Skip to main content

Attenuation & MouseZoom

3 replies [Last post]
Anonymous

I want to change the Attenuation of the PointLight with the help of the MouseZoom. Can anybody say me, how I can do it?
many thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

By now I know
TransformGroup mouse_zoom = new TransformGroup();
mouse_zoom.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
mouse_zoom.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
// Mouse Zoom
MouseZoom m_zoom = new MouseZoom();
m_zoom.setTransformGroup(mouse_zoom);
m_zoom.setSchedulingBounds(allBounds);

objRoot.addChild(m_zoom);

TransformGroup light = new TransformGroup();

PointLight myLight = new PointLight( );
myLight.setEnable( true );
myLight.setColor( new Color3f( 1.0f, 1.0f, 1.0f ) );
myLight.setPosition( new Point3f( 0.0f, 0.0f, 2.0f ) );
myLight.setAttenuation( new Point3f( 0.0f, 0.0f, 1.2f ) );

myLight.setInfluencingBounds(allBounds);
light.addChild(myLight);

mouse_zoom.addChild(light);

nitro
Offline
Joined: 2004-09-12
Points: 0

I think you need to implement your own Beahviour or a MouseMotionListener and set the appropriate values for your light.

this might look something like this:

[code]
int x_old;
PointLight light;

public void mouseMoved(MouseEvent ev){
int xdiff=xOld-ev.getX();
light.setAttenuation(new Point3f(0,0, xdiff/10.0);
}
[/code]

I just wrote this down here the syntax might be wrong...

Anonymous

thank you :-)