git.ucc.asn.au
/
atyndall
/
cits2231.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[atyndall/cits2231.git]
/
scene.c
diff --git
a/scene.c
b/scene.c
index
d9a4ea3
..
d22aa94
100644
(file)
--- a/
scene.c
+++ b/
scene.c
@@
-221,31
+221,50
@@
void mouse(int button, int state, int x, int y) {
void keyboard(unsigned char key, int x, int y) {
\r
switch(key) {
\r
case 'w':
\r
void keyboard(unsigned char key, int x, int y) {
\r
switch(key) {
\r
case 'w':
\r
- camz = camz - 1;
\r
+ case 'W':
\r
+ camz -= factor;
\r
break;
\r
case 'a':
\r
break;
\r
case 'a':
\r
- camx = camx - 1;
\r
+ case 'A':
\r
+ camx -= factor;
\r
break;
\r
case 's':
\r
break;
\r
case 's':
\r
- camz = camz + 1;
\r
+ case 'S':
\r
+ camz += factor;
\r
break;
\r
case 'd':
\r
break;
\r
case 'd':
\r
- camx = camx + 1;
\r
+ case 'D':
\r
+ camx += factor;
\r
break;
\r
case 'q':
\r
break;
\r
case 'q':
\r
- camy = camy + 1;
\r
+ case 'Q':
\r
+ camy += factor;
\r
break;
\r
case 'e':
\r
break;
\r
case 'e':
\r
- camy = camy - 1;
\r
+ case 'E':
\r
+ camy -= factor;
\r
break;
\r
case 'z':
\r
break;
\r
case 'z':
\r
- rot = rot + 1;
\r
+ case 'Z':
\r
+ keyrot += factor;
\r
break;
\r
case 'x':
\r
break;
\r
case 'x':
\r
- rot = rot - 1;
\r
+ case 'X':
\r
+ keyrot -= factor;
\r
break;
\r
break;
\r
+ case '=':
\r
+ case '+':
\r
+ factor += 0.1;
\r
+ printf("Factor of change is now %f\n", factor);
\r
+ break;
\r
+ case '-':
\r
+ case '_':
\r
+ factor -= 0.1;
\r
+ printf("Factor of change is now %f\n", factor);
\r
+ break;
\r
+
\r
}
\r
}
\r
- printf("Camera is now at (%f, %f, %f), angle %f\n", camx, camy, camz, rot);
\r
+ printf("Camera is now at (%f, %f, %f), angle %f\n", camx, camy, camz,
key
rot);
\r
glutPostRedisplay();
\r
}
\r
\r
glutPostRedisplay();
\r
}
\r
\r
@@
-256,8
+275,8
@@
void keyboard(unsigned char key, int x, int y) {
*/
\r
void motion(int x, int y) {
\r
if (moving) {
\r
*/
\r
void motion(int x, int y) {
\r
if (moving) {
\r
- zoom
Factor
+= (y - starty);
\r
- rotate
Factor
+= (x - startx);
\r
+ zoom += (y - starty);
\r
+ rotate += (x - startx);
\r
startx = x;
\r
starty = y;
\r
glutPostRedisplay();
\r
startx = x;
\r
starty = y;
\r
glutPostRedisplay();
\r
@@
-299,12
+318,12
@@
void display() {
glLoadIdentity();
\r
\r
gluLookAt(
\r
glLoadIdentity();
\r
\r
gluLookAt(
\r
-
0.0, 0.0, 5.0 + (zoomFactor*0.2
), /* eye is at (x,y,z) */
\r
+
10.0, 0.0, 15.0 + (zoom*zoomFactor
), /* eye is at (x,y,z) */
\r
0.0, 0.0, 0.0, /* center is at (x,y,z) */
\r
0.0, 1.0, 0.0 /* up is in postivie Y direction */
\r
);
\r
\r
0.0, 0.0, 0.0, /* center is at (x,y,z) */
\r
0.0, 1.0, 0.0 /* up is in postivie Y direction */
\r
);
\r
\r
- glRotatef(
75
.0, 1.0, 0.0, 0.0);
\r
+ glRotatef(
50
.0, 1.0, 0.0, 0.0);
\r
\r
/* Reposition the light source. */
\r
lightPosition[0] = 12*cos(lightAngle);
\r
\r
/* Reposition the light source. */
\r
lightPosition[0] = 12*cos(lightAngle);
\r
@@
-312,16
+331,12
@@
void display() {
lightPosition[2] = 12*sin(lightAngle);
\r
lightPosition[3] = 0.0;
\r
\r
lightPosition[2] = 12*sin(lightAngle);
\r
lightPosition[3] = 0.0;
\r
\r
-
\r
- //glRotatef(angle, 0.0, 1.0, 0.0);
\r
- // glRotatef(angle2, 1.0, 0.0, 0.0);
\r
-
\r
glPushMatrix();
\r
\r
/* Perform scene rotations based on user mouse/keyboard input. */
\r
glPushMatrix();
\r
\r
/* Perform scene rotations based on user mouse/keyboard input. */
\r
- glRotatef(rotate
Factor*0.5
, 0.0, 1.0, 0.0);
\r
-
//
glTranslatef(camx, camy, camz);
\r
-
//glRotatef(
rot, 1.0, 0.0, 0.0);
\r
+ glRotatef(rotate
*rotateFactor
, 0.0, 1.0, 0.0);
\r
+ glTranslatef(camx, camy, camz);
\r
+
glRotatef(key
rot, 1.0, 0.0, 0.0);
\r
\r
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
\r
\r
\r
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
\r
\r
@@
-356,7
+371,6
@@
void display() {
* init function; sets initial OpenGL state
\r
*/
\r
void init() {
\r
* init function; sets initial OpenGL state
\r
*/
\r
void init() {
\r
- glLightfv(GL_LIGHT0, GL_POSITION, light0_pos);
\r
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);
\r
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);
\r
glLightfv(GL_LIGHT0, GL_SPECULAR, specular0);
\r
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);
\r
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);
\r
glLightfv(GL_LIGHT0, GL_SPECULAR, specular0);
\r
UCC
git Repository :: git.ucc.asn.au