Jump to content

[SOLVED] how to inverse the direction of a player with modelview matrix?


photo

Recommended Posts

Posted

This might be a very stupid question, But I really can not figure out how to do this.

 

In my scene, I need to update a PlayerDummy from a cacluated modelview matrix, but I found my modelview matrix are almost correct except it's looking direction is inversed.

 

I know that unigine use same format of modelview matrix as opengl, according to opengl, I just need to inverse the column 0(left) and column 2(direction), and leave the columnt 1/3 unchanged, that should inverse the camera's looking direction.

 

But in my script, i use this to inverse

            mv.m00m10m20m30 = -mv.m00m10m20m30;
            mv.m02m12m22m32 = -mv.m02m12m22m32;
            dummy.setModelview(mv);

and result is, dummy camera are gone,  there is nothing to be rendered, only background color.

 

So how can I correctly inverse the looking direction of a player by using modelview matrix?

  • 1 month later...
Posted

Unigine scripts support m.col0/row0 syntax, so m00m10m20m30 can be replaced.

To inverse camera direction just multiply your matrix by rotateX(180.0f).

×
×
  • Create New...