Difference between camera.setLocation and cameraNode.setLocation

Hi JME gurus,



can anyone please explain to me what is the difference between the camera.setLocation method and the cameraNode.setLocaleTranslation method?



Accoring to the scene graph schema I suppose setLocalTranslation method to be responsible for the translation in relation to the parent. So, if my child has got (30,0,0) relative position to its parent and the parent moves (100,0,0) from world (0,0,0) the world coordinates of the child afterwards are (130,0,0). This of course holds for all SceneNodes and therefore also for CameraNode.



But why does the camer object also have a location? A location relative to what? Is it not enough add the camera to a CameraNode and define the position according to the CameraNode.



My question is in relation to what is the position of the CAMERA object defined?



Thanks a lot,



Regards,

Equilibrium

if you want to set the location of the camera manually, use cam.setLocaltion(). (thats the camera's absolute location)



if you want the camera to follow a node, use CameraNode, forget about the camera and just use the nodes's methods to rotate/move the camera.

Hi i a cameranode which folows a reacts to movements of a wiiboard to rotate to the left or right

Now i want to make a second camera node which rotates according to the height of the waves of the sea i have.



Is that possible?

To have two camera nodes?



Because now i have and it does not work.



Thanks

Good morning.

if you want the camera to follow a node, use CameraNode, forget about the camera and just use the nodes's methods to rotate/move the camera.


Is there any recent change? I'm asking because it is not working (camera is not moving). Do we have to attach CameraNode to rootNode?

Hello,



you can attach CameraNode to any Node in your scene Graph.



Regards,

Equi

Here is the things is did:

Rewrote and changed ChaseCamera class according to my game (tested, works good).

Extended CameraNode and added a code in constructor super(cam).

Edited two lines:

[java]

cam.setLocation(pos.add(0, offset, 0));

cam.lookAt(target.getLocalTranslation().add(0, offset, 0), initialUpVec);

[/java]

made:

[java]

setLocalTranslation(pos.add(0, offset, 0));

lookAt(target.getLocalTranslation().add(0, offset, 0), initialUpVec);

[/java]

I want to know is my camera colliding in any moment with walls or other scene elements (this.collideWith(scene, results)).

Hello,



I do not know ChaseCamera due to the fact that I use my own Camera instance. However, I would guess that the logic of ChaseCamera is to look at a point in 3D space. As far as I understand you do not only want the camera to look at a specific point in 3D space (this must already be solved by ChaseCamera) but also want to add the Camera to a CameraNode and make the camera be updated according to the localTranslation of your CameraNode.



Use one of those two code snippets…



[java]

CameraNode cameraNode=new CameraNode(yourCamera);

cameraNode.setControlDir(ControlDirection.CameraToSpatial);

[/java]



or



[java]

CameraNode cameraNode=new CameraNode(yourCamera);

cameraNode.setControlDir(ControlDirection.SpatialToCamera);

[/java]



I think it is ControlDirection.CameraToSpatial



This should do the trick. The reason is that a Camera is “magically” as it has been told to my by Normen. It is not really part of the 3D scene. It is like “god” watching the scene. So there is no localTranslation for a camera, only a position which is the camera’s worldTranslation (don’t know why it is not called translation either). The CameraControl does nothing else than recalculating the camera’s world translation (=position) according to the relative position of the CameraNode’s position to its parent.



Regards,

Equi

Thank you very much, but you were wrong. It is ControlDirection.SpatialToCamera :D.

life is hard…