TreeCollision Problem

dizlexik

08-06-2007 20:07:03

I'm using TreeCollision on some SceneNodes that have a scale of (-1, 1, 1).
When an object with normal scale (1, 1, 1) comes into contact with one of the objects with the negative scale it sorta gets sucked in instead of stopped like it should. Everything works fine when two normal scale objects collide, it's just the (-1, 1, 1) ones that give me the trouble. Any ideas how I can fix this?

walaber

09-06-2007 01:08:05

the problem is that Newton considers the faces of a TreeCollision to have a "direction", which is based on the winding of the vertices when they are passed to Newton.

so, if you have a negative scale, the winding flips, and Newton thinks the faces are pointing the wrong way.

why do you have objects with negative scale?

dizlexik

11-06-2007 14:44:52

Right, I figured that out a little bit after I posted. I've had no luck fixing it yet though.
I have objects with negative scale because I need to have mirror versions of certain things in my scene and I only have one mesh for each object.
I've tried a lot of stuff to fix this including changing the culling mode on the materials etc.. but so far nothing.. And I have no idea how to go about changing the index order of a loaded mesh. I'm guessing that's all I can do right? Or am I missing something more simple?

walaber

11-06-2007 17:47:08

you can't mirror the object in the modeler and re-save to a new .mesh?

otherwise, you will need to modify OgreNewt for your particular need so that if it sees a negative scale on an object, it switches the order on the polygons as it passes them to Newton...

dizlexik

11-06-2007 19:47:37

Well wouldn't it make sense for OgreNewt to do this automatically? If something has a negative scale on an odd number of axes you would always want to reverse the faces right? I don't think I'm a special case for this.
And to answer your question on why I can't just create a new set of mirrored meshes, it's just not feasible for the project I'm working on. There's just too many objects and I really need to be able to do this through code.
Do you think there's a chance that this could be fixed in the next release of OgreNewt?

walaber

11-06-2007 20:01:05

Sorry, but I think your solution is a bit specific to your case. You are probably not using dynamic lighting in your project either, right? becuase using a negative scale will cause problems with the normals on the vertices as well.

However, a compromise would be to add a parameter to TreeCollision functions in OgreNewt that specify the winding order... which I would be OK with implementing.

it's extremely simple, you can add if yourself without waiting for a new version from me.

dizlexik

11-06-2007 20:47:03

That sounds great, thanks a lot!
I'm using Mogre/MogreNewt btw, so making small changes like this isn't exactly the easiest thing for me. And on top of that all I have are the binaries :/
Do you have any idea when you'll be releasing a new version of OgreNewt with this addition in it?

walaber

11-06-2007 21:48:20

well, I'd been waiting on the (anticipated) update to version 1.6 of Newton itself, but perhaps I can clean up the current version and make a quick release with this, and I believe there were a few other things I need to patch up as well.

dizlexik

12-06-2007 19:36:33

Awesome!
I did end up making the change myself for the meantime and it works great.
I made it check to see if an odd number of axes were negative and then reverse the index order accordingly.