Category Archives: Phil

Phil 2.9.12

8:00 –  4:30 FP

  • Onward to the next chapter!
  • Texture maps – we get to make shiny things…
  • Adding a callback to the main window so that textures are released on closing.
  • Textures are working! Going to make things a bit fancier tomorrow.

Phil 2.7.12

8:30 – 5:00 FP

  • Working on how to chain matrices.
  • Old-school:
  • glRotatef(eyeOrient[0], 1, 0, 0);
    glRotatef(eyeOrient[2], 0, 1, 0);
    glTranslatef(eyePos[0], eyePos[1], eyePos[2]);
    
    // global world transformations
    glTranslatef(worldPos[0], worldPos[1], worldPos[2]);
    
    glRotatef(worldOrient[0], 1, 0, 0);
    glRotatef(worldOrient[1], 0, 1, 0);
  • And How it’s done now:
  • m3dLoadIdentity44(workingMatrix);
    m3dLoadIdentity44(worldMat);
    m3dLoadIdentity44(eyeMat);
    m3dLoadIdentity44(tmat);
    m3dLoadIdentity44(rmat1);
    m3dLoadIdentity44(rmat2);
    
    // handle eyepoint transformations
    m3dRotationMatrix44(rmat1, eyeOrient[0], 1, 0, 0);
    m3dRotationMatrix44(rmat2, eyeOrient[2], 0, 1, 0);
    m3dTranslationMatrix44(tmat, eyePos[0], eyePos[1], eyePos[2]);
    
    m3dMatrixMultiply44(eyeMat, rmat2, eyeMat);
    m3dMatrixMultiply44(eyeMat, rmat1, eyeMat);
    m3dMatrixMultiply44(eyeMat, tmat, eyeMat);
    
    // handle global world transformations
    m3dTranslationMatrix44(tmat, worldPos[0], worldPos[1], worldPos[2]);
    m3dRotationMatrix44(rmat1, worldOrient[0], 1, 0, 0);
    m3dRotationMatrix44(rmat2, worldOrient[1], 0, 1, 0);
    m3dMatrixMultiply44(worldMat, rmat1, rmat2);
    m3dMatrixMultiply44(worldMat, tmat, worldMat);
    
    // combine the eye and eorld xforms
    m3dMatrixMultiply44(workingMatrix, eyeMat, worldMat);
  • Isn’t that better?
  • Ok, cleaned things up a bit, and now I’ve got something I can live with:
  • // global eye transformations
    modelViewMatrix.Rotate(eyeOrient[0], 1, 0, 0);
    modelViewMatrix.Rotate(eyeOrient[2], 0, 1, 0);
    modelViewMatrix.Translate(eyePos[0], eyePos[1], eyePos[2]);
    
    // global world transformations
    modelViewMatrix.Translate(worldPos[0], worldPos[1], worldPos[2]);
    
    modelViewMatrix.Rotate(worldOrient[0], 1, 0, 0);
    modelViewMatrix.Rotate(worldOrient[1], 0, 1, 0);
  • Putting the stage and other bits in

Phil 2.6.12

8:30 – 5:30 FP

  • Hey, it’s my 2 month anniversary of my broken leg. On the whole, progress has been pretty good.
  • Working out how to put all the matrix pieces of a shader system together.
  • After flailing for pretty much most of the day, I discovered that I had set up the view frustum incorrectly, due to a typo. Most things work, but the viewframe isn’t reset ti identity each time through. I need to revisit how to set that up.
  • This was the hint that clued me in, BTW. Yuck.

Phil 2.1.12

8:30 – 4:30 FP

  • Starting the OpenGl SuperBible 5th Edition, which covers OpenGl 3.0+
  • Hmm. Can’t check out code from svn http://oglsuperbible5.googlecode.com/svn/trunk/
    • Here’s the useful SVN fix of the week: “SVN uses a few HTTP commands that not every web proxy and/or firewall understands, which can lead to errors. There is one thing that might fix this for you, and that is to use HTTPS instead of HTTP, because then the 
      connection is encrypted and any proxy/firewall in between can’t mess with the content. I checked, and the server provides HTTPS access, although that is not necessarily always the case. “
  • Ok, after some heroic struggling with getting libraries to behave and dealing with static declarations, I can now draw a simple triangle. I’m going to try to do the same in FLTK now, since I’d like to get away from static libraries…
    • Got a basic Shader Window framework compiled. Will test tomorrow.

Phil 1.31.12

8:30 – 4:00 FP

  • Good math library if I need it later: http://cmldev.net
  • Cleaning up the collision detection
  • And collisions work with multi-axis roatations. Cool.
  • Starting the OpenGL 4.0 Shading Language Cookbook.
    • Immediate mode has been deprecated! Going to get the GLEW (openGL Extension Wrangler) from sourceforge
    • Wow. No matrix mode either. Getting the GLM library
    • Code download is here: http://www.packtpub.com/code_download/7658
    • Hmm. I need to understand how the camera is setup in OGL 4.0.

Phil 1.30.12

8:30 – 5:30 FP

  • Adding environment methods that will coordinate the interactions of the objects.
  • Cleaning up Arvo’s so that only 3D collisions between solid objects are calculated, with a resulting unit penetration value.
  • Collision detection and response are now working!
  • Adding a few more cubes to collide with. Then work on global to local mapping so that I can have the cubes at arbitrary angles.
    • Added the cubes, now I need to clear and sum the collision forces each time through. Done.
    • After spending the entire afternoon unrotating objects in my head, I got the projections onto the object in it’s coordinate frame working. So bounding boxes work at any arbitrary angle. Whee!

Phil 1.27.12

8:00 – 10:30 FP

  • Working on collision detection. It just needs to be convex hull. At this point I’m thinking of doing the following:
    • For each polygon
    • calculate the shortest distance to the plane
    • If the square of the distance is less than the collision radius
      • See if the collision point is within the polygon (project the plane onto X, Y or Z, if it crosses an odd number of line segments, it’s outside – for convex polygons we can stop at one crossing)
      • If the distance from the “center” (average of all points) to the collision point on the plane is less than the distance from the “center” to the test point, then the collision is happening outside the hull, and the force can be calculated based on the difference between the collision radius and the surface. Otherwise, it’s within the hull, and the force is based on the collision radius + the distance from the polygon.
  • Well this is convenient – The Game Programming Wiki
  • Looks like we can use Arvo’s algorithm. Going to see how this works. Discovered Arvo here at Gamasutra.
  • Graphics Gems code repository
  • www.geometrictools.com: source code for real-time computer graphics and physics, mathematics, geometry, numerical analysis, and image analysis
  • http://www.realtimerendering.com/intersections.html

10:30 – 12:30 Interview

  • Went well. The work would be entirely on site. Ah well.

1:30 – 5:00 – FP

  • Got Arvo’s in. I can clean it up so that the collision test is only for solid shapes, which will allow me to get penetration values out of the collision. There was one tricky bit – I had to get the viewpoint matrix multiplies out of the collision calculations. So now there is a render() pass which draws, and a calculateCollisionPoints() that is called at some other time without any glBegin()/glEnd() blocks, and starting with an Identity matrix. I then pull the result of all the calculations off the matrix stack and save for the collision calculations. This does need to be cleaned up, but it’s not bad.
  • Collisions!

Phil 1.26.12

8:30 – 5:00 FP

  • Wire up the force sliders
    • Index finger is done
    • Thumb finger is done
    • Ring  finger is done
    • Middle finger is done
    • Pinky finger is done
  • Added text within the 3D environment, partially to show Dong how it’s done, but also because it could be quite useful. It’s in the DrawableObject base class.
  • Add collision detection
  • Add force output display (Small GL windows, drawing only 2D?, slider?)

Phil 1.25.12

8:30 – 5:30  FP

  • More on the HandControlUi and RightHand proper.
  • Added a clock to calculate elapsed time between frames for physically-based modeling.
  • Got the basics of the hand working, but I need to rework the eyepoint/model control. Adding a popup menu to select the mode.
  • This is a great source for FLTK coding examples (Erco’s FLTK Cheat Page)
  • Done with the popup menu
  • Adding the matrix analysis to get the position  of the fingertips. Done for one finger. Need to add methods to store and access all the position information. May need orientation. If so then I could subtract the position from the current matrix, then multiply a vector by the resulting matrix.

Phil 1.24.12

8:30 – 2:30

  • Well, I was hoping to use the MODELVIEW_Matrix to determine the orientation vector of the camera, but no luck. Time for classical spherical coordinate transforms. Transposing Y and Z, since OpenGl likes to have Y as the up vector.
    • phi = angle from vertical, theta = angle from x axis
    • z = cos(theta)*sin(phi)
    • x = -sin(theta)*sin(phi)
    • y = cos(theta)
    • And that is now working. Note that we had to multiply the x component of the view vector by -1.
  • Oooo – new shader book: http://www.packtpub.com/opengl-4-0-shading-language-cookbook/book
  • Started on the HandControlUi fltk class.

Phil 1.23.12

8:30 – 5:30 FP

  • Fixing up a few things with eyepoint control, then adding the hand
  • Got sidetracked about adding text overlay capability. Also, to truly make the eyepoint controls work, the eye vector needs to be transformed by the view matrix rotational component
  • Big lesson of the day – if you declare a static variable in the header file, you must reference it outside the methods in the .cpp file. But Dprint() is now working as an overlay!
  • Filled out paperwork for Clif’s project, looks like there is progress.

Phil 1.20.12

8:30 – 5:30 FP

  • Since I have to change my insanely long FGM password, I swing by the customer to check all my passwords. They won’t need changing for a while. Looks like FGM’s password schedule is now at a different frequency. More stuff to remember. I think it’s crowding out the calculus.
  • Working on the Fl_GL_Window extension (Gl_View_Window) that will handle the drawing of all the items in the universe. Got the callback working nicely.
    • Add mouse functions for world and camera control – mostly done.
  • Working out how to set up callbacks using Fluid. Remarkably, it seems to be making sense.

Phil 1.19.12

8:30 – 4:30 FP

  • Gave Dong my copy of the OpenGl Superbible so he can have a good grounding
  • Set up a window in Fluid that has all the pieces needed for display and testing
  • Figure out timers in C++ (FLTK?) and incorporate. Working, though I can’t get a callback to work inside of a class. I may need to go to FLTK 3.0? Downloading and testing. Nope, doesnt work.
  • The way you do callbacks with classes is to have the callback be static. You pass the “this” address of the class in so that you can work with the class that is active at the moment. This is covered in detail here: http://www.fltk.org/articles.php?L379+I0+TFAQ+P1+Q, which is from the generally useful http://www.fltk.org/articles.php?L+TFAQ