riekhof

Member
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

122 Neutral

About riekhof

  • Rank
    Newbie
  1. Animation Pseudocode for Milkshape bones?

    I'm o so close, I just need a little more hand holding on the matrix math. I've computed the rotation matrix for all the joints. When I just rotate the root, I can make it work. However, if I try to rotate another joint at the same time, bad things happen. oconnelseanm gave me the following algorithm: for each vertex 1) determine its owner joint. (I'm clear on this step) 2) transform the vertex by the correct joint's matrix. I assume that means multiply the vertex vector by the owner joints rotation matrix. I'm a bit confused on how keyframes would affect this operation. If I'm not on the intial keyframe, do I need to do some additional matrix operations to get it into position? 3)transfrom the vertex by the joint's parent matrix. Again, I assume this means multiply by all the ancestor joint rotation matrices. Do I pre or post multiply? And how would not being on initial keyframe affect this? Tx for any help on this.
  2. Newbie Matrix question

    I found the answer to my last question: gl.glMultMatrixf( rm ). Also had my rotation matrix crisscrossed. Now I'm trying to do linear interpolation. Since I need both points for the vertex to do the interpolation, I guess I have to compute the start and end points for each vertex myself anyway...
  3. Newbie Matrix question

    I have built a rotation matrix. When I multiply each vertex by hand and then do my gl.glVertex3f() calls, then it works for a simple test case. Do I have to do all this work by hand or is there some way to give OpenGL my rotation matrix and tell it to multiply each vertex vector by the rotation matrix? I've tried playing around with the gl.glLoadMatrixf( myRotMatrix ) calls but I can't seem to get it to work. Code below illustrates what im doing. <code> // rotate triangle float[] rm = mm.joints[0].rotMatrix; float v11 = (rm[0] * v1[0]) + (rm[4] * v1[1]) + (rm[8] * v1[2] ) + rm[12]; float v12 = (rm[1] * v1[0]) + (rm[5] * v1[1]) + (rm[9] * v1[2] ) + rm[13]; float v13 = (rm[2] * v1[0]) + (rm[6] * v1[1]) + (rm[10] * v1[2] ) + rm[14]; float v21 = (rm[0] * v2[0]) + (rm[4] * v2[1]) + (rm[8] * v2[2] ) + rm[12]; float v22 = (rm[1] * v2[0]) + (rm[5] * v2[1]) + (rm[9] * v2[2] ) + rm[13]; float v23 = (rm[2] * v2[0]) + (rm[6] * v2[1]) + (rm[10] * v2[2] ) + rm[14]; float v31 = (rm[0] * v3[0]) + (rm[4] * v3[1]) + (rm[8] * v3[2] ) + rm[12]; float v32 = (rm[1] * v3[0]) + (rm[5] * v3[1]) + (rm[9] * v3[2] ) + rm[13]; float v33 = (rm[2] * v3[0]) + (rm[6] * v3[1]) + (rm[10] * v3[2] ) + rm[14]; // now do my gl.glVertex3f() calls. </code>
  4. Animation Pseudocode for Milkshape bones?

    oconnelseanm, Thanks for help, that will get me started. I'm not clear on what you meant by by Milkshape ascii loader having code for animation. Can you give me more details on that. These are the best things on the net I've found so far on the topic. http://rsn.gamedev.net/tutorials/ms3danim.asp The pig and bert examples: http://www.john.findlay1.btinternet.co.uk/opengl/opengl.htm Darrel
  5. Below is a really simple milkshape model: 2 joints, 2 triangles, and a 16 frame animation. I thought it would be a good place to start in trying to get an animation to render. I've loaded all the info from a Milkshape ascii export file into my JOGL program. I've also rendered all the vertices, triangles, and materials in my OpenGL world. Now I'd like to render a simple Milkshape bone animation. But I'm lost... What are the steps (matrix and other operations) to get from the bone info at at the bottom of the milkshape export to an animated scene in my OpenGL window? I have the spec for the export file, so I understand all the data, I just don't understand how to use it. Darrel How do u get src to show up in scroll boxes? -------------------------------- // MilkShape 3D ASCII Frames: 16 Frame: 1 Meshes: 1 "Triangles" 0 -1 6 0 0.000000 0.000000 -1.000000 0.000000 0.000000 0 0 -1.000000 0.000000 1.000000 0.000000 0.000000 0 0 1.000000 0.000000 1.000000 0.000000 0.000000 0 0 -5.034483 0.000000 1.000000 0.000000 0.000000 1 0 -3.000000 0.000000 1.000000 0.000000 0.000000 1 0 -4.000000 0.000000 -1.000000 0.000000 0.000000 1 1 0.000000 1.000000 0.000000 2 0 0 1 2 0 0 0 1 0 3 4 5 0 0 0 1 Materials: 0 Bones: 2 "joint1" "" 21 2.022987 0.000000 -0.007663 3.141590 1.568910 0.000000 3 1.000000 0.000000 0.000000 -0.000000 9.000000 0.000000 -0.000000 -0.000000 16.000000 0.000000 -0.000000 -0.000000 3 1.000000 0.000000 0.000000 0.000000 9.000000 -0.000003 1.570794 0.000000 16.000000 0.000000 0.000000 0.000000 "joint2" "joint1" 20 0.000000 0.000000 4.057477 0.000000 0.000000 0.000000 3 1.000000 0.000000 0.000000 0.000000 9.000000 0.000000 -0.000000 0.000082 16.000000 0.000000 -0.000000 0.000082 3 1.000000 0.000000 0.000000 0.000000 9.000000 -0.000003 -1.570777 0.000000 16.000000 -0.000000 -0.000020 -0.000000 GroupComments: 0 MaterialComments: 0 BoneComments: 0 ModelComment: 0
  6. Extending lesson 10

    tx for the info lc_overlord. The best thing I was able to google on this is: http://www.morrowland.com/apron/article/gl/boundingbox/index.php So I guess I'll try to come up with some clever data structure that keeps bounding box information on things kind of close to me. Darrel
  7. Extending lesson 10

    Wanted: Hint on how to make lesson 10 stop running thru walls. I've been hacking on lesson 10 for a while now. I'm a newb, but I've managed to add strafing and get it to use different textures for the floor, walls, and ceiling. My next goal is to make it so you can't run through walls, but not sure how to go about this. I looked at lesson 30, but its over my head and doesn't really look like it deals with camera to object collisions. Are there any lessons or tutorials around that would help me on this? Also, at the end of the article the author said he'd be posting another tutorial on this. Is that next tutorial available anywhere?
  8. Lesson 6 newbie question

    Thank you tool_2046! It runs now using no CPU, and I almost feel like I understand texture fundamentals.
  9. Lesson 6 newbie question

    Hello I went thru lesson 6, and after recovering from a texture induced headache, I proceeded to do as suggested and make the cube have six different textures on my own (using JOGL). I settled on just 3 textures, each texture would be on two sides. To my suprise, I was able to do this fairly quickly, but I noticed the CPU usage skyrocketed from practically nothing with one texture to sucking up over 50% with 3. I had moved a lot of the texture specific code out of the init() method and into the display method, and I assumed that was the reason. I tried moving code back into init(), as much as I thought I could get away with. However, its still sucking up over 50% cpu. The only texture method calls I left in display() are the ones to gl.glTexParameteri() and gl.glTexImage2D() Am I doing something stupid to hurt the performance? My display method is below. tx, Darrel ============================ public void display(GLDrawable gLDrawable) { final GL gl = gLDrawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); // Reset The View gl.glTranslatef(0.0f,0.0f,-5.0f); gl.glRotatef(xrot,1.0f,0.0f,0.0f); gl.glRotatef(yrot,0.0f,1.0f,0.0f); gl.glRotatef(zrot,0.0f,0.0f,1.0f); gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR); // select texture gl.glTexImage2D( GL.GL_TEXTURE_2D, 0, GL.GL_RGB, textureBeans[0].getWidth(), textureBeans[0].getHeight(), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, textureBeans[0].getByteBuffer() ); gl.glBegin(GL.GL_QUADS); // Front Face gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); gl.glEnd(); // select texture gl.glTexImage2D( GL.GL_TEXTURE_2D, 0, GL.GL_RGB, textureBeans[1].getWidth(), textureBeans[1].getHeight(), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, textureBeans[1].getByteBuffer() ); // gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR); // gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR); gl.glBegin(GL.GL_QUADS); // Top Face gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); // Bottom Face gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glEnd(); // select texture gl.glTexImage2D( GL.GL_TEXTURE_2D, 0, GL.GL_RGB, textureBeans[2].getWidth(), textureBeans[2].getHeight(), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, textureBeans[2].getByteBuffer() ); // gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR); // gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR); gl.glBegin(GL.GL_QUADS); // Right face gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); // Left Face gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); gl.glEnd(); xrot+=0.3f; yrot+=0.2f; zrot+=0.4f; }