Solved

Car physic and terrains

Posted on 2007-11-25
11
511 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
Comment Utility
all I need is the geometry of the terrain, no texture etc...
0
 
LVL 20

Accepted Solution

by:
ikework earned 350 total points
Comment Utility
hi kulpe,

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

ike
0
 

Author Comment

by:kulpe
Comment Utility
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
Comment Utility
can you show the datastructure of the heightmap expected by Ageia
0
 

Author Comment

by:kulpe
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:kulpe
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

743 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

8 Experts available now in Live!

Get 1:1 Help Now