Welcome to CAP4730's TA page!
Homeworks
You can download the OpenGL Utility Toolkit (GLUT) here.
Run your program on Linux machines:
Homework#3
Hint for displaying triangle mesh:
You can convert the posted .ply file into obj format, then load it in and display as triangles.
Hint for displaying texture image:
OpenGl Texture Tutorial, Opengl FAQ, more in Chapter 9.
loadBMP sample code.
Hint for displaying coordinates on screen:
Hint for NURBS surface and lighting:
sample code, more in Chapter 12.
Homework#2
Hint for Picking:
See sample code.
Hint for Animation:
In order to identify the location of the tip, you can use glGetFloatv(GL_MODELVIEW_MATRIX, yourmatrix) to get the transformation applied to it.
Homework#1
Hint for 3a:
for 3a you need to create 6 curve pieces and 6 calls of glMap1f
(while for 3c you need only one call to gluNurbsCurve)
You can arrange that in a for-loop over segment index k from 0 to 5 where
{
1. I create first four local indices
i0 = k-1; if k-1 < 0 i0 = last = 5
i1 = k;
i2 = k+1; if...
i3 = k+2; if ...
2. compute the four coefficients of the BB form of the segment
c[0][xyz] = (secret formula you should determine)
c[1][xyz] = (2*ctlpt[i1][xyz] + 1*ctlpt[i2][xyz])/3;
c[2][xyz] = (1*ctlpt[i1][xyz] + 2*ctlpt[i2][xyz])/3;
c[3][xyz] = (secret formula you should determine)
3. call glMap1f(.........,&c[0][0])
glEnable
for (l=0; l < EVALPTS, l++) glEvalCoord...
}
Q: When the mouse clicked, how to decide which control point being picked?
A:
glutMouseFunc() will return the window coordinates of the point you clicked,
suppose it is (x,y)
World coordinates (x',y') need to be computed. The following is the formula:
x' = ((GLfloat)x/(GLfloat)width)*(right-left)+(GLfloat)left;
similarly for y' -- be careful that the origin of the mouse coordinates is in the upper left hand corner.
width : the width of the window.
left, right are set in
glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)