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; }