better animate rate (Marcelo Magallon)
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#define COS(X) cos( (X) * 3.14159/180.0 )
|
#define COS(X) cos( (X) * 3.14159/180.0 )
|
||||||
#define SIN(X) sin( (X) * 3.14159/180.0 )
|
#define SIN(X) sin( (X) * 3.14159/180.0 )
|
||||||
@@ -25,12 +27,12 @@
|
|||||||
GLboolean IndexMode = GL_FALSE;
|
GLboolean IndexMode = GL_FALSE;
|
||||||
GLuint Ball;
|
GLuint Ball;
|
||||||
GLenum Mode;
|
GLenum Mode;
|
||||||
GLfloat Zrot = 0.0, Zstep = 6.0;
|
GLfloat Zrot = 0.0, Zstep = 180.0;
|
||||||
GLfloat Xpos = 0.0, Ypos = 1.0;
|
GLfloat Xpos = 0.0, Ypos = 1.0;
|
||||||
GLfloat Xvel = 0.2, Yvel = 0.0;
|
GLfloat Xvel = 2.0, Yvel = 0.0;
|
||||||
GLfloat Xmin = -4.0, Xmax = 4.0;
|
GLfloat Xmin = -4.0, Xmax = 4.0;
|
||||||
GLfloat Ymin = -3.8, Ymax = 4.0;
|
GLfloat Ymin = -3.8, Ymax = 4.0;
|
||||||
GLfloat G = -0.1;
|
GLfloat G = -9.8;
|
||||||
|
|
||||||
static GLuint
|
static GLuint
|
||||||
make_ball(void)
|
make_ball(void)
|
||||||
@@ -149,10 +151,17 @@ static void
|
|||||||
idle(void)
|
idle(void)
|
||||||
{
|
{
|
||||||
static float vel0 = -100.0;
|
static float vel0 = -100.0;
|
||||||
|
static double t0 = -1.;
|
||||||
|
double t, dt;
|
||||||
|
t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
|
||||||
|
if (t0 < 0.)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
Zrot += Zstep;
|
Zrot += Zstep*dt;
|
||||||
|
|
||||||
Xpos += Xvel;
|
Xpos += Xvel*dt;
|
||||||
if (Xpos >= Xmax) {
|
if (Xpos >= Xmax) {
|
||||||
Xpos = Xmax;
|
Xpos = Xmax;
|
||||||
Xvel = -Xvel;
|
Xvel = -Xvel;
|
||||||
@@ -163,8 +172,8 @@ idle(void)
|
|||||||
Xvel = -Xvel;
|
Xvel = -Xvel;
|
||||||
Zstep = -Zstep;
|
Zstep = -Zstep;
|
||||||
}
|
}
|
||||||
Ypos += Yvel;
|
Ypos += Yvel*dt;
|
||||||
Yvel += G;
|
Yvel += G*dt;
|
||||||
if (Ypos < Ymin) {
|
if (Ypos < Ymin) {
|
||||||
Ypos = Ymin;
|
Ypos = Ymin;
|
||||||
if (vel0 == -100.0)
|
if (vel0 == -100.0)
|
||||||
|
@@ -912,14 +912,18 @@ draw (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
idle (void)
|
idle (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
for (i = 0; i < number_of_gears; i++)
|
for (i = 0; i < number_of_gears; i++)
|
||||||
g[i].angle += g[i].angular_velocity;
|
g[i].angle += g[i].angular_velocity * dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ APOSITION = -7.000 0.000 0.000
|
|||||||
ACOLOR = 0.800 0.500 0.200
|
ACOLOR = 0.800 0.500 0.200
|
||||||
ALENGTH = 6.000
|
ALENGTH = 6.000
|
||||||
AMOTORED = 1
|
AMOTORED = 1
|
||||||
AANGULARVELOCITY = 2.000
|
AANGULARVELOCITY = 90.000
|
||||||
ADIRECTION = 1
|
ADIRECTION = 1
|
||||||
|
|
||||||
ANAME = AXLE2
|
ANAME = AXLE2
|
||||||
|
@@ -21,9 +21,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
#include "readtex.c" /* I know, this is a hack. */
|
#include "readtex.h"
|
||||||
|
|
||||||
#define SPECULAR_TEXTURE_FILE "../images/reflect.rgb"
|
#define SPECULAR_TEXTURE_FILE "../images/reflect.rgb"
|
||||||
#define BASE_TEXTURE_FILE "../images/tile.rgb"
|
#define BASE_TEXTURE_FILE "../images/tile.rgb"
|
||||||
@@ -43,7 +44,7 @@ static GLuint Object = 0;
|
|||||||
static GLboolean Animate = GL_TRUE;
|
static GLboolean Animate = GL_TRUE;
|
||||||
|
|
||||||
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
|
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
|
||||||
static GLfloat DXrot = 1.0, DYrot = 2.5;
|
static GLfloat DXrot = 20.0, DYrot = 50.;
|
||||||
|
|
||||||
static GLfloat Black[4] = { 0, 0, 0, 0 };
|
static GLfloat Black[4] = { 0, 0, 0, 0 };
|
||||||
static GLfloat White[4] = { 1, 1, 1, 1 };
|
static GLfloat White[4] = { 1, 1, 1, 1 };
|
||||||
@@ -58,13 +59,18 @@ static GLint T0 = 0;
|
|||||||
static GLint Frames = 0;
|
static GLint Frames = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void Idle( void )
|
static void Idle( void )
|
||||||
{
|
{
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
if (Animate) {
|
if (Animate) {
|
||||||
Xrot += DXrot;
|
Xrot += DXrot*dt;
|
||||||
Yrot += DYrot;
|
Yrot += DYrot*dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined (WIN32)|| defined(_WIN32)
|
#if defined (WIN32)|| defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
#include "readtex.c"
|
#include "readtex.h"
|
||||||
|
|
||||||
#ifdef XMESA
|
#ifdef XMESA
|
||||||
#include "GL/xmesa.h"
|
#include "GL/xmesa.h"
|
||||||
@@ -543,6 +543,12 @@ draw(void)
|
|||||||
static GLfloat alpha = 0.0f;
|
static GLfloat alpha = 0.0f;
|
||||||
static GLfloat beta = 0.0f;
|
static GLfloat beta = 0.0f;
|
||||||
static float fr = 0.0;
|
static float fr = 0.0;
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
dojoy();
|
dojoy();
|
||||||
|
|
||||||
@@ -586,8 +592,8 @@ draw(void)
|
|||||||
drawipers(0, FROM_NONE);
|
drawipers(0, FROM_NONE);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
alpha += 0.5f;
|
alpha += 4.f * dt;
|
||||||
beta += 0.3f;
|
beta += 2.4f * dt;
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glDisable(GL_LIGHT0);
|
glDisable(GL_LIGHT0);
|
||||||
|
@@ -660,6 +660,13 @@ static void draw_ico( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void draw ( void ) {
|
static void draw ( void ) {
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@@ -681,7 +688,7 @@ static void draw ( void ) {
|
|||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
|
||||||
step+=0.05;
|
step += dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void idle_( void )
|
static void idle_( void )
|
||||||
|
@@ -79,7 +79,6 @@ static float float_rand(void) { return rand() / (float) RAND_MAX; }
|
|||||||
|
|
||||||
#define MEAN_VELOCITY 3.0
|
#define MEAN_VELOCITY 3.0
|
||||||
#define GRAVITY 2.0
|
#define GRAVITY 2.0
|
||||||
#define TIME_DELTA 0.025 /* The speed of time. */
|
|
||||||
|
|
||||||
/* Modeling units of ground extent in each X and Z direction. */
|
/* Modeling units of ground extent in each X and Z direction. */
|
||||||
#define EDGE 12
|
#define EDGE 12
|
||||||
@@ -114,6 +113,13 @@ updatePointList(void)
|
|||||||
float distance;
|
float distance;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
motion = 0;
|
motion = 0;
|
||||||
for (i=0; i<numPoints; i++) {
|
for (i=0; i<numPoints; i++) {
|
||||||
distance = pointVelocity[i][0] * theTime;
|
distance = pointVelocity[i][0] * theTime;
|
||||||
@@ -139,9 +145,9 @@ updatePointList(void)
|
|||||||
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
|
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
|
||||||
}
|
}
|
||||||
motion = 1;
|
motion = 1;
|
||||||
pointTime[i] += TIME_DELTA;
|
pointTime[i] += dt;
|
||||||
}
|
}
|
||||||
theTime += TIME_DELTA;
|
theTime += dt;
|
||||||
if (!motion && !spin) {
|
if (!motion && !spin) {
|
||||||
if (repeat) {
|
if (repeat) {
|
||||||
makePointList();
|
makePointList();
|
||||||
@@ -264,7 +270,7 @@ menu(int option)
|
|||||||
case 0:
|
case 0:
|
||||||
makePointList();
|
makePointList();
|
||||||
break;
|
break;
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
case 1:
|
case 1:
|
||||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
|
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
|
||||||
break;
|
break;
|
||||||
@@ -281,7 +287,7 @@ menu(int option)
|
|||||||
case 5:
|
case 5:
|
||||||
blend = 0;
|
blend = 0;
|
||||||
break;
|
break;
|
||||||
#if GL_ARB_point_parameters
|
#ifdef GL_ARB_point_parameters
|
||||||
case 6:
|
case 6:
|
||||||
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
|
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
|
||||||
break;
|
break;
|
||||||
|
@@ -31,8 +31,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "GL/glut.h"
|
#include "GL/glut.h"
|
||||||
#include "../util/showbuffer.c"
|
#include "showbuffer.h"
|
||||||
#include "../util/readtex.c"
|
#include "readtex.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEG2RAD (3.14159/180.0)
|
#define DEG2RAD (3.14159/180.0)
|
||||||
@@ -318,8 +318,14 @@ static void draw_scene( void )
|
|||||||
|
|
||||||
static void idle( void )
|
static void idle( void )
|
||||||
{
|
{
|
||||||
spin += 2.0;
|
static double t0 = -1.;
|
||||||
yrot += 3.0;
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
spin += 60.0 * dt;
|
||||||
|
yrot += 90.0 * dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,9 +13,15 @@
|
|||||||
static GLfloat Phi = 0.0;
|
static GLfloat Phi = 0.0;
|
||||||
|
|
||||||
|
|
||||||
static void Idle(void)
|
static void Idle( void )
|
||||||
{
|
{
|
||||||
Phi += 0.1;
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
Phi += 3.0 * dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "../util/showbuffer.c"
|
#include "showbuffer.h"
|
||||||
|
|
||||||
#if 0 /* change to 1 if you want to use the old SGIX extensions */
|
#if 0 /* change to 1 if you want to use the old SGIX extensions */
|
||||||
#undef GL_ARB_depth_texture
|
#undef GL_ARB_depth_texture
|
||||||
@@ -386,7 +386,13 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
Idle(void)
|
Idle(void)
|
||||||
{
|
{
|
||||||
Yrot += 5.0;
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
Yrot += 75.0 * dt;
|
||||||
/*LightLongitude -= 5.0;*/
|
/*LightLongitude -= 5.0;*/
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@
|
|||||||
static GLUquadricObj *Quadric;
|
static GLUquadricObj *Quadric;
|
||||||
static GLuint Sphere;
|
static GLuint Sphere;
|
||||||
static GLfloat LightPos[4] = {10.0, 10.0, 10.0, 1.0};
|
static GLfloat LightPos[4] = {10.0, 10.0, 10.0, 1.0};
|
||||||
static GLfloat Delta = 1.0;
|
static GLfloat Delta = 20.0;
|
||||||
static GLint Mode = 0;
|
static GLint Mode = 4;
|
||||||
|
|
||||||
/*static GLfloat Blue[4] = {0.0, 0.0, 1.0, 1.0};*/
|
/*static GLfloat Blue[4] = {0.0, 0.0, 1.0, 1.0};*/
|
||||||
/*static GLfloat Gray[4] = {0.5, 0.5, 0.5, 1.0};*/
|
/*static GLfloat Gray[4] = {0.5, 0.5, 0.5, 1.0};*/
|
||||||
@@ -34,14 +34,18 @@ static GLfloat Black[4] = {0.0, 0.0, 0.0, 1.0};
|
|||||||
static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0};
|
static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
static void Idle( void )
|
Idle(void)
|
||||||
{
|
{
|
||||||
LightPos[0] += Delta;
|
static double t0 = -1.;
|
||||||
if (LightPos[0]>15.0)
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;;
|
||||||
Delta = -1.0;
|
if (t0 < 0.0)
|
||||||
else if (LightPos[0]<-15.0)
|
t0 = t;
|
||||||
Delta = 1.0;
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
LightPos[0] += Delta * dt;
|
||||||
|
if (LightPos[0]>15.0 || LightPos[0]<-15.0)
|
||||||
|
Delta = -Delta;
|
||||||
|
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
@@ -104,7 +104,6 @@ static float float_rand(void) { return rand() / (float) RAND_MAX; }
|
|||||||
|
|
||||||
#define MEAN_VELOCITY 3.0
|
#define MEAN_VELOCITY 3.0
|
||||||
#define GRAVITY 2.0
|
#define GRAVITY 2.0
|
||||||
#define TIME_DELTA 0.025 /* The speed of time. */
|
|
||||||
|
|
||||||
/* Modeling units of ground extent in each X and Z direction. */
|
/* Modeling units of ground extent in each X and Z direction. */
|
||||||
#define EDGE 12
|
#define EDGE 12
|
||||||
@@ -139,6 +138,13 @@ updatePointList(void)
|
|||||||
float distance;
|
float distance;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
motion = 0;
|
motion = 0;
|
||||||
for (i=0; i<numPoints; i++) {
|
for (i=0; i<numPoints; i++) {
|
||||||
distance = pointVelocity[i][0] * theTime;
|
distance = pointVelocity[i][0] * theTime;
|
||||||
@@ -164,9 +170,9 @@ updatePointList(void)
|
|||||||
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
|
pointTime[i] = 0.0; /* Reset the particles sense of up time. */
|
||||||
}
|
}
|
||||||
motion = 1;
|
motion = 1;
|
||||||
pointTime[i] += TIME_DELTA;
|
pointTime[i] += dt;
|
||||||
}
|
}
|
||||||
theTime += TIME_DELTA;
|
theTime += dt;
|
||||||
if (!motion && !spin) {
|
if (!motion && !spin) {
|
||||||
if (repeat) {
|
if (repeat) {
|
||||||
makePointList();
|
makePointList();
|
||||||
|
@@ -69,7 +69,7 @@ static int scrheight = HEIGHT;
|
|||||||
|
|
||||||
static float obs[3] = { OBSSTARTX, heightMnt * 1.3, OBSSTARTY };
|
static float obs[3] = { OBSSTARTX, heightMnt * 1.3, OBSSTARTY };
|
||||||
static float dir[3], v1[2], v2[2];
|
static float dir[3], v1[2], v2[2];
|
||||||
static float v = 15.0;
|
static float v = 900.0;
|
||||||
static float alpha = 75.0;
|
static float alpha = 75.0;
|
||||||
static float beta = 90.0;
|
static float beta = 90.0;
|
||||||
|
|
||||||
@@ -77,6 +77,12 @@ static void
|
|||||||
calcposobs(void)
|
calcposobs(void)
|
||||||
{
|
{
|
||||||
float alpha1, alpha2;
|
float alpha1, alpha2;
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
dir[0] = sin(alpha * M_PI / 180.0);
|
dir[0] = sin(alpha * M_PI / 180.0);
|
||||||
dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
||||||
@@ -97,9 +103,9 @@ calcposobs(void)
|
|||||||
v2[0] = sin(alpha2 * M_PI / 180.0);
|
v2[0] = sin(alpha2 * M_PI / 180.0);
|
||||||
v2[1] = cos(alpha2 * M_PI / 180.0);
|
v2[1] = cos(alpha2 * M_PI / 180.0);
|
||||||
|
|
||||||
obs[0] += v * dir[0];
|
obs[0] += v * dir[0] * dt;
|
||||||
obs[1] += v * dir[1];
|
obs[1] += v * dir[1] * dt;
|
||||||
obs[2] += v * dir[2];
|
obs[2] += v * dir[2] * dt;
|
||||||
|
|
||||||
if (obs[1] < 0.0)
|
if (obs[1] < 0.0)
|
||||||
obs[1] = 0.0;
|
obs[1] = 0.0;
|
||||||
@@ -432,10 +438,10 @@ key(unsigned char k, int x, int y)
|
|||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
v += 0.5;
|
v += 50.;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
v -= 0.5;
|
v -= 50.;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (poutline) {
|
if (poutline) {
|
||||||
|
@@ -12,9 +12,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
#include "readtex.c" /* I know, this is a hack. */
|
#include "readtex.h"
|
||||||
|
|
||||||
#define TEXTURE_FILE "../images/reflect.rgb"
|
#define TEXTURE_FILE "../images/reflect.rgb"
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ static GLuint CylinderObj = 0;
|
|||||||
static GLboolean Animate = GL_TRUE;
|
static GLboolean Animate = GL_TRUE;
|
||||||
|
|
||||||
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
|
static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0;
|
||||||
static GLfloat DXrot = 1.0, DYrot = 2.5;
|
static GLfloat DXrot = 50.0, DYrot = 125.0;
|
||||||
|
|
||||||
/* performance info */
|
/* performance info */
|
||||||
static GLint T0 = 0;
|
static GLint T0 = 0;
|
||||||
@@ -39,9 +40,16 @@ static GLint Frames = 0;
|
|||||||
|
|
||||||
static void Idle( void )
|
static void Idle( void )
|
||||||
{
|
{
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
if (Animate) {
|
if (Animate) {
|
||||||
Xrot += DXrot;
|
Xrot += DXrot * dt;
|
||||||
Yrot += DYrot;
|
Yrot += DYrot * dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -85,7 +85,13 @@ static void draw( void )
|
|||||||
|
|
||||||
static void idle( void )
|
static void idle( void )
|
||||||
{
|
{
|
||||||
Angle += 2.0;
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
Angle += 120.0*dt;
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,14 +9,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "readtex.c"
|
#include "readtex.h"
|
||||||
#include "tunneldat.h"
|
#include "tunneldat.h"
|
||||||
|
|
||||||
#ifdef XMESA
|
#ifdef XMESA
|
||||||
@@ -55,7 +55,7 @@ static int win = 0;
|
|||||||
|
|
||||||
static float obs[3] = { 1000.0, 0.0, 2.0 };
|
static float obs[3] = { 1000.0, 0.0, 2.0 };
|
||||||
static float dir[3];
|
static float dir[3];
|
||||||
static float v = 0.5;
|
static float v = 30.;
|
||||||
static float alpha = 90.0;
|
static float alpha = 90.0;
|
||||||
static float beta = 90.0;
|
static float beta = 90.0;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ inittextures(void)
|
|||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
GL_LINEAR_MIPMAP_LINEAR);
|
GL_LINEAR_MIPMAP_NEAREST);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glGenTextures(1, &t2id);
|
glGenTextures(1, &t2id);
|
||||||
@@ -160,6 +160,13 @@ drawobjs(const int *l, const float *f)
|
|||||||
static void
|
static void
|
||||||
calcposobs(void)
|
calcposobs(void)
|
||||||
{
|
{
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
dir[0] = sin(alpha * M_PI / 180.0);
|
dir[0] = sin(alpha * M_PI / 180.0);
|
||||||
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
||||||
dir[2] = cos(beta * M_PI / 180.0);
|
dir[2] = cos(beta * M_PI / 180.0);
|
||||||
@@ -171,9 +178,9 @@ calcposobs(void)
|
|||||||
if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
|
if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
|
||||||
dir[2] = 0;
|
dir[2] = 0;
|
||||||
|
|
||||||
obs[0] += v * dir[0];
|
obs[0] += v * dir[0] * dt;
|
||||||
obs[1] += v * dir[1];
|
obs[1] += v * dir[1] * dt;
|
||||||
obs[2] += v * dir[2];
|
obs[2] += v * dir[2] * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -204,10 +211,10 @@ key(unsigned char k, int x, int y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
v += 0.01;
|
v += 5.;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
v -= 0.01;
|
v -= 5.;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef XMESA
|
#ifdef XMESA
|
||||||
|
@@ -12,14 +12,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "readtex.c"
|
#include "readtex.h"
|
||||||
#include "tunneldat.h"
|
#include "tunneldat.h"
|
||||||
|
|
||||||
#ifdef FX
|
#ifdef FX
|
||||||
@@ -51,11 +51,11 @@ static GLint Frames = 0;
|
|||||||
|
|
||||||
static float obs[3] = { 1000.0, 0.0, 2.0 };
|
static float obs[3] = { 1000.0, 0.0, 2.0 };
|
||||||
static float dir[3];
|
static float dir[3];
|
||||||
static float v = 0.5;
|
static float v = 30.;
|
||||||
static float alpha = 90.0;
|
static float alpha = 90.0;
|
||||||
static float beta = 90.0;
|
static float beta = 90.0;
|
||||||
|
|
||||||
static int fog = 0;
|
static int fog = 1;
|
||||||
static int bfcull = 1;
|
static int bfcull = 1;
|
||||||
static int usetex = 1;
|
static int usetex = 1;
|
||||||
static int cstrip = 0;
|
static int cstrip = 0;
|
||||||
@@ -97,7 +97,7 @@ inittextures(void)
|
|||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
GL_LINEAR_MIPMAP_NEAREST);
|
GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
@@ -158,6 +158,13 @@ drawobjs(const int *l, const float *f)
|
|||||||
static void
|
static void
|
||||||
calcposobs(void)
|
calcposobs(void)
|
||||||
{
|
{
|
||||||
|
static double t0 = -1.;
|
||||||
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
|
if (t0 < 0.0)
|
||||||
|
t0 = t;
|
||||||
|
dt = t - t0;
|
||||||
|
t0 = t;
|
||||||
|
|
||||||
dir[0] = sin(alpha * M_PI / 180.0);
|
dir[0] = sin(alpha * M_PI / 180.0);
|
||||||
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
|
||||||
dir[2] = cos(beta * M_PI / 180.0);
|
dir[2] = cos(beta * M_PI / 180.0);
|
||||||
@@ -169,9 +176,9 @@ calcposobs(void)
|
|||||||
if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
|
if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
|
||||||
dir[2] = 0;
|
dir[2] = 0;
|
||||||
|
|
||||||
obs[0] += v * dir[0];
|
obs[0] += v * dir[0] * dt;
|
||||||
obs[1] += v * dir[1];
|
obs[1] += v * dir[1] * dt;
|
||||||
obs[2] += v * dir[2];
|
obs[2] += v * dir[2] * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -202,10 +209,10 @@ key(unsigned char k, int x, int y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
v += 0.01;
|
v += 5.;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
v -= 0.01;
|
v -= 5.;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef XMESA
|
#ifdef XMESA
|
||||||
|
Reference in New Issue
Block a user