Skip to Main Content

How to attach an avatar (eg. gun) to moving camra

843799Dec 19 2001 — edited Dec 19 2001
hi all!
I am trying to attach an avatar to a moving camera. This should be placed just in front of me (just like in quake :) !) so, that wherever I move in my 3D world this gun should move with me. I did manage to move the camera by using RotPosPathInterpolator but I don't really know how to attach the gun to moving camera. My little demo is very small only few lines of code so if you want then I could send you the whole demo and you could have a look if you could?!.
My email:

this is a part of my code:

RotPosPathInterpolator rotPosPath = new RotPosPathInterpolator( alpha, tgVpTrans, axisOfRotPos, knots, quats, positions);

////////// END

// 1. controlles the The virtual user's location and orientation
ViewPlatform vp = new ViewPlatform( ); // Defines a view point within that locale
// It defines a frame of reference for the
// user's position and orientation in the virtual world

vp.setActivationRadius( 1000.0f ); // 2.
vp.setViewAttachPolicy( View.NOMINAL_SCREEN ); //3.determines how the user's View is placed
//relative to the ViewPlatform's origin
// in this case (origin at screen center)
myView.attachViewPlatform( vp );

tgVpTrans.addChild( vp );

Transform3D tStep = new Transform3D( ) ;
//tStep.rotY( Math.toRadians( 30 ) ) ;
//tStep.setTranslation( new Vector3d( 0.0f, -3.0f, 30.0f ) );
TransformGroup tgStep = new TransformGroup( tStep );

tgStep.addChild( createAvatar( app, 1.0, 0.0, 0.0, 10.0 ));

tgStep.addChild( tgVpTrans );

vpBranchRoot.addChild( tgStep );

//vpBranchRoot.addChild( tgVpTrans );

locale.addBranchGraph( vpBranchRoot );

I am not sure where to attach the gun. At the moment the avatar is not moving at all.
Thanks for help!:)
Post Details
Added on Dec 19 2001
1 comment