void Camera::Update() { Vector3 f = m_center - m_eye; //normalize it //int test = XTOF(f.z); int mag = sqrtx( (int32)(MULX(f.x,f.x) + (int32)MULX(f.y,f.y) + (int32)MULX(f.z,f.z)) ); int n = DIVX(ITOX(1),mag); f.x = MULX(f.x,n); f.y = MULX(f.y,n); f.z = MULX(f.z,n); //update direction m_dir = f; Vector3 s = f ^ m_up, u = s ^ f; int matrix[16] = { s.x, u.x, -f.x, 0, s.y, u.y, -f.y, 0, s.z, u.z, -f.z, 0, 0, 0, 0, ITOX(1) }; glMultMatrixx(matrix); glTranslatex(-m_eye.x,-m_eye.y,-m_eye.z); }
void Chest::Reset() { m_up = true; int32 z = rand() % WORLD_WIDTH; int32 x = rand() % WORLD_HEIGHT; m_ri->position(ITOX(x),0,ITOX(z)); }
void Chest::Update(Racer* ship) { //test of the ship has collided with this chest Vector3 chestPos = m_ri->position(), shipPos = ship->m_ri->position(); if(m_up) chestPos.y += FTOX(0.01); else chestPos.y -= FTOX(0.01); if(chestPos.y >= FTOX(-0.2)) m_up = false; if(chestPos.y < FTOX(-0.6)) m_up = true; m_ri->position(chestPos); if( MULX((chestPos.x - shipPos.x),(chestPos.x - shipPos.x)) + MULX((chestPos.z - shipPos.z),(chestPos.z - shipPos.z)) < ITOX(2) ) { m_chestsRecovered++; Reset(); } }
void Chest::Initialize(Info* info) { m_chestsRecovered = 0; m_ri = new RenderInstance; m_ri->renderData(info->m_mm->GetChest()); //rotate so he's always right side up Vector3 vec(-ITOX(90),0,0); m_ri->rotation(vec); m_ri->scale(FTOX(0.5),FTOX(0.5),FTOX(0.5)); Reset(); }
//============================================================================= //Setup GL //@returns TRUE on success, FALSE otherwise //============================================================================= boolean GLApp::SetupGL() { //smooth shading & depth test glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); //enable lighting operations GLfixed diffuse[] = { FTOX(1.0f), FTOX(1.0f), FTOX(1.0f), FTOX(1.0f) }; GLfixed lightPos[] = { FTOX(0.0f), FTOX(5.0f), FTOX(-5.0f) }; glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glLightxv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightxv(GL_LIGHT0, GL_POSITION, lightPos); //enable blending operations glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //enable fog operations GLfixed fogColor[] = { 0, 0, 0, ITOX(1) }; glFogxv(GL_FOG_COLOR, fogColor); glFogx(GL_FOG_MODE, GL_LINEAR); glFogx(GL_FOG_START, ITOX(10)); glFogx(GL_FOG_END, ITOX(70)); //perspective Correction glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //GL Initialization glViewport(0, 0, m_DBitmapInfo.cx, m_DBitmapInfo.cy); //init Projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustumx(ITOX(-5), ITOX(5), ITOX(-5), ITOX(5), ITOX(10), ITOX(100)); //init Model-View matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(glGetError() != GL_NO_ERROR) return FALSE; return TRUE; }
/* INDENT ON */ long double __k_sinl(long double x, long double y) { long double a, t, z, w; int *pt = (int *) &t, *px = (int *) &x; int i, j, hx, ix; t = 1.0L; #if !defined(__i386) && !defined(__amd64) hx = px[0]; #else XTOI(px, hx); #endif ix = hx & 0x7fffffff; if (ix < 0x3ffc9000) { if (ix < 0x3fc60000) if (((int) x) == 0) return (x); /* generate inexact */ z = x * x; t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + z * (p6 + z * (p7 + z * p8))))))); t = y + x * t; return (x + t); } j = (ix + 0x400) & 0x7ffff800; i = (j - 0x3ffc4000) >> 11; #if !defined(__i386) && !defined(__amd64) pt[0] = j; #else ITOX(j, pt); #endif if (hx > 0) x = y - (t - x); else x = (-y) - (t + x); a = _TBL_sinl_hi[i]; z = x * x; t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); t = _TBL_cosl_hi[i] * w + a * t; t += _TBL_sinl_lo[i]; if (hx < 0) return (-a - t); else return (a + t); }