Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Car physic and terrains

Posted on 2007-11-25
11
Medium Priority
?
530 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 700 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
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 clear a vector as well as how to detect empty vectors in C++.

722 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