In 3d graphics there are basically several coordinate systems that exists. The useful ones are model space, world space, view space, clip space.
Each one is basically a coordinate system. When you do a Nodepath.setPos(x,y,z) you are setting the world space coordinate of the nodepath.
However, when you get vertex position and normals from the NORMAL and POSITION keyword in cg… or any shading language for that matter, you are getting it model space.
Model space is coordinate systems of your model or in panda, your nodepath. Every nodepath has different model space origin. So if your vertex is at point (1,1,1) and your node is at (0,0,0) then since model space origin and world space origin are the same, the vertex model space coordinate is still (1,1,1).
However, if you move your node to (1,0,0). The vertex’s world space position is now (2,1,1), but the vertex’s model space position is still (1,1,1). Its just simple addition, but it gets more complicated with scaling and rotation.
The next useful coordinate system is the view space. You can think of view space coordinates as the model space coordinate system for the camera. Its basically the same thing.
So… when you doing stuff, always make sure you are calculating vectors and comparing vectors in the same coordinate space.
You can read more about it here: panda3d.org/manual/index.php/S … ate_Spaces
In any case, to help you out panda can automatically give you the matrices you need to convert a vector from one coordinate space to another. So all you need to do is look at what is provided and then muliply it using the mul command.
for example the modelview matrix transforms something from model space to view space.
So if I calculate a light vector in model space and I want to compare it with something in view space, I can do this:
mul(trans_model_to_apiview, vector)
[/code]