Greetings,
This piece of code will draw a red QUAD. The code is
supposed to change the color of the lower left vertex
to yellow, but It doesn't seems to work cause of my
lack of knowledge.
I have put some question inside the code, thank you
very much.
import javax.media.j3d.*;
import javax.vecmath.*;
public class MyShape extends Shape3D implements
GeometryUpdater
{
int N;
float[] verts;
QuadArray quad;
public MyShape()
{
N = 4;
createGeometry();
}
private void createGeometry()
{
quad = new QuadArray( 4, QuadArray.COORDINATES
| QuadArray.COLOR_3
|
QuadArray.BY_REFERENCE
|
QuadArray.INTERLEAVED );
verts = new float[N*6];
// Set a QUAD facing to viewer
verts[0] = 1.0f; verts[1] = 0.0f; verts[2] = 0.0f;
verts[3] = -0.5f; verts[4] = -0.5f; verts[5] =
-0.0f;
verts[6] = 1.0f; verts[7] = 0.0f; verts[8] = 0.0f;
verts[9] = 0.5f; verts[10] = -0.5f; verts[11] =
-0.0f;
verts[12] = 1.0f; verts[13] = 0.0f; verts[14] =
0.0f;
verts[15] = 0.5f; verts[16] = 0.5f; verts[17] =
-0.0f;
verts[18] = 1.0f; verts[19] = 0.0f; verts[20] =
0.0f;
verts[21] = -0.5f; verts[22] = 0.5f; verts[23] =
-0.0f;
quad.setInterleavedVertices( verts );
// is this where I set ALLOW_REF_DATA_WRITE?
quad.setCapability(
GeometryArray.ALLOW_REF_DATA_WRITE );
// Call just once?
quad.updateData( this );
setGeometry( quad );
}
//
// Implement updateData for Interface GeometryUpdater
// How to do this? ... I have no idea, any example
would be great?
//
public void updateData( Geometry geometry )
{
QuadArray q = (QuadArray)geometry;
verts[1] += 0.01f;
if(verts[1] > 1.0f) verts[1] = 0.0f;
q.setInterleavedVertices( verts );
setGeometry( q );
}
}
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".