Page 1 of 1
How hard to make the engine right-handed?
Posted: Fri Jul 03, 2009 2:06 pm
by mjstone
I'm wondering if it would be possible for me to hack my copy of Irrlicht to make it right-handed.
Other tools and libraries that I'm using are right-handed, and RH + Z-up makes more sense for my application. Having to switch my brain between systems is becoming tiresome.
So, how far-reaching is the LH convention? Could I tweak the camera and culling code and get a RH system? I'm using Collada and .X importers -- I can presumably just comment the FlipAxis assignment for Collada. I'm not sure about .X.
Advice, anyone?
Posted: Fri Jul 03, 2009 3:12 pm
by hybrid
Well, all basic mesh handling algorithms, the render routines, driver setup, etc. needs to be rewritten then. I doubt that it makes any sense.
Posted: Tue Jul 07, 2009 4:22 pm
by Piraaate
hmmm, I got it working on a right-handed platform by only tweaking the CCameraSceneNode.cpp code and the CParticleSystemSceneNode.cpp code if I remember well...
@Hybrid: Why do you think he should rewrite something else ?
Posted: Tue Jul 07, 2009 9:58 pm
by hybrid
Right-handed systems have a counter-clockwise winding order and other things. Having a completley right-handed system would require very much rewriting.
Posted: Wed Jul 08, 2009 3:39 am
by Katsankat
In bsp files, data is stored as RH (after a loong compile),
so either irrlicht has to change, or your application must adapt.
You can make the application Right-Handed.
When loading a model, parent it to an empty scene node and keep a pointer to its mesh.
Later, transform this node, and flip all faces:
Code: Select all
node->setRotation(vector3df(-90.f,0.f,0.f));
node->setScale(vector3df(1.f,-1.f,1.f));
// negative scale (for right -> left hand coordinates system)
// will place models at their right locations, but this will flip normals
// so flip them now
IMeshManipulator* manip = smgr->getMeshManipulator();
for (u16 n=0; n<miscmodelsmeshes.size(); n++)
{
IAnimatedMesh* mesh = miscmodelsmeshes[n];
manip->flipSurfaces(mesh->getMesh(0));
manip->recalculateNormals(mesh);
mesh->drop();
}
miscmodelsmeshes.clear();
Posted: Wed Jul 08, 2009 8:37 am
by Zenja
hybrid wrote:Right-handed systems have a counter-clockwise winding order and other things. Having a completley right-handed system would require very much rewriting.
Cant you just change the winding (eg. in OpenGL it would be glFrontFace(GL_CW)) in your init code?
Posted: Wed Jul 08, 2009 9:54 am
by hybrid
Well, besides getting a handle for this setting, you'd also have to cope with the mesh manipulators and stuff, which don't check for handedness etc. I don't see the point for this.