Tree Collision is not accurate with supplied vert & ind

gzmzhen

10-09-2006 17:08:44

So I'm having a rather large problem where the tree collision produced by ogerNewt is inaccurate when compared to the actual polygonal geometry created that uses the same vertex and index data.

In particular, sometimes the car in my program will go beneath the ground, or drive above it.

To solve this problem I want to see what ogreNewt makes out of the data I send it (I'm probably doing something wrong, but it will help to see what). So I'd like to have the collision object be draw over the top of my geometry like they did in the pictures on this forum:
http://www.ogre3d.org/phpBB2addons/view ... +collision

How do you do that?

HexiDave

10-09-2006 19:30:15

Press "F3" on your keyboard to show debug lines - make sure your terrain isn't at a different level of detail of that which you created the TreeCollision as that's usually what the cause is. If you're not using OgreNewt's BasicFramelistener, but creating your own to update Newton, try it (the F3 debug is in there - not hard to implement on your own, though.)

gzmzhen

10-09-2006 19:37:11

What do you mean by a different level of detail?

I create the terrain manually with the vertecies and indecies, then give ogreNewt the same data. Most of the time the collision is perfect and lines up correctly, however there are times where the car dips below the terrain or above it. Usually when it dips below it no longer matches up with the treeCollision to the sides of it and then falls down.

I'll post a picture in a second.

gzmzhen

10-09-2006 19:51:33

So here are the debug lines...

It's hard to see unless you're at an angle like this where it's apparent that the car is driving in the sky.

So, it fairly obvious that the collision is being constructed incorrectly... What were you saying that the problem usually is?

HexiDave

10-09-2006 21:17:36

Ah, sorry - forgot you were using the manual mesh (1 piece.) How many vertices/indicies are you feeding to OgreNewt? If you've got an extremely large mesh, the information may be getting screwed up from precision issues.

gzmzhen

10-09-2006 21:43:34

I'm sending it 16*16 different treeCollisions that have 65*65 vertices and 3*64*64 indicies.

Would it be better to split them up more, or less or what?

walaber

10-09-2006 21:53:10

are you certain that your visual mesh doesn't have an offset from the origin that you are not also applying to the rigid body you are creating?

gzmzhen

10-09-2006 21:56:47

Absolutely positive. The manual mesh is created in place (no translations) and then the same data is sent ogreNewt.

HexiDave

10-09-2006 22:58:03

Are you loading your TreeCollision from a previous serialization or are you building it brand new each time you load? If you serialze, erase the cache you created and let it re-build.

gzmzhen

10-09-2006 23:13:01

I've done that several times.

In fact I just tested to see if it would work if I break it up into even smaller pieces - and it seems to be more accurate, but there are still parts where it isn't aligned with the actual polygons.

Is the tree collision constructed exactly as the polygons it is sent in as? Does it try to reduce the number of polygons or so? Is it necessary, or is there some way I can turn it off to see if it will fix it?

I just realized I have optimizing on - let me turn it off and see if that helps.

Additionally, when I broke it up into smaller pieces, I get an error after a while saying it can't serialize the mesh because it can't open the specific file. I'm guessing either it's not closing the files afterwards. (I fixed that in my program by letting it load stuff if it's there or start creating it if it isn't.)

gzmzhen

10-09-2006 23:30:08

Ok, it was because I had optimize on ... I feel rather dumb for posting this. Sorry guys.

walaber

11-09-2006 00:10:28

i was about to ask that :)

gzmzhen

11-09-2006 01:01:28

You see, what makes me feel particularly dumb is that the other topic I linked to was solved by turning optimization off (i.e. "if there's a problem, usually turning it off will help fix it") - and I assumed it was off already.

Anyways, it's looking good now.

On a side note, Walaber, what would I need to do to stop a vehicle from your vehicle class from sliding sideways down a slope? I basically just want to increase the friction between the tires and the road (maybe the ground too). This should help when turning as well, cause the vehicle likes to spin out a lot.

Thanks,
Nate

walaber

11-09-2006 04:13:00

in stunt playground, I created a material for the world, and a material for the vehicle. inside the callback, I detected if a tire was touching the world, and it so, I increased the friction to a high value. if the chassis was touching, I set the friction to a lower value. it worked pretty well for me.

gzmzhen

11-09-2006 04:15:27

Hmm... I have my static friction values between the car and the road (and the car and the ground) set to the max of 2.0, but it still seems to slide sideways. That is, when the vehicle is stationary, it slides sideways if aimed sideways down a slope. You didn't have any problems like this?

gzmzhen

11-09-2006 23:33:37

Walaber,

I think you misunderstand what my problem is, and I think you are the best that can help me since I'm practically using a very similar setup to what you used for StuntPlayground Vehicles.

So, when the car is not moving at all (not being accelerated or anything) it will slide slowly (but noticably) due to the fact that the wheels are not creating enough frictional force against the road to resist the movement. I've created a materialpair that uses the two IDs (and set it to 2.0) and it doesn't seem to stop it from sliding. Also, when you drive, the rear end of the vehicle likes to slip.

Are there ways to improve this effect? I'd prefer that if the car isn't being moved at all that it considers itself stationary. I'm thinking in the worst case scenario I create a collision callback and watch for when it has reached 0.0mph either from braking or rolling, and then just make sure setVelocity(0) until the accelerate button is pressed. I don't think it's necessary to make such a callback, so I'm asking if there's something else I can do first.

Thanks,
Nate