Horde3D

Next-Generation Graphics Engine
It is currently 26.11.2024, 07:36

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 17.04.2011, 15:32 
Offline

Joined: 17.04.2011, 15:13
Posts: 8
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


Top
 Profile  
Reply with quote  
PostPosted: 17.04.2011, 16:23 
Offline

Joined: 11.09.2010, 20:21
Posts: 44
Location: Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: 17.04.2011, 18:53 
Offline

Joined: 17.04.2011, 15:13
Posts: 8
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?


Top
 Profile  
Reply with quote  
PostPosted: 17.04.2011, 21:49 
Offline

Joined: 11.09.2010, 20:21
Posts: 44
Location: Germany
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group