Solved

Car physic and terrains

Posted on 2007-11-25
11
512 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to copy an image file into clipboard C/C++? 1 152
bunnyEars2 challenge 6 106
Which Linux flavors will this run on? 6 76
show out valin of json for debugging in visaul c++ 1 15
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now