Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

Car physic and terrains

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
kulpe
Asked:
kulpe
  • 6
  • 5
1 Solution
 
kulpeAuthor Commented:
all I need is the geometry of the terrain, no texture etc...
0
 
ikeworkCommented:
hi kulpe,

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

ike
0
 
kulpeAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ikeworkCommented:
can you show the datastructure of the heightmap expected by Ageia
0
 
kulpeAuthor Commented:
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
 
kulpeAuthor Commented:
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
 
ikeworkCommented:
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
 
kulpeAuthor Commented:
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
 
ikeworkCommented:
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
 
kulpeAuthor Commented:
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
 
ikeworkCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now