We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › flying bat orientation
Page Index Toggle Pages: 1
flying bat orientation (Read 800 times)
flying bat orientation
Dec 7th, 2008, 7:20am
 
Hi,

I'm putting together a flocking installation involving bats flying around on a projection where users can interact with bat flocks.

I've got a model of a single bat into processing and got it's wings flapping around. Now I'm attempting to orientate the bat model in the direction it is travelling. It's a lot trickier then anticipated, when I rotate the the bat around one axis, it effects the other axis. The way I see it working, the left and right movement will be the bat model rotating around the Y axis and the up and down movement will be the bat model rotated the Z axis... with a few other cases to make it flip around when upside down.

Currently trying to do this using matrix transformations.

Has anyone done anything similar to this or can point me to some resources?
Re: flying bat orientation
Reply #1 - Dec 8th, 2008, 5:16am
 
here what i've found from an existing thread,
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1206925856

can't seem to crack this one.
here is what i have so far.
trying to orientate the bat to point the direction it is travelling.

Vec3D out, up, right;



up    = new Vec3D( 0, 1, 0 );
out   = locs[ 0 ].sub( locs[ 1 ] ).normalize();
up    = up.cross( out ).normalize();
right = out.cross( up ).normalize();



float[] m;
m = new float[]
 {
   right.x, up.x, out.x, 0,
   right.y, up.y, out.y, 0,
   right.z, up.z, out.z, 0,
   0,
    0,
  0,
 1
 };

FloatBuffer rotMatrix;
rotMatrix = ByteBuffer.allocateDirect(4 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();



rotMatrix.put( m );



rotMatrix.flip();

gl.glPushMatrix();
gl.glMultMatrixf( rotMatrix );

// draw.

gl.glPopMatrix();
Re: flying bat orientation
Reply #2 - Dec 14th, 2008, 11:34pm
 
have a solution to the problem,

http://www.julapy.com/blog/2008/12/13/bats/
Page Index Toggle Pages: 1