Category Archives: Phil

Phil 2.20.12

9:30 – 3:00 FP

  • Biting the bullet and installing R on fgmdev. Installed, and working on getting all the packages in.
  • Installed the folllowing
    • install.packages(“Rserve”)
    • apt-get install r-cran-car then library(car)
    • install.packages(“vcd”)
    • apt-get install r-cran-gplots then library(gplots)
    • install.packages(“pwr”)
  • had to re-run library(gplots) so that plotmeans was visible correctly
  • After installing all the packages, I bounced Rserve, and then remembered that I had to bounce tomcat. Which took a *while* to restart.
  • everything appears to be running correctly 🙂

Here’s the current list:

Packages in library '/usr/local/lib/R/site-library':

colorspace              Color Space Manipulation
mvtnorm                 Multivariate Normal and t Distributions
pwr                     Basic functions for power analysis
Rserve                  Binary R server
vcd                     Visualizing Categorical Data

Packages in library '/usr/lib/R/site-library':

car                     Companion to Applied Regression
gdata                   Various R programming tools for data
                        manipulation
gplots                  Various R programming tools for plotting data
gtools                  Various R programming tools
multcomp                Simultaneous Inference in General Parametric
                        Models
mvtnorm                 Multivariate Normal and t Distributions

Packages in library '/usr/lib/R/library':

base                    The R Base Package
boot                    Bootstrap R (S-Plus) Functions (Canty)
class                   Functions for Classification
cluster                 Cluster Analysis Extended Rousseeuw et al.
codetools               Code Analysis Tools for R
datasets                The R Datasets Package
foreign                 Read Data Stored by Minitab, S, SAS, SPSS,
                        Stata, Systat, dBase, ...
graphics                The R Graphics Package
grDevices               The R Graphics Devices and Support for Colours
                        and Fonts
grid                    The Grid Graphics Package
KernSmooth              Functions for kernel smoothing for Wand & Jones
                        (1995)
lattice                 Lattice Graphics
MASS                    Main Package of Venables and Ripley's MASS
methods                 Formal Methods and Classes
mgcv                    GAMs with GCV smoothness estimation and GAMMs
                        by REML/PQL
nlme                    Linear and Nonlinear Mixed Effects Models
nnet                    Feed-forward Neural Networks and Multinomial
                        Log-Linear Models
rpart                   Recursive Partitioning
spatial                 Functions for Kriging and Point Pattern
                        Analysis
splines                 Regression Spline Functions and Classes
stats                   The R Stats Package
stats4                  Statistical Functions using S4 Classes
survival                Survival analysis, including penalised
                        likelihood.
tcltk                   Tcl/Tk Interface
tools                   Tools for Package Development
utils                   The R Utils Package
  • Came upon an interesting thing: http://rapache.net/ it’s a pretty slick VISIBILITY-ish looking thing. Need to spend some time figuring out how it works. Not all that clear yet.
  • OK, back to shaders and such.
  • And I just got why rendering the entire scene to a framebuffer that you then process is important. It’s because you can post process the texture (i.e. the entire scene) to get blur, bloom, and other effects. Cool. Well, I know what I’m doing tomorrow.

Phil 2.17.12

8:30 – FP

  • Started off the day with sprites. Here’s a starfield:
  • The neat thing about this is that the stars are handled as sprites, which means that it’s possible to handle text overlay with a shader now. I think that the way it could be done would be to create a single grid with all the characters and pass that to the vertex shader with the XY index and size of the letter. The vertex shader moves the texture so that the letter is centered and then passes off the texture and size to the fragment shader, which clips the output so only the particular letter is shown. Not going to do that yet, but it’s probably the first tool after I finish the book.
  • Worked my way through the pixBuffer/motion blur section, but I don’t think it’s worth incorporating into the framework.

Phil 2.16.12

8:30 – 4:30 FP

    • Reflection cube maps today
    • And they are working! The trick to handling rotating reflections is the following (note that the camera matrix is determined before the model roation, and the surface normal is calculated after the rotation.):
	M3DMatrix44f mCameraRotOnly;
	M3DMatrix44f mInverseCamera;
	M3DMatrix33f mNormalMat;

	const M3DMatrix44f &mCamera = modelViewStack.GetMatrix();

	modelViewStack.PushMatrix();
		modelViewStack.Rotate(angle, 0.0f, 1.0f, 0.0f);

		orient44fromMat44(mCameraRotOnly, mCamera);
		orient33fromMat44(mNormalMat, modelViewStack.GetMatrix());
		m3dInvertMatrix44(mInverseCamera, mCameraRotOnly);

		projectionStack.PushMatrix();
			projectionStack.MultMatrix(modelViewStack.GetMatrix());
			glUseProgram(reflectionShader);
			glUniformMatrix4fv(locMVPReflect, 1, GL_FALSE, projectionStack.GetMatrix());
			glUniformMatrix4fv(locMVReflect, 1, GL_FALSE, modelViewStack.GetMatrix());
			glUniformMatrix3fv(locNormalReflect, 1, GL_FALSE, mNormalMat);
			glUniformMatrix4fv(locInvertedCamera, 1, GL_FALSE, mInverseCamera);
			triangleBatch.Draw();
			glUseProgram(NULL);
		projectionStack.PopMatrix();
	modelViewStack.PopMatrix();
  • It seems to be a nice day for pretty pictures. Here’s an example of multitexturing:
  • And now that our connection is better, maybe I’ll install R on fgmdev

Phil 2.15.12

8:30 – 4:30 FP

  • Making good, albiet slow progress on shaders. It’s kind of like programming in pre IDE-days; edit in vim then submit to the GPU compiler for a cryptic message. On the list of things to do is a framework that allows for the more sophisticated editing of shaders in the context of a running program. Will probably do this is Java for eclipse. Looks like there’s a starting point here: http://glshaders.sourceforge.net/
  • Nice progress so far. Let’s see if this video uploads…
  • solarSystem
  • Useful post on how to make a skybox with photoshop: http://www.interlopers.net/forum/viewtopic.php?f=44&t=31549
  • Going to set up a new project – ShaderLearning2
    • Use frame this time in Gl_ShaderWindow. Nope, I need Euler Angles for this.
  • Need to install R on the new server.

Phil 2.10.12

8:00 – 6:00 FP

  • Cleaning up the texture allocation scheme by going to a singleton class like Dprint. Nope, after looking into it, the glGenTextures is guaranteed to return unique handles to textures each time it’s called.
  • Pretty picture:
  • Oh, boy, I get to redo my security form! I guess that’s what I’m spending the rest of the day on.
  • But then the Internet broke, and I had my graphics book cached locally. Can’t work on forms. Darn.

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?)