void ctSafeZone::Draw( vsRenderQueue *queue ) { vsScene *scene = queue->GetScene(); vsBox2D box( scene->GetTopLeftCorner(), scene->GetBottomRightCorner() ); float marginSize = box.Height() * 0.1f; box.Expand( marginSize ); vsVector3D v[4] = { vsVector2D(box.GetMin().x, box.GetMin().y), vsVector2D(box.GetMax().x, box.GetMin().y), vsVector2D(box.GetMin().x, box.GetMax().y), vsVector2D(box.GetMax().x, box.GetMax().y) }; int i[5] = {0, 1, 3, 2, 0}; vsDisplayList *list = queue->GetGenericList(); list->VertexArray(v,4); list->LineStrip(i,5); list->ClearVertexArray(); }
void daModeTitleScreen::Init() { m_menuItemSelected = 0; m_menu = new utMenu( MENU_MAX, 25.0f, 35.0f, 20.0f ); m_menu->SetItemLabel(NewGame, "New Game"); m_menu->SetItemLabel(HowToPlay, "How To Play"); m_menu->SetItemLabel(Options, "Options"); m_menu->SetItemLabel(Credits, "Credits"); m_menu->SetItemLabel(Quit, "Quit"); m_menuThump = new sndSample("thump_4.wav"); m_title = new vsSprite( NULL ); vsSprite *timed = new vsSprite(vsBuiltInFont::CreateString(vsString("Ill-Timed"), 30.0f, 80.0f, Justification_Right)); vsSprite *petition = new vsSprite(vsBuiltInFont::CreateString(vsString("Petition"), 60.0f, 80.0f, Justification_Right)); vsSprite *damsel = new vsSprite(vsBuiltInFont::CreateString(vsString("Damsel"), 90.0f, 90.0f, Justification_Right)); timed->SetPosition( vsVector2D(0.0f,0.0f) ); petition->SetPosition( vsVector2D(0.0f,80.0f) ); damsel->SetPosition( vsVector2D(0.0f,180.0f) ); m_title->AddChild(timed); m_title->AddChild(petition); m_title->AddChild(damsel); m_background = new daLevelBackground; m_background->SetPosition(vsVector2D(-400.0f,100.0f)); m_background->RegisterOnLayer(0); m_background->FadeIn(); m_title->RegisterOnLayer(1); m_menu->Enter(); m_menu->RegisterOnLayer(1); m_transitioningIn = true; m_transitioningOut = false; m_transitionTimer = 0.f; titlePos.x = vsScreen::Instance()->GetLayer(1)->GetTopRightCorner().x - 100.f; m_iniTitlePos = titlePos; m_iniMenuPos = menuPos; m_iniTitlePos.y = vsScreen::Instance()->GetLayer(1)->GetTopLeftCorner().y - 300.f; m_iniMenuPos.x = vsScreen::Instance()->GetLayer(1)->GetTopLeftCorner().x - 400.0f; m_menu->SetPosition(m_iniMenuPos); m_title->SetPosition(m_iniTitlePos); m_title->SetColor(vsColor::Black); m_game->PlayMusic( daGame::Music_Title ); }
void sstSequence::DoneAddingBeats() { if ( !m_beatCount ) return; m_width = m_beatCount * vsRandom::GetFloat( 70.0f, 100.0f ); float halfWidth = 0.5f * m_width; float offsetPerBeat = (m_beatCount > 1)?m_width / (m_beatCount-1):0.f; float offsetPerBeatFortyFive = offsetPerBeat * 0.707f; // if we're doing a 45 degree offset, adjust our distance so the stars aren't really far apart. vsVector2D movingPosition( -halfWidth, 0.f ); for ( int i = 0; i < m_beatCount; i++ ) { int dir = vsRandom::GetInt(4); if ( dir == 0 ) movingPosition += vsVector2D( offsetPerBeatFortyFive, offsetPerBeatFortyFive ); else if ( dir == 1 ) movingPosition += vsVector2D( offsetPerBeatFortyFive, -offsetPerBeatFortyFive ); else movingPosition += vsVector2D( offsetPerBeat, 0.f ); m_segment[i].m_position = movingPosition;//.Set( -halfWidth + (i * offsetPerBeat), 0.f ); m_segment[i].m_time = m_beat[i]; } m_start = m_mode->GetMusicTime(); m_end = m_beat[m_beatCount-1] + 8.0f; m_transformA.SetTranslation( vsRandom::GetVector2D(300.0f) ); if ( m_onRight ) m_transformA.SetTranslation( m_transformA.GetTranslation() + vsVector2D(700.0f,0.f) ); else m_transformA.SetTranslation( m_transformA.GetTranslation() - vsVector2D(700.0f,0.f) ); float speed = vsRandom::GetFloat( 30.0f, 60.0f ); float rotSpeed = vsRandom::GetFloat( -200.0f, 200.0f ); float deltaTime = m_end - m_start; m_transformB.SetTranslation( m_transformA.GetTranslation() ); m_transformB.SetTranslation( m_transformB.GetTranslation() + vsRandom::GetVector2D( speed * deltaTime ) ); m_transformA.SetAngle( DEGREES(vsRandom::GetFloat(-180.0f, 180.0f)) ); m_transformB.SetAngle( DEGREES(m_transformA.GetAngle().GetDegrees() + rotSpeed * deltaTime) ); ClampBeats(); }
void sstSequence::DrawTarget( vsDisplayList *list, int id ) { if ( m_targetActive[id] ) { vsVector2D pos = m_currentTransform.ApplyTo( m_segment[id].m_position ); list->SetColor( m_segment[id].m_color ); list->MoveTo( pos + vsVector2D(0.0f,-15.0f)); list->LineTo( pos + vsVector2D(15.0f,0.0f)); list->LineTo( pos + vsVector2D(0.0f,15.0f)); list->LineTo( pos + vsVector2D(-15.0f,0.0f)); list->LineTo( pos + vsVector2D(0.0f,-15.0f)); } }
vsVector2D vsCollisionObject::GetPosition() { b2Vec2 p = m_body->GetPosition(); return vsVector2D(p.x,p.y); }
vsVector2D vsVector2D::Normalised() { float length = Length(); vsAssert(length != 0.f, "Tried to normalise zero-length vector!"); return vsVector2D(x/length, y/length); }
void astHud::_Draw( vsDisplayList *list ) { // by default, our viewport extends -500 -> 500 vertically, and something more than that horizontally (based on aspect ratio) BuildScoreLists(); vsTransform2D t = vsTransform2D::Zero; t.SetTranslation( vsVector2D(-460.f, -400.f) ); list->SetColor( vsColor::Blue * m_opacity * m_opacity ); // ease in, slam out int livesRemaining = m_parent->GetPlayerLivesRemaining(); if ( livesRemaining > 5 ) livesRemaining = 5; // only draw up to five icons, max. for ( int i = 0; i < livesRemaining; i++ ) // draw each of our player icons { list->PushTransform(t); list->Append(*m_playerShip); list->PopTransform(); t.SetTranslation( t.GetTranslation() + vsVector2D(50.f,0.f) ); } list->SetColor( vsColor::Blue * m_opacity ); if ( m_scoreList ) { t.SetTranslation(vsVector2D(-520.f, -440.f)); list->PushTransform(t); list->Append(*m_scoreList); list->PopTransform(); } if ( m_highScoreList ) { t.SetTranslation(vsVector2D(-40.f, -440.f)); list->PushTransform(t); list->Append(*m_highScoreList); list->PopTransform(); } }
void vsBuiltInFont::BuildDisplayListFromString( vsDisplayList *list, const char *string, float size, float capSize, JustificationType j, const vsVector2D &offset_in ) { vsVector2D offset = offset_in; size_t len = strlen(string); if ( j != Justification_Left ) { BuildDisplayListFromString(list, string, size, capSize, Justification_Left); float width = GetDisplayListWidth(list); if ( j == Justification_Right ) offset.x = -width; if ( j == Justification_Center ) offset.x = -(width*0.5f); list->Clear(); } //float iniXOffset = offset.x; list->VertexBuffer(s_P); vsTransform2D t; for ( size_t i = 0; i < len; i++ ) { char thisChar = string[i]; float thisSize = GetSizeForCharacter(thisChar, size, capSize); int index = lookup_letterIndex(thisChar); if ( index < 57 && index >= 0 ) { vsAssert(index < 57, "Unknown char??"); offset.x += c_kerningFactor * thisSize; t.SetTranslation( offset-(thisSize*baseline) ); t.SetScale( vsVector2D(thisSize,thisSize) ); list->PushTransform(t); list->LineListBuffer( &s_I[index] ); list->PopTransform(); } // AppendCharacterToList( string[i], list, offset, thisSize ); offset.x += c_kerningFactor * thisSize; } list->ClearArrays(); }
void astPlayerShip::HandleSpawnTimer( float timeStep ) { m_timeSinceSpawn += timeStep; const float c_invulnerableTime = 3.0f; // three seconds of invulnerability if ( m_spawnInvulnerable ) { float scale = 1.0f; vsColor c = vsColor::Blue; if ( m_timeSinceSpawn > c_invulnerableTime ) { SetCollisionsActive(true); m_spawnInvulnerable = false; } else if ( m_timeSinceSpawn > 2.0f ) { float frac = (m_timeSinceSpawn - 2.0f); float theta = frac * TWOPI; float pulseAmt = vsFabs(vsSin(theta)); c = vsInterpolate(pulseAmt, vsColor::LightBlue, vsColor::White); } else if ( m_timeSinceSpawn > 1.0f ) { float frac = (m_timeSinceSpawn - 1.0f); float theta = frac * TWOPI; float pulseAmt = vsFabs(vsSin(theta)); c = vsInterpolate(pulseAmt, vsColor::LightBlue, vsColor::White); } else { c = vsInterpolate(m_timeSinceSpawn, vsColor::Black, vsColor::LightBlue); } const float c_scaleTime = 3.0f; if ( m_timeSinceSpawn < c_scaleTime ) { float frac = m_timeSinceSpawn / c_scaleTime; frac = 1.0f - ((frac-1.f) * (frac-1.f)); // slam in, ease out //frac = (3.0f * frac * frac) - (2.0f * frac * frac * frac); // ease in, ease out scale = vsInterpolate( frac, 5.0f, 1.0f ); } SetColor(c); m_transform.SetScale( vsVector2D(scale,scale) ); } }
void tbGame::Update( float timeStep ) { UNUSED(timeStep); sysInput *input = GetInput(); if ( input->WasPressed(CID_A) ) { m_a->SetVelocity( vsVector2D::Zero ); m_b->SetVelocity( vsVector2D::Zero ); m_a->SetAngularVelocity( 0.f ); m_b->SetAngularVelocity( 0.f ); m_a->SetPosition( vsVector2D(-100.0f, 0.0f) ); m_b->SetPosition( vsVector2D(100.0f, 0.0f) ); m_e->SetSpawnPosition( vsVector2D(100.0f, 0.0f) ); m_e->SetSpawnRate( 100.0f ); vsTuneable vsVector2D partVel(-400.0f, 0.0f); m_e->SetSpawnVelocity( partVel, 100.0f ); vsTuneable vsVector2D impulseA(-2000.0f,0.0f); vsTuneable vsVector2D impulseB(-30000.0f,12000.0f); m_a->SetMass(5.0f); m_b->SetMass(5.0f); m_a->AddForce(impulseA); m_b->AddForce(impulseB); vsTuneable float torqueAmt = 500.0f; m_a->AddTorque(-torqueAmt); m_b->AddTorque(torqueAmt); } m_e->Update(timeStep); }
void daHud::_Draw( vsDisplayList *list ) { // by default, our viewport extends -500 -> 500 vertically, and something more than that horizontally (based on aspect ratio) BuildScoreLists(); vsTransform t = vsTransform::Zero; t.m_position.Set(-460.f, -400.f); t.m_scale.Set(2.0f,2.0f); list->SetColor( vsColor::Yellow * m_opacity * m_opacity ); // ease in, slam out int petitionsRemaining = m_gameMode->GetPetitionsInHand(); if ( petitionsRemaining > 5 ) petitionsRemaining = 5; // only draw up to five icons, max. for ( int i = 0; i < petitionsRemaining; i++ ) // draw each of our player icons { list->PushTransform(t); list->Append(*m_petitionList); list->PopTransform(); t.m_position += vsVector2D(50.f,0.f); } t.m_scale.Set(1.0f,1.0f); list->SetColor( vsColor::Blue * m_opacity ); if ( m_scoreList ) { t.m_position.Set(-100.f, -440.f); list->PushTransform(t); list->Append(*m_signatures); list->Append(*m_scoreList); list->PopTransform(); } if ( m_timeList ) { t.m_position.Set(450, -440.f); list->PushTransform(t); list->Append(*m_timeRemaining); list->Append(*m_timeList); list->PopTransform(); } }
void daSplat::Update( float timeStep ) { m_timer -= timeStep; SetScale(vsVector2D(1.2f,1.2f)); if ( m_timer <= 0.f ) { Extract(); // despawn us. } else { vsColor grey(0.5f,0.5f,0.5f,1.0f); if ( m_timer > 1.0f ) SetColor(grey); else SetColor( vsInterpolate( m_timer, vsColor::Black, grey ) ); } }
void sstFireworks::Update( float timeStep ) { sstFireworkParticle *p = m_usedList->m_next; while( p && p != m_usedList ) { sstFireworkParticle *next = p->m_next; p->m_position += p->m_velocity * timeStep; p->m_velocity += vsVector2D(0.0f,30.81f) * timeStep; p->m_life += timeStep; if ( p->m_life > p->m_lifeTime ) { p->Extract(); m_unusedList->Append(p); } p = next; } }
void rpModeCredits::LoadLine( int i ) { vsString creditString; m_creditsDone = !m_credits->ReadLine(&creditString); m_lineUsed[i] = false; if ( m_line[i] ) vsDelete(m_line[i]); if ( !m_creditsDone ) { if ( creditString[0] == '-' ) m_line[i] = new vsSprite( vsBuiltInFont::CreateString(creditString, 35.0f, 60.0f, Justification_Center) ); else m_line[i] = new vsSprite( vsBuiltInFont::CreateString(creditString, 15.0f, 20.0f, Justification_Center) ); m_line[i]->SetColor( vsColor(vsColor::LightBlue) ); m_line[i]->SetPosition( vsVector2D(0.f, -700.f) ); m_line[i]->RegisterOnScene(1); m_lineUsed[i] = true; m_lineId[i] = m_lineCount++; } }
void ctMode3D::Init() { Parent::Init(); vsBox3D dims( vsVector3D(-30.f, 0.f, -30.f), vsVector3D(30.f, 15.f, 30.f) ); m_stage = new ctStage3D( dims ); m_player = new ctPlayer3D( dims ); m_player->SetPosition( vsVector2D(-25.f, 0.f) ); m_stage->RegisterOnScene(0); m_player->RegisterOnScene(0); m_camera = new ctCamera3D; m_camera->Follow( m_player ); vsSystem::GetScreen()->GetScene(0)->Set3D(true); vsSystem::GetScreen()->GetScene(0)->SetCamera3D(m_camera); //m_stage->AddBox( vsBox2D( vsVector2D(0.f,-2.f), vsVector2D(5.f,-1.f) ) ); //m_stage->AddBox( vsBox2D( vsVector2D(10.f,-4.f), vsVector2D(15.f,-3.f) ) ); //m_stage->AddBox( vsBox2D( vsVector2D(18.f,-5.f), vsVector2D(25.f,-4.f) ) ); }
vsVector2D operator-(const vsVector2D &vec) { return vsVector2D(-vec.x,-vec.y); }
void Init() { SetFOV( (float)vsScreen::Instance()->GetHeight() ); SetPosition( vsVector2D( vsScreen::Instance()->GetWidth() * 0.5f, vsScreen::Instance()->GetHeight() * 0.5f ) ); }
void vsRenderPipelineStageBloom::PreparePipeline( vsRenderPipeline *pipeline ) { RenderTargetRequest req; req.type = RenderTargetRequest::Type_MipmapLevel; req.depth = false; req.stencil = false; req.linear = true; req.mipmaps = false; req.antialias = false; req.share = true; for ( int i = 0; i < m_passCount; i++ ) { req.mipmapLevel = i; m_passes[i].m_pass = pipeline->RequestRenderTarget(req, this); m_passes[i].m_pass2 = pipeline->RequestRenderTarget(req, this); } if ( !kernel_normalised ) { // Normalize kernel coefficients float sum = 0; for (int c = 0; c < KERNEL_SIZE; c++) sum += kernel[c]; for (int c = 0; c < KERNEL_SIZE; c++) kernel[c] *= (1.f / sum); kernel_normalised = true; } m_hipassMaterial = new vsDynamicMaterial; m_hipassMaterial->SetBlend(false); m_hipassMaterial->SetDrawMode(DrawMode_Absolute); m_hipassMaterial->SetColor(c_white); m_hipassMaterial->SetCullingType(Cull_None); m_hipassMaterial->SetZRead(false); m_hipassMaterial->SetZWrite(false); m_hipassMaterial->SetGlow(false); m_hipassMaterial->SetTexture(0, m_from->GetTexture(1)); m_hipassMaterial->SetShader(new vsShader(passv, normalf, false, false)); m_bloomBlurShader = new vsBloomBlurShader(); for ( int i = 0; i < m_passCount; i++ ) { float offsetx = 1.2f / m_passes[i].m_pass->GetWidth(); float offsety = 1.2f / m_passes[i].m_pass->GetHeight(); m_passes[i].m_horizontalBlurMaterial = new vsDynamicMaterial; m_passes[i].m_horizontalBlurMaterial->SetClampU(true); m_passes[i].m_horizontalBlurMaterial->SetClampV(true); m_passes[i].m_horizontalBlurMaterial->SetBlend(false); m_passes[i].m_horizontalBlurMaterial->SetTexture(0,m_passes[i].m_pass->GetTexture()); m_passes[i].m_horizontalBlurMaterial->SetShader(m_bloomBlurShader); m_passes[i].m_horizontalBlurMaterial->GetResource()->m_shaderIsMine = false; m_passes[i].m_horizontalBlurMaterial->SetUniformF("offsetx", offsetx); m_passes[i].m_horizontalBlurMaterial->SetUniformF("offsety", 0.f); m_passes[i].m_verticalBlurMaterial = new vsDynamicMaterial; m_passes[i].m_verticalBlurMaterial->SetClampU(true); m_passes[i].m_verticalBlurMaterial->SetClampV(true); m_passes[i].m_verticalBlurMaterial->SetBlend(false); m_passes[i].m_verticalBlurMaterial->SetTexture(0,m_passes[i].m_pass2->GetTexture()); m_passes[i].m_verticalBlurMaterial->SetShader(m_bloomBlurShader); m_passes[i].m_verticalBlurMaterial->GetResource()->m_shaderIsMine = false; m_passes[i].m_verticalBlurMaterial->SetUniformF("offsetx", 0.f); m_passes[i].m_verticalBlurMaterial->SetUniformF("offsety", offsety); m_passes[i].m_combinePassMaterial = new vsDynamicMaterial; m_passes[i].m_combinePassMaterial->SetBlend(true); m_passes[i].m_combinePassMaterial->SetColor(c_white); m_passes[i].m_combinePassMaterial->SetCullingType(Cull_None); m_passes[i].m_combinePassMaterial->SetZRead(false); m_passes[i].m_combinePassMaterial->SetZWrite(false); m_passes[i].m_combinePassMaterial->SetDrawMode(DrawMode_Add); m_passes[i].m_combinePassMaterial->SetGlow(false); m_passes[i].m_combinePassMaterial->SetClampU(true); m_passes[i].m_combinePassMaterial->SetClampV(true); m_passes[i].m_combinePassMaterial->SetTexture(0, m_passes[i].m_pass->GetTexture()); m_passes[i].m_combinePassMaterial->SetShader(new vsBloomCombineShader); } m_fromMaterial = new vsDynamicMaterial; m_fromMaterial->SetBlend(false); m_fromMaterial->SetColor(c_white); m_fromMaterial->SetCullingType(Cull_None); m_fromMaterial->SetZRead(false); m_fromMaterial->SetZWrite(false); m_fromMaterial->SetGlow(false); m_fromMaterial->SetClampU(true); m_fromMaterial->SetClampV(true); m_fromMaterial->SetTexture(0, m_from->GetTexture()); m_fromMaterial->SetShader(new vsBloomPassShader); m_vertices = new vsRenderBuffer(vsRenderBuffer::Type_Static); m_indices = new vsRenderBuffer(vsRenderBuffer::Type_Static); float ar = vsScreen::Instance()->GetAspectRatio(); vsVector3D v[4] = { vsVector3D(-ar,-1.f,0.f), vsVector3D(-ar,1.f,0.f), vsVector3D(ar,-1.f,0.f), vsVector3D(ar,1.f,0.f) }; vsVector2D t[4] = { vsVector2D(0.f,1.f), vsVector2D(0.f,0.f), vsVector2D(1.f,1.f), vsVector2D(1.f,0.f) }; uint16_t ind[4] = { 0, 1, 2, 3 }; vsRenderBuffer::PT pt[4]; for ( int i = 0; i < 4; i++ ) { pt[i].position = v[i]; pt[i].texel = t[i]; } m_vertices->SetArray(pt,4); m_indices->SetArray(ind,4); }
} } #define W (0.5f) #define W2 (W * 0.5f) #define H (-0.25f) #define H2 (2.0f * H) #define H3 (3.0f * H) vsVector2D baseline(0.f,-H); // The points. vsVector2D P [24] = { vsVector2D::Zero, vsVector2D(-W,H3), vsVector2D(0,H3), vsVector2D(W,H3), vsVector2D(-W,H2), vsVector2D(0,H2), vsVector2D(W,H2), vsVector2D(-W,H), vsVector2D(0,H), vsVector2D(W,H), vsVector2D(-W,0), vsVector2D(0,0), vsVector2D(W,0), vsVector2D(-W,-H), vsVector2D(0,-H), vsVector2D(W,-H), vsVector2D(-W,-H2), vsVector2D(0,-H2), vsVector2D(W,-H2), vsVector2D(-W,-H3), vsVector2D(0,-H3), vsVector2D(W,-H3), vsVector2D(-W2,-H3), vsVector2D(W2,-H3) }; // Vector strokes (indexed into P). static int st_nick53[56][15] = { /* A */ { 13,4,2,6,15,0,10,6,-1 }, /* B */ { 13,1,2,6,8,12,14,13,-1 }, /* C */ { 12,14,10,4,2,6,-1 }, /* D */ { 13,1,2,6,12,14,13,-1 },
void rpModeCredits::Update( float timeStep ) { int activeLines = 0; for ( int i = 0; i < MAX_CREDIT_LINES; i++ ) { if ( m_lineUsed[i] ) activeLines++; } const float c_creditsScrollSpeed = 50.0f; // 50 'units' per second const float c_creditLineSpacing = 50.0f; float top = vsSystem::GetScreen()->GetScene(1)->GetTopLeftCorner().y - 50.0f; m_creditsPos += (timeStep * c_creditsScrollSpeed); for ( int i = 0; i < MAX_CREDIT_LINES; i++ ) { if ( m_lineUsed[i] ) { float yCoord = m_lineId[i] * c_creditLineSpacing; yCoord -= m_creditsPos; if ( m_creditsDone && m_lineId[i] == m_lineCount-1 && yCoord < top ) m_fadingOut = true; if ( m_creditsDone && m_lineId[i] == m_lineCount-1 ) // last line yCoord = vsMax( yCoord, 0.f ); // last line doesn't go past halfway. if ( yCoord < top ) LoadLine(i); else m_line[i]->SetPosition( vsVector2D(0.f, yCoord) ); } else if ( !m_creditsDone ) LoadLine(i); } if ( m_game->GetInput()->WasPressed(CID_A) ) m_fadingOut = true; if ( m_fadingOut ) { m_fadingTimer += timeStep; const float c_fadeDuration = 2.0f; float frac = m_fadingTimer / c_fadeDuration; vsColor c = vsColor::Black; if ( !m_inittedFade ) { //m_game->FadeOutMusic( c_fadeDuration ); m_inittedFade = true; } if ( frac < 1.0f ) { c = vsInterpolate( frac, vsColor::LightBlue, vsColor::Black ); for ( int i = 0; i < MAX_CREDIT_LINES; i++ ) { if ( m_lineUsed[i] ) { m_line[i]->SetColor(c); } } } else { return core::SetExit(); } } }
void vsRenderQueue::InitialiseTransformStack() { if ( m_parent->Is3D() ) { vsTransform3D startingTransform; switch( vsSystem::Instance()->GetOrientation() ) { case Orientation_Normal: break; case Orientation_Six: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(180.f) ) ); break; case Orientation_Three: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(270.f) ) ); break; case Orientation_Nine: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(90.f) ) ); break; } vsMatrix4x4 startingMatrix = startingTransform.GetMatrix(); vsMatrix4x4 requestedMatrix = vsMatrix4x4::Identity; requestedMatrix.w -= m_parent->GetCamera3D()->GetPosition(); // vsMatrix4x4 myIdentity; myIdentity.x *= -1.f; // vsMatrix4x4 cameraMatrix = m_parent->GetCamera3D()->GetTransform().GetMatrix(); vsVector3D forward = cameraMatrix.z; vsVector3D up = cameraMatrix.y; vsVector3D side = forward.Cross(up); cameraMatrix.x = side; cameraMatrix.y = up; cameraMatrix.z = forward; cameraMatrix.w.Set(0.f,0.f,0.f,1.f); cameraMatrix.Invert(); // vsMatrix4x4 cameraMatrix = m_parent->GetCamera3D()->GetTransform().GetMatrix(); // cameraMatrix.Invert(); cameraMatrix = startingMatrix * myIdentity * cameraMatrix; m_worldToView = cameraMatrix * requestedMatrix; m_transformStack[0] = vsMatrix4x4::Identity; m_transformStackLevel = 1; } else { vsTransform3D startingTransform; switch( vsSystem::Instance()->GetOrientation() ) { case Orientation_Normal: break; case Orientation_Six: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(180.f) ) ); break; case Orientation_Three: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(90.f) ) ); break; case Orientation_Nine: startingTransform.SetRotation ( vsQuaternion( vsVector3D::ZAxis, DEGREES(270.f) ) ); break; } // // startingTransform.SetTranslation( vsVector3D(0.f, 0.0f, 0.f) ); vsMatrix4x4 startingMatrix = startingTransform.GetMatrix(); vsTransform2D cameraTransform = m_parent->GetCamera()->GetCameraTransform(); // cameraMatrix will have a scale on its members from the camera. (Since // that's where it stores the FOV). // We remove that, since that eventually becomes part of the PROJECTION // transform, not the MODELVIEW transform, which is all we care about here.. cameraTransform.SetScale(vsVector2D(1.f,1.f)); vsMatrix4x4 cameraMatrix = cameraTransform.GetMatrix(); cameraMatrix.Invert(); m_worldToView = cameraMatrix * startingMatrix; m_transformStack[0] = vsMatrix4x4::Identity; m_transformStackLevel = 1; } }
vsVector2D fsRecord::Vector2D() { vsAssert( m_argCount >= 2, "Wrong number of arguments supplied for Vector2D" ); return vsVector2D( GetArg(0), GetArg(1) ); }