Skip to main content

How to Make Scene Lighting Independent of OrbitBehavior?

5 replies [Last post]
edm
Offline
Joined: 2010-09-30

Hi,

I have a scene that contains four objects I can rotate around a central point using OrbitBehavior. I have also set up a few directional lights around the scene.

When I rotate the objects the lighting also rotates around the central point because OrbitBehavior effects the viewplane.

Is there a way to make the lighting stay where it is and have everything else rotate around this central point?

Thanks for the help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miguelmu123
Offline
Joined: 2010-05-11

I'm not sure, but if you can create two differents BranchGroups, and only add the behavior to one, the other BranchGroup won´t be affected by the behavior.

Try it, and tell me :D

Message was edited by: miguelmu123

edm
Offline
Joined: 2010-09-30

I don't think I can add the behaviour to only one branchGroup, as orbitBehaviour is added to the viewingplane, which is part of the universe rather than belonging to a specific branchGroup.

This is my code for setting the behaviour :

TransformGroup VpTG = u.getViewingPlatform().getViewPlatformTransform();
OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(bounds);
viewingPlatform.setViewPlatformBehavior(orbit);

I've tried adding the scene and the lighting to separate branchGroups but this didn't help.

miguelmu123
Offline
Joined: 2010-05-11

Ok, I'm not sure but i think that you can add the behavior only to one branch with the method addChild()

myBranchGroup1.addChild(behavior);

In this example the behavior only affect to this branch, I think.

edm
Offline
Joined: 2010-09-30

Compiles ok but crashes with

Exception in thread "AWT-EventQueue-0" javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be added

miguelmu123
Offline
Joined: 2010-05-11

RestrictedAccessException - if this group node is part of live or compiled scene graph and the child node being added is not a BranchGroup node

I'm not sure but you must add the behavior before compile the scene.