void CTransform::LookAt(const CVec& cEye, const CVec& cCenter, const CVec& cUp) { CVec cF = cCenter - cEye; cF.Normalize( ); CVec cUpPrime = cUp; cUpPrime.Normalize( ); CVec cS = cF * cUpPrime; CVec cU = cS * cF; CTransform cTemp; cTemp.m_afData[0][0] = cS[0]; cTemp.m_afData[1][0] = cS[1]; cTemp.m_afData[2][0] = cS[2]; cTemp.m_afData[0][1] = cU[0]; cTemp.m_afData[1][1] = cU[1]; cTemp.m_afData[2][1] = cU[2]; cTemp.m_afData[0][2] = -cF[0]; cTemp.m_afData[1][2] = -cF[1]; cTemp.m_afData[2][2] = -cF[2]; *this = cTemp * *this; Translate(-cEye.m_afData[0], -cEye.m_afData[1], -cEye.m_afData[2]); }
void CVecTests::ShouldDefaultToOriginWhenNoParameterPassed() { CVec vec; QVERIFY2(vec.x() == 0.0, "X coordinate should be 0.0"); QVERIFY2(vec.y() == 0.0, "Y coordinate should be 0.0"); QVERIFY2(vec.z() == 0.0, "Z coordinate should be 0.0"); }
void CWorm::ProcessPickDropItem() { //for all items in range: pick them up, if no item selected if ((g_pFramework->isNewEvent()) && (g_pFramework->KeyDown(m_pSettings->KeyPickDropItem))) { if (m_SelectedpItem == m_pItems.begin()) { //pick item up! list<CItem*>::iterator it; for (it = m_pGame->m_pItems.begin(); it != m_pGame->m_pItems.end(); ++it) { if ((*it)->getOwner() == NULL) { //nobody owns it //calculate distance to item: CVec posItem = CVec((*it)->getRect(), true); CVec dist = CVec(getRect()); dist -= posItem; if (dist.quad_abs() < QUADMAXITEMPICKUPDIST) { //in range...., so its mine now! (*it)->setOwner(this); m_pItems.push_back((*it)); //new item = selected one: m_SelectedpItem = m_pItems.end(); m_SelectedpItem--; } } }//for } else {//drop item! if ((*m_SelectedpItem)->isDropable()) {//can drop item (*m_SelectedpItem)->setOwner(NULL); m_SelectedpItem = m_pItems.erase(m_SelectedpItem); } } }//keydown }
/////////////////// // Setup the camera for the car void Car_SetupCamera(carsim_t *psCar, CCamera *pcCam, float dt) { float length = 40; if(!pcCam) return; CVec pos = psCar->cPos; CVec up = psCar->Z; // Limit the UP vector to a certain degree up.SetZ( MAX(0.5f, up.GetZ()) ); psCar->cDestCamPos = pos - psCar->Y * length + up * 10; CVec v = pcCam->getPos() - psCar->cDestCamPos; float dist = VectorNormalize(&v); // Spring to the 'normal' position CVec campos = pcCam->getPos() - v * CVec(10,10,5) * (dist*dt); // Follow car camera pcCam->Setup( campos, pos+psCar->Y*8 ); // // DEVELOPER: side view // keyboard_t *kb = System_GetKeyboard(); if(psOptions->nDeveloper) { if(kb->keys[SDLK_q]) pcCam->Setup( pos - psCar->X*35 + psCar->Z*5, pos); if(kb->keys[SDLK_e]) pcCam->Setup( pos + psCar->X*35 + psCar->Z*5, pos); if(kb->keys[SDLK_w]) pcCam->Setup( pos + psCar->Y*35 + psCar->Z*5, pos); } // Stationary (DEBUG) camera campos = CVec(30,30,420); //pcCam->Setup( campos, pos ); // Hood camera if( psCar->nCameraType == CAM_INCAR ) { pos = psCar->X*psCar->cInCarCamera.GetX() + psCar->Y*psCar->cInCarCamera.GetY() + psCar->Z*psCar->cInCarCamera.GetZ() + psCar->cPos; pcCam->Setup( pos, pos+psCar->Y*5); // Find the roll angle of the car // TODO: Do this better float roll = -atanf( psCar->X.GetZ() ) * (180/PI); pcCam->setRoll( roll ); } else pcCam->setRoll( 0 ); }
//--------------------------------------------------------------------------- CCoordSys::CCoordSys(CVec& org, CVec& dirX, CVec& dirY, UNIT_SYSTEM units) //--------------------------------------------------------------------------- { m_vecDirZ = dirX.Cross(dirY); m_vecDirX = dirX.Normalized(); m_vecDirY = dirY.Normalized(); m_vecDirZ = m_vecDirZ.Normalized(); m_vecOrg = org; m_enumUnits = units; }
void RemoveUnusedFrames() // frames count will not go below t_initialFrames { for( uiw frame = 0; frame < _o_frames.Size() && _o_frames.Size() >= t_initialFrames; ++frame ) { if( _o_frames[ frame ].used == 0 ) { _o_frames.Erase( frame, 1 ); --frame; } } }
void CFramework::drawLine(CVec v1, CVec v2, int r, int g, int b, bool doOnViewCheck) { vector<S_ViewPort>::iterator it; for (it = g_pFramework->ViewPorts.begin(); it != g_pFramework->ViewPorts.end(); ++it) { if ( (doOnViewCheck == false) || ((v1.inRect(it->m_View)) && (v2.inRect(it->m_View))) ) { lineRGBA(m_pScreen, v1.x + (it->m_ScreenPosition.x) - (it->m_View.x), v1.y, v2.x + (it->m_ScreenPosition.x) - (it->m_View.x), v2.y, r, g, b, 255); } } }
void CTransform::RotateAxis(float fAngle, CVec cAxis) { cAxis.Normalize( ); float s = VectorSinD(fAngle); float c = VectorCosD(fAngle); float t = 1.0f - c; float x = cAxis.m_afData[0]; float y = cAxis.m_afData[1]; float z = cAxis.m_afData[2]; CTransform cRotMatrix; cRotMatrix.m_afData[0][0] = t * x * x + c; cRotMatrix.m_afData[0][1] = t * x * y + s * z; cRotMatrix.m_afData[0][2] = t * x * z - s * y; cRotMatrix.m_afData[0][3] = 0.0; cRotMatrix.m_afData[1][0] = t * x * y - s * z; cRotMatrix.m_afData[1][1] = t * y * y + c; cRotMatrix.m_afData[1][2] = t * y * z + s * x; cRotMatrix.m_afData[1][3] = 0.0; cRotMatrix.m_afData[2][0] = t * x * z + s * y; cRotMatrix.m_afData[2][1] = t * y * z - s * x; cRotMatrix.m_afData[2][2] = t * z * z + c; cRotMatrix.m_afData[2][3] = 0.0; cRotMatrix.m_afData[3][0] = 0.0; cRotMatrix.m_afData[3][1] = 0.0; cRotMatrix.m_afData[3][2] = 0.0; cRotMatrix.m_afData[3][3] = 1.0; *this = cRotMatrix * *this; }
X &Enumerate( uiw *p_frame, uiw *p_index ) { ASSUME( p_frame && p_index ); for( ; ; ) { uiw frame = *p_frame; uiw index = *p_index; ++*p_index; if( *p_index == t_frameSize ) { *p_index = 0; ++*p_frame; } if( frame == _o_frames.Size() ) { *p_frame = uiw_max; return _o_frames[ 0 ].p_mem[ 0 ]; } if( !_IsFree( &_o_frames[ frame ].p_mem[ index ] ) ) { return _o_frames[ frame ].p_mem[ index ]; } } }
void CAA_DragonFire::update() { if (getLastCollisionX().bIsCollision) { CBlockKoord blockKoord; CVec vec = CVec( getRect().x+(m_bOrientation == OLEFT ? -3.0f : getRect().w+3.0f), //x getRect().y + 50.0f); //y blockKoord = vec.toBlockKoord(); CBlock * pOldBlock = m_pGame->getBlock(blockKoord); if ((pOldBlock != NULL) && (pOldBlock->getBlockType() != CBlock::AIR)) { m_pGame->BuildBlock(blockKoord, CBlock::AIR, m_WormID, m_TeamID); } //TODO: save map in xml... } }
void RemoveByFrameIndex( uiw frame, uiw index ) { ASSUME( frame < _o_frames.Size() && index < t_frameSize ); ASSUME( !_IsFree( &_o_frames[ frame ].p_mem[ index ] ) ); _o_frames[ frame ].p_mem[ index ].~X(); _SetFree( &_o_frames[ frame ].p_mem[ index ] ); --_o_frames[ frame ].used; }
CBlock::BlockType CPhysics::getBlockType(CVec &vec) { CBlock* b; b= m_pGame->getBlock(vec.toBlockKoord()); if (b != NULL) //vec existiert tats�chlich! return b->getBlockType(); else return CBlock::NORMAL; }
uiw Size() { uiw size = 0; for( uiw frame = 0; frame < _o_frames.Size(); ++frame ) { size += _o_frames[ frame ].used; } return size; }
X *AddUninit() { for( uiw frame = 0; frame < _o_frames.Size(); ++frame ) { if( _o_frames[ frame ].used < t_frameSize ) { for( uiw index = 0; ; ++index ) { ASSUME( index < t_frameSize ); if( _IsFree( _o_frames[ frame ].p_mem + index ) ) { ++_o_frames[ frame ].used; return &_o_frames[ frame ].p_mem[ index ]; } } } } _o_frames.Resize( _o_frames.Size() + 1 ); ++_o_frames.Back().used; return &_o_frames.Back().p_mem[ 0 ]; }
void Clear() { for( uiw frame = 0; frame < _o_frames.Size(); ++frame ) { for( uiw index = 0; index < t_frameSize; ++index ) { if( !_IsFree( &_o_frames[ frame ].p_mem[ index ] ) ) { _o_frames[ frame ].p_mem[ index ].~X(); _SetFree( &_o_frames[ frame ].p_mem[ index ] ); } } _o_frames[ frame ].used = 0; } }
void Remove( X *p_val ) { for( uiw frame = 0; ; ++frame ) { ASSUME( frame < _o_frames.Size() ); if( p_val >= _o_frames[ frame ].p_mem && p_val <= _o_frames[ frame ].p_mem + t_frameSize - 1 ) { ASSUME( !_IsFree( p_val ) ); p_val->~X(); _SetFree( p_val ); --_o_frames[ frame ].used; break; } } }
bln GetFrameIndexByAddr( const void *cp_addr, uiw *p_frame, uiw *p_index ) { ASSUME( p_frame && p_index ); const byte *cp_byteAddr = (byte *)cp_addr; for( uiw frame = 0; frame < _o_frames.Size(); ++frame ) { if( cp_byteAddr >= (byte *)_o_frames[ frame ].p_mem && (X *)cp_byteAddr < _o_frames[ frame ].p_mem + t_frameSize ) { *p_frame = frame; cp_byteAddr -= (uiw)_o_frames[ frame ].p_mem; *p_index = (uiw)cp_byteAddr / sizeof(X); return true; } } return false; }
void CAA_Cloud::init(CVec StartPos, CWorm * pAimWorm, CWorm * pOwnerWorm, int TeamID) { initKillTime(0.7f); FloatRect fr = StartPos.toFloatRect(); fr.w = m_pSprite->GetRect().w; fr.h = m_pSprite->GetRect().h; fr.y = 0; //Clouds are on Heaven! setRect(fr); m_TeamID = TeamID; m_pAimWorm = pAimWorm; m_pOwnerWorm = pOwnerWorm; //don't do physics on that! setIsSolid(false); setCanMove(false); m_fLighteningState = 0.0f; }
CVec CTransform::operator*(const CVec& cVec) const { int nSize = cVec.GetSize( ); CVec cTemp(nSize); for (int i = 0; i < nSize; ++i) { cTemp.m_afData[i] = 0.0f; for (int j = 0; j < 4; ++j) if (j < nSize) cTemp.m_afData[i] += m_afData[i][j] * cVec.m_afData[j]; else if (j == 3) cTemp.m_afData[i] += m_afData[i][j]; } return cTemp; }
/////////////////// // Initialize the sky bool CSky::Initialize(void) { // Allocate the stars m_psStars = new star_t[MAX_STARS]; if(m_psStars == NULL) return false; // Set the star details float radius = 90; CVec f; for(int i=0; i<MAX_STARS; i++) { GetAngles(-fabs(GetRandomNum()*45), 0, fabs(GetRandomNum()*360), &f, NULL, NULL); m_psStars[i].pos = f*radius; m_psStars[i].size = fabs(GetRandomNum()); m_psStars[i].flicker = fabs(GetRandomNum()); // Calculate the rotation CVec p = m_psStars[i].pos; VectorNormalize( &p ); m_psStars[i].yaw = (float)(-atan2(p.GetX(),p.GetY()) * (180/PI)); float dist = (float)sqrt((float)(p.GetX() * p.GetX() + p.GetY() * p.GetY())); m_psStars[i].pitch = (float)(-atan2(dist,p.GetZ()) * (180/PI)+270); } // Load the moon texture m_psMoonTexture = Cache_LoadTexture("data/textures/sky/moonlg.png"); if(m_psMoonTexture == NULL) return false; Tex_Upload(m_psMoonTexture); // Load the star texture m_psStarTexture = Cache_LoadTexture("data/textures/sky/star.png"); if(m_psStarTexture == NULL) return false; Tex_Upload(m_psStarTexture); return true; }
// calculates euler angles representing rotation matrix void CMathLib::getOrientation(CMatrix &mat, CVec &first, CVec &second) { float a, b, g; b = atan2(-mat.a[2], sqrt(mat.a[0]*mat.a[0]+mat.a[1]*mat.a[1])); if (fabsf(b - M_PI/2.0) < 0.0001) { a = 0; g = atan2(mat.a[4], mat.a[5]); } else if (fabsf(b + M_PI/2.0) < 0.0001) { a = 0; g = -atan2(mat.a[4], mat.a[5]); } else { a = atan2(mat.a[1]/cos(b), mat.a[0]/cos(b)); g = atan2(mat.a[6]/cos(b), mat.a[10]/cos(b)); } first.set(g, b, a); second = first; /* float a, b, g; b = atan2(-mat.a[4], sqrt(mat.a[5]*mat.a[5]+mat.a[6]*mat.a[6]) ); if(fabs(b - M_PI/2.0) < 0.0001) { g = 0; a = atan2(mat.a[9], mat.a[10]); } else if(fabs(b + M_PI/2.0) < 0.0001) { g = 0; a = atan2(-mat.a[9], mat.a[10]); } else { a = atan2(mat.a[8]/cos(b), mat.a[0]/cos(b) ); g = atan2(mat.a[6]/cos(b), mat.a[5]/cos(b) ); } first.set(g, a, b); second = first;*/ }
float CVec::AngleBetween(const CVec& cVec) const { return (acosf((*this ^ cVec) / (Magnitude( ) * cVec.Magnitude( )))); }
void CPhysics::doPhysicsFor(CPhysicalObject * it) { if (! it->getCanMove()) return; S_Collision YCollision; S_Collision XCollision; float timeElapsed = g_pTimer->getElapsed(); if (timeElapsed == 0.0f) return; //macht keinen Sinn.... FloatRect FR = it->getRect(); //rect of PO..PhysicalObject CVec dir = it->getDir(); //dir of PO XCollision.bIsCollision = false; YCollision.bIsCollision = false; float time = timeElapsed; int i;//Anzahl der Kleinschritte herrausbekommen: for (i = 1; dir.quad_abs()*time > BLOCKSIZE*BLOCKSIZE; i++) { time = timeElapsed/i; } //////////////////// //X/Y-Collisions: for (i = 1; (i*time <= timeElapsed); i++) { if (!XCollision.bIsCollision) { FR.x += dir.x*time; XCollision = getCollision(FR); if (XCollision.bIsCollision) { //kollission durch x-Rutschen? FR.x -= dir.x*time; //dann x-Rutschen wieder r�ckg�ngig machen dir.x *= (-1 * XCollision.fBouncingFactorX); } } if (!YCollision.bIsCollision) { //yes all physicall objects fall! //Fallbeschleunigung dazu! //HINT: Fallkurve hängt von getTimeelapsed ab!! evtl mit s=g/2t² arbeieten dir.y += Gravity*time; //graviy muss nach unten zeigen... it->setCanJump(false); //kann auf jeden erstmal nicht springen //Kollission durch y-Verschiebung?? FR.y += dir.y*time; YCollision = getCollision(FR); if (YCollision.bIsCollision) { //kollission durch y-Rutschen? //JumpingBoard... //getBouncingfactor from Blocktype FR.y -= dir.y*time; //dann y-Rutschen wieder r�ckg�ngig machen dir.y *= (-1 * YCollision.fBouncingFactorY);//neues Y if ((Abs(dir.y) < 10.0f) || (YCollision.BlockType == CBlock::JUMPBOARD)) { it->setCanJump(true); } } } if (YCollision.bIsCollision && XCollision.bIsCollision) break; }//für jeden SChritt... //wenn keine x-Kollission: //HINT:Reibung://Flugreibung ist Sinnlos! if (!XCollision.bIsCollision) dir.x *= (Friction ) ; //TODO TimeElapsed einrechnen! if (FR.x < 0.0f) FR.x = 0.0f; //man kann nicht aus dem linken bildschirm fallen!! if (FR.y < 0.0f) {//opben geht das ganze natürlich auch nicht FR.y = 0.0f; dir.y = 0.0f; }//MBE Performance: allways 0.0f if its float! with .0f!!! //Wenn keine kollission dann Verschieben !...^^ it->setDir(dir); it->setRect(FR); //gegebenenfalls neue collision setzen if (YCollision.BlockType != CBlock::AIR) it->setLastCollisionY(YCollision); }
uiw Frames() { return _o_frames.Size(); }
void ClearToInitial() { Clear(); _o_frames.Resize( t_initialFrames ); }
/////////////////// // Update the wheel position void Car_UpdateWheel(carsim_t *psCar, CModel *pcTrack, int id) { wheel_t *w = &psCar->sWheels[id]; CVec relpos = w->cRelPos; float p[3], t1[9], t2[9]; plane_t plane; // Calculate the wheel 'top' pos CVec wheelPos = psCar->X*relpos.GetX() + psCar->Y*relpos.GetY() + psCar->Z*relpos.GetZ() + psCar->cPos; // Convert the wheel in car coords relpos -= CVec(0,0,w->fRestLength); w->cPos = psCar->X*relpos.GetX() + psCar->Y*relpos.GetY() + psCar->Z*relpos.GetZ() + psCar->cPos; // This is for the rendering w->fWheelZ = -w->fRestLength; // Defaults w->fSuspLength = w->fRestLength; w->fPistonVelocity = 0; // Check for collisions p[0] = w->cPos.GetX(); p[1] = w->cPos.GetY(); p[2] = w->cPos.GetZ(); w->bCollision = false; float pDist = 0; if( pcTrack->getCDModel()->sphereCollision( p, w->fRadius ) ) { float top=999999; for(int n=0; n<pcTrack->getCDModel()->getNumCollisions(); n++) { pcTrack->getCDModel()->getCollidingTriangles(n, t1,t2,false); plane = CalculatePlane(CVec(t1[0],t1[1],t1[2]), CVec(t1[3],t1[4],t1[5]), CVec(t1[6],t1[7],t1[8])); // If the normal is too great for the tyre, ignore the collision if(DotProduct(plane.vNormal,psCar->Z) < 0.5f) continue; // Find the plane that is raised towards the wheel center the most if( DotProduct(wheelPos, plane.vNormal) + plane.fDistance < top) { // TODO: Check if the tyre is not too high (ie, over the suspension joint) top = DotProduct(wheelPos, plane.vNormal) + plane.fDistance; w->cNormal = plane.vNormal; pDist = plane.fDistance; } w->bCollision = true; } } w->fSpeed = 0; // If not colliding, just leave if(!w->bCollision) return; // Make the tyre sit on top of the road float d = DotProduct(w->cPos, w->cNormal) + pDist; w->fSuspLength = d; relpos = w->cRelPos - CVec(0,0,w->fSuspLength); w->fWheelZ = -w->fSuspLength; w->cPos = psCar->X*relpos.GetX() + psCar->Y*relpos.GetY() + psCar->Z*relpos.GetZ() + psCar->cPos; // Get the piston velocity for the suspension CVec vel = CrossProduct(psCar->cPos-w->cPos, psCar->cAngVelocity) + psCar->cVelocity; w->fPistonVelocity = (psCar->Z * DotProduct(psCar->Z,vel)).GetZ(); // Calculate the rotation speed of the tyre CVec s = psCar->Y * DotProduct(psCar->cVelocity, psCar->Y); w->fSpeed = VectorLength(s); if(DotProduct(psCar->cVelocity, psCar->Y) > 0) w->fSpin += w->fSpeed / w->fRadius; else w->fSpin -= w->fSpeed / w->fRadius; // Rotation is based on the Torque from the engine //w->fSpin += w->fTorque / w->fRadius; // If the torque is greater then the slip torque for the surface, the wheel is slipping and the engine force // is less // Note: The slip torque is constant for now if(id == 1) { //tMainSR3.f1 = w->fTorque; } if(w->fTorque > 100) { // Slipping w->fEngineLoad = w->fTorque/50; w->bSlip = true; } else { w->bSlip = false; w->fEngineLoad = 0; } w->fSpin = LimitAngle(w->fSpin); }
CObject *CreateBox() { static Nullable < SGeometry > boxGeo; if( boxGeo.IsNull() ) { Geometry::BoxTN( &boxGeo.Get(), true ); } SGeometrySlice slice; slice.indicesCount = boxGeo->indicesCount; slice.is_defined = true; slice.startIndex = 0; slice.startVertex = 0; slice.verticesCount = boxGeo->verticesCount; D3D11_SAMPLER_DESC o_sampDef; o_sampDef.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; o_sampDef.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; o_sampDef.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; o_sampDef.BorderColor[ 0 ] = 1.f; o_sampDef.BorderColor[ 1 ] = 1.f; o_sampDef.BorderColor[ 2 ] = 1.f; o_sampDef.BorderColor[ 3 ] = 1.f; o_sampDef.ComparisonFunc = D3D11_COMPARISON_NEVER; o_sampDef.Filter = D3D11_FILTER_ANISOTROPIC; o_sampDef.MaxAnisotropy = 16; o_sampDef.MaxLOD = FLT_MAX; o_sampDef.MinLOD = -FLT_MAX; o_sampDef.MipLODBias = 0.f; D3D11_BLEND_DESC o_blend = {}; o_blend.AlphaToCoverageEnable = false; o_blend.IndependentBlendEnable = false; o_blend.RenderTarget[ 0 ].BlendEnable = true; o_blend.RenderTarget[ 0 ].SrcBlend = D3D11_BLEND_SRC_ALPHA; o_blend.RenderTarget[ 0 ].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; o_blend.RenderTarget[ 0 ].BlendOp = D3D11_BLEND_OP_ADD; o_blend.RenderTarget[ 0 ].SrcBlendAlpha = D3D11_BLEND_ZERO; o_blend.RenderTarget[ 0 ].DestBlendAlpha = D3D11_BLEND_ZERO; o_blend.RenderTarget[ 0 ].BlendOpAlpha = D3D11_BLEND_OP_ADD; o_blend.RenderTarget[ 0 ].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; D3D11_RASTERIZER_DESC o_rsDesc; o_rsDesc.AntialiasedLineEnable = false; o_rsDesc.CullMode = D3D11_CULL_BACK; o_rsDesc.DepthBias = 0; o_rsDesc.DepthBiasClamp = 0.f; o_rsDesc.DepthClipEnable = true; o_rsDesc.FillMode = D3D11_FILL_SOLID; o_rsDesc.FrontCounterClockwise = false; o_rsDesc.MultisampleEnable = false; o_rsDesc.ScissorEnable = false; o_rsDesc.SlopeScaledDepthBias = 0.f; CVec < STex, void > tex; tex.EmplaceBack( TextureLoader::Load( "Textures/Best-Desktop-Background-130.jpg" ), &o_sampDef, vec2( 0 ), vec2( 4000, 4 ), vec2( 0.75, 0.75 ), 0 ); CVec < SMaterial, void > mat; mat.EmplaceBack( &boxGeo.Get(), slice, 1, 0, std::move( tex ), ShadersManager::AcquireByName( "lightless" ), &o_blend, &o_rsDesc, Colora::White, Colora::White, Color::Black, 0.5, RStates::target ); mat[ 0 ].is_enabled = true; mat[ 0 ].is_inFrustum = true; return new CObject( vec3( 0 ), vec3( 0 ), vec3( 0 ), std::move( mat ) ); }
X &Get( uiw frame, uiw index ) { ASSUME( frame < _o_frames.Size() && index < t_frameSize ); return _o_frames[ frame ].p_mem[ index ]; }
CFramedStore() : _o_frames( t_initialFrames ) { _o_frames.Resize( t_initialFrames ); }
/////////////////// // Render the sky void CSky::Render(CCamera *psCamera) { int i; float fSize; State_Enable(GL_TEXTURE_2D); State_Disable(GL_FOG); State_Disable(GL_LIGHTING); State_Enable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR); glDepthMask(0); // Make the sky be around the camera glPushMatrix(); if(psCamera) { CVec p = psCamera->getPos(); glTranslatef(p.GetX(), p.GetY(), p.GetZ()); } // Draw the stars Tex_Bind(m_psStarTexture); star_t *s = m_psStars; for(i=0; i<MAX_STARS; i++, s++) { glPushMatrix(); glTranslatef(s->pos.GetX(), s->pos.GetY(), s->pos.GetZ()); glRotatef(s->yaw-180, 0,0,1); glRotatef(s->pitch, 0,0,1); float f = 1-(fabs(GetRandomNum()*0.6f) * s->flicker); glColor4f(f,f,f,1.0f); fSize = s->size; glBegin(GL_QUADS); glTexCoord2i(0,0); glVertex3f(-fSize, 0, -fSize); glTexCoord2i(1,0); glVertex3f(fSize, 0, -fSize); glTexCoord2i(1,1); glVertex3f(fSize, 0, fSize); glTexCoord2i(0,1); glVertex3f(-fSize, 0, fSize); glEnd(); glPopMatrix(); } // Draw the moon glColor4f(1,1,1,1); Tex_Bind(m_psMoonTexture); glPushMatrix(); fSize = 5.5f; glTranslatef(-60,100,40); glRotatef(10,0,0,1); glBegin(GL_QUADS); glTexCoord2i(0,0); glVertex3f(-fSize, 0, -fSize); glTexCoord2i(1,0); glVertex3f(fSize, 0, -fSize); glTexCoord2i(1,1); glVertex3f(fSize, 0, fSize); glTexCoord2i(0,1); glVertex3f(-fSize, 0, fSize); glEnd(); glPopMatrix(); glDepthMask(1); glPopMatrix(); }