void MedievalTorch::Start(VideoPtr video, InputPtr input, AudioPtr audio) { this->video = video; this->input = input; this->audio = audio; m_props.ambient = Vector3(1,1,1); Platform::FileManagerPtr fileManager = video->GetFileManager(); m_provider = ETHResourceProviderPtr(new ETHResourceProvider( ETHGraphicResourceManagerPtr(new ETHGraphicResourceManager()), ETHAudioResourceManagerPtr(new ETHAudioResourceManager()), boost::shared_ptr<ETHShaderManager>(new ETHShaderManager(video, GS_L("assets/data/"))), GS_L("assets/"), video, audio, input)); const Vector2 screenSize = video->GetScreenSizeF(); const float TARGET_WIDTH = 480/4; const float TARGET_HEIGHT = 854/4; if (pTorch) pTorch->Release(); pTorch = new ETHRenderEntity(GS_L("assets/entities/medieval_torch.ent"), m_provider); pTorch->SetOrphanPositionXY(Vector2(TARGET_WIDTH / 2.0f, TARGET_HEIGHT - (TARGET_HEIGHT / 10.0f))); pTorch->ScaleParticleSystem(0, 1.6f); pTorch->ScaleParticleSystem(0, screenSize.x / 480.0f / 4); renderTarget = video->CreateRenderTarget(static_cast<unsigned int>(TARGET_WIDTH), static_cast<unsigned int>(TARGET_HEIGHT), GSTF_DEFAULT); }
gs2d::math::Vector2 ETHParallaxManager::ComputeOffset( const VideoPtr& video, const Vector3 &pos, const float& individualParallaxIntensity) const { const Vector2 screenSpacePos = Vector2(pos.x, pos.y) - video->GetCameraPos(); return ((screenSpacePos - GetInScreenOrigin(video)) / video->GetScreenSizeF().x) * pos.z * m_intensity * individualParallaxIntensity; }
static void DrawSplashScreen() { video->BeginSpriteScene(gs2d::constant::BLACK); if (splashSprite) { splashSprite->SetOrigin(gs2d::Sprite::EO_CENTER); const Vector2 screenSize(video->GetScreenSizeF()); const float scale = ComputeSplashScale(screenSize); splashSprite->Draw(screenSize * 0.5f, gs2d::constant::WHITE, 0.0f, Vector2(scale, scale)); } video->EndSpriteScene(); }
inline bool IsInArea(const gs2d::math::Vector2& pos, const gs2d::math::Rect2Df& area, const gs2d::math::Vector2& origin, VideoPtr video) { const gs2d::math::Vector2 offset = area.size * origin * -1.0f; float tmp1 = video->GetScreenSizeF().y - area.pos.y + offset.y - area.size.y / 2; float tmp2 = video->GetScreenSizeF().y - area.pos.y + area.size.y + offset.y - area.size.y / 2; if (pos.x < area.pos.x + offset.x || pos.x > area.pos.x + area.size.x + offset.x || pos.y < area.pos.y + offset.y || pos.y > area.pos.y + area.size.y + offset.y) { return false; } else { return true; } }
Vector3 ETHFakeEyePositionManager::ComputeFakeEyePosition( VideoPtr video, ShaderPtr pShader, const bool drawToTarget, const Vector3 &v3LightPos, const float entityAngle) { const Vector2 &v2CamPos(video->GetCameraPos()); const Vector2 &v2ScreenDim(video->GetScreenSizeF()); Vector3 v3RelativeEyePos(0, v2ScreenDim.y*1.5f, GetFakeEyeHeight()); if (!drawToTarget) v3RelativeEyePos.y -= v3LightPos.y-v2CamPos.y; Matrix4x4 matRot = RotateZ(-DegreeToRadian(entityAngle)); v3RelativeEyePos = Multiply(v3RelativeEyePos, matRot); //pShader->SetConstant(GS_L("fakeEyePos"), v3RelativeEyePos+Vector3(0, v2CamPos.y, 0)+Vector3(v3LightPos.x,0,0)); return v3RelativeEyePos+Vector3(0, v2CamPos.y, 0)+Vector3(v3LightPos.x,0,0); }
bool IsSphereInScreen(const Vector3& pos, const float radius, const Vector2& zAxisDir, const VideoPtr& video) { const Vector2 v2Pos(ToScreenPos(pos, zAxisDir)); const Vector2& v2Cam = video->GetCameraPos(); const Vector2& v2Screen = video->GetScreenSizeF(); const float minX = v2Cam.x - radius; const float maxX = v2Cam.x + v2Screen.x + radius; const float minY = v2Cam.y - radius; const float maxY = v2Cam.y + v2Screen.y + radius; if (v2Pos.x < minX || v2Pos.x > maxX || v2Pos.y < minY || v2Pos.y > maxY) { return false; } else { return true; } }
void CustomDataEditor::InputVariableName(ETHEntity* pEntity, EditorBase *pEditor) { VideoPtr video = pEditor->GetVideoHandler(); const Vector2 v2Pos = video->GetScreenSizeF()/2.0f - Vector2(m_inVariableName.GetWidth()/2.0f, 0.0f); if (m_inVariableName.IsActive()) { DrawInputFieldRect(v2Pos, &m_inVariableName, pEditor, GS_L("Enter variable name")); m_inVariableName.PlaceInput(v2Pos); str_type::stringstream ss; ss << ETHCustomDataManager::GetDataName(m_cdesState); pEditor->ShadowPrint(v2Pos-Vector2(0.0f,m_inVariableName.GetSize()), ss.str().c_str(), GS_L("Verdana14_shadow.fnt"), gs2d::constant::BLACK); // if it has just been unactivated if (!m_inVariableName.IsActive()) { if (m_inVariableName.GetValue() != GS_L("")) { switch (m_cdesState) { case CDES_ADDING_INT: pEntity->SetInt(m_inVariableName.GetValue(), 0); break; case CDES_ADDING_UINT: pEntity->SetUInt(m_inVariableName.GetValue(), 0); break; case CDES_ADDING_FLOAT: pEntity->SetFloat(m_inVariableName.GetValue(), 0.0f); break; case CDES_ADDING_STRING: pEntity->SetString(m_inVariableName.GetValue(), GS_L("none")); break; default: break; } Rebuild(pEntity, pEditor); } m_cdesState = CDES_IDLE; } } }
void CustomDataEditor::EditVariable(ETHEntity* pEntity, EditorBase *pEditor) { if (m_cdesState != CDES_IDLE) return; VideoPtr video = pEditor->GetVideoHandler(); InputPtr input = pEditor->GetInputHandler(); GSGUI_BUTTON r = m_customDataButtonList.GetFirstActiveButton(); if (m_lastData != r.text || pEntity->GetID() != m_lastEntityID) { m_inValueInput.SetupMenu( video, input, pEditor->GetMenuSize(), pEditor->GetMenuWidth()*4.0f, 144, false, pEntity->GetCustomDataManager()->GetValueAsString(r.text) ); m_lastData = r.text; m_lastEntityID = pEntity->GetID(); } if (r.text != GS_L("")) { m_inValueInput.SetActive(true); const Vector2 v2Pos = video->GetScreenSizeF()/2.0f - Vector2(m_inValueInput.GetWidth()/2.0f, 0.0f); DrawInputFieldRect(v2Pos, &m_inValueInput, pEditor, GS_L("Leave blank to erase variable")); const ETHCustomData::DATA_TYPE type = pEntity->CheckCustomData(r.text); switch (type) { case ETHCustomData::DT_INT: pEntity->SetInt(r.text, ETHGlobal::ParseInt(m_inValueInput.PlaceInput(v2Pos).c_str())); break; case ETHCustomData::DT_UINT: pEntity->SetUInt(r.text, ETHGlobal::ParseUInt(m_inValueInput.PlaceInput(v2Pos).c_str())); break; case ETHCustomData::DT_STRING: pEntity->SetString(r.text, m_inValueInput.PlaceInput(v2Pos)); break; case ETHCustomData::DT_FLOAT: pEntity->SetFloat(r.text, ETHGlobal::ParseFloat(m_inValueInput.PlaceInput(v2Pos).c_str())); break; default: break; }; str_type::stringstream ss; ss << ETHCustomDataManager::GetDataName(type) << GS_L(" ") << r.text << GS_L(":"); pEditor->ShadowPrint(v2Pos-Vector2(0.0f,m_inValueInput.GetSize()), ss.str().c_str(), GS_L("Verdana14_shadow.fnt"), gs2d::constant::BLACK); } else { Rebuild(pEntity, pEditor); } if (!m_inValueInput.IsActive()) { if (m_inValueInput.GetValue() == GS_L("")) { pEntity->EraseData(r.text); Rebuild(pEntity, pEditor); } m_customDataButtonList.DeactivateButton(r.text); } }