Solved

Car physic and terrains

Posted on 2007-11-25
11
525 Views
Last Modified: 2013-12-21
hi there,
we Developed our car using Ageia API, now we need to drive it over a OpenFlight terrain using our own OpenGL rendering system. our question is how to convert the openflight terrain to heightfield so the Ageai can understand the terrain....

10x
0
Comment
Question by:kulpe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 

Author Comment

by:kulpe
ID: 20348431
all I need is the geometry of the terrain, no texture etc...
0
 
LVL 20

Accepted Solution

by:
ikework earned 350 total points
ID: 20348765
hi kulpe,

what formats can you export the OpenFlight-terrain and what format does the Ageia API expect?

ike
0
 

Author Comment

by:kulpe
ID: 20348971
I can export it to:
AutoCAD file *.DXF
VRML *.wrl
WaveFront OBJ *.obj
STL .stl
X-Plane *.obj

Ageia API accept heightmap.
we are using Ageia for the physic behavior of the car, therefor the Ageia API must be aware of the terrain the car is driving on...
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 20

Expert Comment

by:ikework
ID: 20350519
can you show the datastructure of the heightmap expected by Ageia
0
 

Author Comment

by:kulpe
ID: 20351608
this is how built a HeightField in Ageia API, all I need to know how to get the relevnt info from the openflight file...
NxHeightFieldDesc heightFieldDesc;    heightFieldDesc.nbColumns           = nbColumns;    heightFieldDesc.nbRows              = nbRows;    heightFieldDesc.verticalExtent      = -1000;    heightFieldDesc.convexEdgeThreshold = 0;    //Allocate storage for samples.    heightFieldDesc.samples             = new NxU32[nbColumns*nbRows];    heightFieldDesc.sampleStride        = sizeof(NxU32);    NxU8* currentByte = (NxU8*)heightFieldDesc.samples;    for (NxU32 row = 0; row < nbRows; row++)        {        for (NxU32 column = 0; column < nbColumns; column++)            {            NxHeightFieldSample* currentSample = (NxHeightFieldSample*)currentByte;            currentSample->height         = computeHeight(row,column); //Desired height value. Signed 16 bit integer.            currentSample->materialIndex0 = gMaterial0;            currentSample->materialIndex1 = gMaterial1;            currentSample->tessFlag = 0;            currentByte += heightFieldDesc.sampleStride;            }        }    NxHeightField* heightField = gScene->getPhysicsSDK().createHeightField(heightFieldDesc);    //Data has been copied therefore free the buffer.    delete[] heightFieldDesc.samples;

Open in new window

0
 

Author Comment

by:kulpe
ID: 20351630
currentSample->height         = computeHeight(row,column); //Desired height value. Signed 16 bit integer.            
currentSample->materialIndex0 = gMaterial0;            
currentSample->materialIndex1 = gMaterial1;            
currentSample->tessFlag = 0;            

currentByte += heightFieldDesc.sampleStride;

well this is better. basicly it create a array of the terrain and travers the aray and assign each square the height value.
0
 
LVL 20

Expert Comment

by:ikework
ID: 20351799
so basically you have a grid of vertices in the OpenFlight-App, right? do the have the same amount of rows an columns in there (vertices in xz-plane)?
that would be the easiest way, to generate the terrain in OpenFlight with the same amounts of rows and cols and the same distances between them.
then you just export it and read the y-values from the export-file and put it in a two dimensional float array as temporary buffer, then you can create your heightmap from that buffer-info

so the export-format is not a big question, just choose one and read the y-values into a two- dimensional array.

just make sure the OpenFlight-terrain is made up of the same amount of rows and cols and with a fixed step-size in xz-plane, the same way Ageia expects it ..
0
 

Author Comment

by:kulpe
ID: 20390596
well, I dont know of a format like that, every format export keep the openflight polygons, I dont hava a grid I just have a polygons... with AGEIA API I didn't manage yet to read this format... It assume a matrix
0
 
LVL 20

Expert Comment

by:ikework
ID: 20390802
ok, when i say grid, i mean polygon-points that are equally distributed in a plane, letzs say xz. see the example below in the code-snippet-section. the points can only be free in y. x and z lie in a grid. this *grid* could be easily converted into a heightmap. because that is what a heightmap is, it implies the step in x and z from one point to another is equal, just the height (y) can be different from one point to another.

see the picture below. this *grid* consist of polygons (triangles) you dont see the change of y in the picture, because we look down to the xz-plane.

so what i'm saying is, if you didnt create the surface in OpenFlight like this *grid*, then its gonna be more difficult, because then you have to clip the polygons/triangles before you can pass the y (height) to the matrix(heightmap) and then its not just importing.

so the important question for the *import* is:

is the OpenFlight surface created like the grid below or are the polygon-points distubuted randomly? if it is created like the grid below then its an easy task and we can go on choosing one export-format and we're gonna show you how to import it.
if not then we have to import the surface and clip it to *sample* the y at given positions for the heightmap, i.e. at 2d-point {x,z}
{0,0} {0,1} {0,2}
{1,0} {1,1} {1,2}
{2,0} {2,1} {2,2}

we need that information to give you the best assistance ..
+---+---+---+---+
|  /|  /|  /|  /|
| / | / | / | / |
|/  |/  |/  |/  |
+---+---+---+---+
|  /|  /|  /|  /|
| / | / | / | / |
|/  |/  |/  |/  |
+---+---+---+---+

Open in new window

0
 

Author Comment

by:kulpe
ID: 20402092
well I got my answer,
I converted the openflight into STL and the loaded the polygon data into a mesh object and hopes it works...
well 10x alot u didnt give an answer, but I'll be more than happy to give you some of the points
how do I do it???
0
 
LVL 20

Expert Comment

by:ikework
ID: 20402940
you're welcome .. ;)

> how do I do it???
there is an accept-button on each post, isn't it? have a look here:

http://www.experts-exchange.com/help.jsp#hi68
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question