Category Archives: 3D Charting

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.

Dong Shin 02.03.2012

import org.newdawn.slick.TrueTypeFont;

private TrueTypeFont font;

private TrueTypeFont font2;

public void init() {

// load a default java font
Font awtFont = new Font(“Times New Roman”, Font.BOLD, 24);
font = new TrueTypeFont(awtFont, antiAlias);

// load font from file
try {
InputStream inputStream = ResourceLoader.getResourceAsStream(“AnnabelScript.ttf”);
Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont2 = awtFont2.deriveFont(24f); // set font size
font2 = new TrueTypeFont(awtFont2, antiAlias);
} catch (Exception e) {
font2 = new TrueTypeFont(awtFont, antiAlias);
e.printStackTrace();
}

matStage.init();
}

public void render() {

GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, width, height, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
Color.white.bind();

font.drawString(100, 50, “THE LIGHTWEIGHT JAVA GAMES LIBRARY”, Color.yellow);
font2.drawString(100, 100, “NICE LOOKING FONTS!”, Color.green);
GL11.glDisable(GL11.GL_BLEND);

}

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.