[SOLVED]HieghtField Collision

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: HieghtField Collision

Postby Julio Jerez » Tue Aug 03, 2010 2:29 pm

why they montain do not look in the righ place?

also there is still the orientaion of the diagonal in each grid.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Tue Aug 03, 2010 2:33 pm

Because they aren't in the same place, not sure why. They are the same heights but the X,Z coords are not the same.
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Re: HieghtField Collision

Postby Julio Jerez » Tue Aug 03, 2010 2:36 pm

you must have a bug on the horizontal scale them

why you calculate the size of a grid like this
Ogre::Real horizontalScale = terrain->getWorldSize() / (terrain->getSize() - 2);
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Tue Aug 03, 2010 2:44 pm

Ok lets be clear what you mean by *size* of cells.

Ogre::Real horizontalScale = terrain->getWorldSize() / (terrain->getSize() - 2);

terrain->getWorldSize() will return the total size of the terrain. SO if we have a terrain that is 128x128 the terrain world size would be 256. So if we divide the world size by the size of one size( terrain->getSize() ) we are left with the number of cells in the terrain.

If we are talking about individual sizes of the actual cell i will probably have to divide the cell by the quotient of the previous line.

Ogre::Real horizontalScale =terrain->getSize() / ( terrain->getWorldSize() / (terrain->getSize() - 2) );

However that will blow the scale out of proportion as i've already tried it.
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Re: HieghtField Collision

Postby Julio Jerez » Tue Aug 03, 2010 2:49 pm

I do no knwo where are you getting that reasoning but doe not sodun right.

the horizionat scale is the spacing between two consecutive cells, I am getting it is GetSize();
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Tue Aug 03, 2010 2:54 pm

Well despite whatever i change the horizontal scale to, it doesn't line the collision up
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Re: HieghtField Collision

Postby Julio Jerez » Tue Aug 03, 2010 3:05 pm

I do not knwo what could be wrong, it is like the collision and the visual mesh are two different bitmap.
That has never happened before.
this is why said modifi jut on point at teh lower left corner so tha you can see what happen.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Tue Aug 03, 2010 9:17 pm

Well i'm not sure how to fix it either. But thank you for spending so much time on this, I've learned alot.
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Re: HieghtField Collision

Postby Julio Jerez » Tue Aug 03, 2010 9:27 pm

but there have to be a bug somewhere, because the hiegh field do not make the values, and that has worked for every one who has use so far.

I am always surprice at how for some reason newton engine seem to have the poorest peformance when it is used with Ogre.
for being a Industry standard in Graphics engine, I do not know why teh simnplest thing seem to be so complicated.
I feel sorry, you could not get any results, with something in my view is so trivial.

plus since you are an Ogre user, it seems not one in Ogre Forum could lend you some help with that.
because I am 100% conviced that the data you are reading from the Terrain hightmap to pass to Newton collision, is not right.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Wed Aug 04, 2010 8:18 pm

You were right. I didn't look deep into it but the problem were the elevations. It probably was that they were in a scrambled sort of order, im not sure but i've fixed it. Now there's one more problem. Going back to the actual terrain i'll be using, the collision is above the visual entity by a bit.

*EDIT*: I did find out what the problem before was exactly. The function i was calling to get the elevations was giving me the heights in world coordinates, meaning, that 0,0 would have been the center of the terrain rather than the bottom left corner. So when we looped through that data we were already halfway through the elevations so when the loop continued to extract heights, it was offset because of where it started. Giving us the result we had previously.

Also i think that the problem between Newton and Ogre is that Ogre uses this confusing World and Local coordinate system where it seems everything for Newton is in world coordinates (thats why when we first started the origins of the terrain were different)

Image

Uploaded with ImageShack.us
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Re: HieghtField Collision

Postby Julio Jerez » Wed Aug 04, 2010 10:33 pm

Ha that look better, now all you nee to so is translate the veriical position of the Body matrix by the mint TerrainHioght

Code: Select all
  // here set the origin offset like you did to align the mesh and the collision
       x =  (width / 2) * OgreTerrainGetCellSize();
       z =  (height / 2) * OgreTerrainGetCellSize();
      matrix[3 * 4 + 0] -= x;
      matrix[3 * 4 + 2] -= z;
 float min = terrain->getMinHeight();
matrix[3 * 4 + 1] -= min;


also do no forgte to meake sure the dignal of newton Terrain Grid an dteh Ogre Traiin Gord Match,

for that you render both the Netown and Ogre Terrain in wireframe, and if the grid looks like the diagonals cross each other on the grid center,
then you set the GridOrination form zero to one when you call NewtonCreatehieghtfield.

I thonk that will be all you nee to hav eteh Terrain working, Congratulations.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: HieghtField Collision

Postby SFCBias » Wed Aug 04, 2010 10:37 pm

Thank you so much for all the work you put into this one thing. I will implement this in OgreNewt
SFCBias
 
Posts: 54
Joined: Tue Jun 22, 2010 12:40 am
Location: Hephzibah,GA

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests