Horde3D http://horde3d.org/forums/ |
|
SceneGraph vs Camera nodes inconsistency? http://horde3d.org/forums/viewtopic.php?f=2&t=1502 |
Page 1 of 1 |
Author: | jacereda [ 17.04.2011, 15:32 ] |
Post subject: | SceneGraph vs Camera nodes inconsistency? |
Hi, I'm trying to bring the lua bindings back to life. I wrote a small app using it, but found a couple of oddities: If I put a camera at 0,0,20 and a model at 0,0,0 both without any rotation, I can see the model facing towards the camera. Shouldn't both objects be facing the same direction (and thus, a 180 degrees rotation around Y would be needed in the camera to see the model)? Also, why is the model facing towards the positive Z axis? I would expect it to be facing towards the positive X axis... I'm using the same code to control any object, and when I try to control the camera, the first issue makes it feel inverted. The second issue, requires adding 90 degrees to the rotation when moving objects (I can see that same thing in the standard knight example). Thanks in advance, Jorge |
Author: | Rauy [ 17.04.2011, 16:23 ] |
Post subject: | Re: SceneGraph vs Camera nodes inconsistency? |
The camera in untransformed state faces along the negative z-axis so it is correct, that it sees the model. A model actually faces nowhere, it just has a position and orientation in space (in your case the position is at the origin and its orientation is aligned with the world's coordinate system). But for it to face somewhere the facing direction has to have a semantic meaning (e.g. the viewing direction of a character) and is completely model dependent. If your model faces along positive z and you want it to face along positive x, either rotate it, change its geometry or use another model. |
Author: | jacereda [ 17.04.2011, 18:53 ] |
Post subject: | Re: SceneGraph vs Camera nodes inconsistency? |
Rauy wrote: The camera in untransformed state faces along the negative z-axis so it is correct, that it sees the model. Yes, my problem is that models in untransformed state face the opposite direction as cameras in untransformed state. Let me try to clarify it with some code: Code: function transformable:advancexz(yangle, speed) local rady = math.rad(yangle-90) self.px = self.px + (speed * math.cos(rady)) self.pz = self.pz - (speed * math.sin(rady)) end I have a model at 0,0,0 without any rotation and a camera at 0,0,20 also without any rotation. If I apply that code to the model, it advances towards positive Z. That means that the untransformed model 'faces' towards positive Z. Same happens with the camera. But the camera in untransformed state happens to be facing negative Z. What that means is that I can't use the same code to control a model and a camera. That seems wrong. Also, I think the -90 smells. Why not have everything facing towards positive X? |
Author: | Rauy [ 17.04.2011, 21:49 ] |
Post subject: | Re: SceneGraph vs Camera nodes inconsistency? |
This is no inconsistency, just use another function/model/tranfsormation. You define the facing direction of your model and you define the code to transform it. The negative-z facing direction of the camera is quite common and standard in OpenGL, as an identity view transformation cooresponds to a camera at the origin facing along negative-z. The facing direction of model is specified by YOU, by changing the model or its transformation or your code and therefore the interpretation, what a facing direction is. Your code snippet is not part of Horde3D and Horde3D does not know about a facing direction of a model, as stated above. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |