How hard to make the engine right-handed?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
mjstone
Posts: 8
Joined: Mon May 18, 2009 7:33 pm

How hard to make the engine right-handed?

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Piraaate
Posts: 18
Joined: Wed Feb 21, 2007 3:04 pm
Location: Valence, France
Contact:

Post 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 ?
ImageImage
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Katsankat
Posts: 178
Joined: Sun Mar 12, 2006 4:15 am
Contact:

Post 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();
Zenja
Posts: 3
Joined: Wed Jun 24, 2009 2:31 am
Location: Melbourne, Australia
Contact:

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Post Reply