Hi
I want to have lights, that can be transformed by TransformGroups but also light other parts of the scene. E.g. the geometry of a flashlight should be together in one TransformGroup with the light.
Is this really not possible ???
Hi
I want to have lights, that can be transformed by TransformGroups but also light other parts of the scene. E.g. the geometry of a flashlight should be together in one TransformGroup with the light.
Is this really not possible ???
It’s possible, just attach the lights to the root of the scene graph and use the setLocation and/or setDirection methods to the desired world-space location and/or direction of the light.
Yeah sure, but I want to have the Lights to be also part of the scenegraph, so that they move with the object they belong to. (I have a object, which is represented in a subgraph, that contains these Lights) I think it wouldn’t be very good if I have to reset the position of the light every frame.
Compute the orientation, translation of your object, transform them to VirtualWorld Coords and use them for the orientation, position of your light.
I use this method to have a virtual robot mounted camera. The camera is a simple cube and I compute the position on one of the cubes faces to be the origin of the camera. Now when the robot and or the camera is moving the view moves along. Positioning your light should work the same way (I suppose).
Get the geometry of the object you want to attach the light to e.g. your flashlight front. Compute the normal and put the light on some position along this normal. Then transform this position using localToVworld into the Vworld coordinate space. Whats missing now is the orientation but you need to get this from the transformgroup your flashlight is attached to (and again: localToVworld transformation).
Perhaps this is works as well: Get the local transform of your flashlight (4x4 Matrix). Put the translation of the lightsource in it (e.g. the position of the light relative to the flashlight). Then use localToVworld on this 4x4 Matrix and this should be the transform to use with your light.
Ca$