[SOLVED] I need something like ”chaseCamera.getLocation/.getPosition()”

hey monkeys,

i’d like to attach a spotLight to my chaseCam:

i already made it point at the player :

[java]spot.setDirection(player.getPhysicsLocation());[/java]

(yeh, thats nothing special :smiley: )

but i cant figure out how to get the Position of the camera itself. I know, that I could get it to work with vector calculations etc. but my brain is in hollyday-mode so i don’t even get it done this way.

maybe somebody already got a method “chaseCamera.getPosition()” written himself and is willing to post it here.



TaiTen

Chase cam is attached to a spatial, so its location is the location of the spatial.

:smiley: what a picture… probably thats why im not an artist:



http://i.imgur.com/HFu2Z.png



alright. so this is what i want to do:

i want a spotLight, which has the Position of my chaseCam (blue dot) and it should point at the spatial (red dot).



why?

when i move my camera arround my character theres always a side, without light(sword/shield/… is simply black) so i want a weak light source to light up the side of my character im “looking” at with the camera.







TaiTen

[java]AmbienLight someLight = new AmbientLight();

// set the light stuff

characterGeometry.addLight(someLight);[/java]

I’m seriously glad you want to help, but this is like:



Me: I want to go to spain.

You: Well in Itally is good weather, too.



i tried your suggestion, but:

http://i.imgur.com/IvHoO.png

only the character itself is lighted, not the attached items :frowning:





TaiTen

well i decided to go to spain but the east coast, so its closer to italy :smiley:

heres my sollution:

thou it should also work fine with spotLight i decided to go with a point light:



[java]pl = new PointLight();

pl.setPosition(new Vector3f(0,10,0));

rootNode.addLight(pl);[/java]



[java]public void simpleUpdate(float tpf){



pl.setPosition(new Vector3f(((float)Math.cos(-chaseCam.getHorizontalRotation())*chaseCam.getDistanceToTarget())+player.getPhysicsLocation().x,((float)Math.sin(chaseCam.getVerticalRotation())*chaseCam.getDistanceToTarget())+player.getPhysicsLocation().y,((float)Math.sin(chaseCam.getHorizontalRotation())*chaseCam.getDistanceToTarget())+player.getPhysicsLocation().z));



}[/java]



to use this with a spotLight i’d also have to come up with a calculation for th curent player location (since only “direction” and not “look at” is supportet with spotLight), but this one works just fine for me and is less calculation for me AND the machine.