bool ETHScene::LoadFromFile(const str_type::string& fileName) { Platform::FileManagerPtr fileManager = m_provider->GetFileManager(); if (!fileManager->FileExists(fileName)) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file not found (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } m_minSceneHeight = 0.0f; m_maxSceneHeight = m_provider->GetVideo()->GetScreenSizeF().y; // Read the header and check if the file is valid TiXmlDocument doc(fileName); str_type::string content; fileManager->GetUTF16FileString(fileName, content); if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY)) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file found, but parsing failed (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } TiXmlHandle hDoc(&doc); TiXmlHandle hRoot(0); TiXmlElement *pElement = hDoc.FirstChildElement().Element(); if (!pElement) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: couldn't find root element (") << fileName << GS_L(")"); m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } return ReadFromXMLFile(pElement); }
ETHPixelLightDiffuseSpecular::ETHPixelLightDiffuseSpecular(VideoPtr video, const str_type::string& shaderPath, ETHFakeEyePositionManagerPtr fakeEyeManager) : m_fakeEyeManager(fakeEyeManager) { m_video = video; if (IsSupportedByHardware()) { m_hPixelLightPS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_PS_Hor_Diff()).c_str(), GSSF_PIXEL, m_profile); m_vPixelLightPS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_PS_Ver_Diff()).c_str(), GSSF_PIXEL, m_profile); m_hPixelLightVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_VS_Hor_Light()).c_str(), GSSF_VERTEX, GSSP_MODEL_2); m_vPixelLightVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_VS_Ver_Light()).c_str(), GSSF_VERTEX, GSSP_MODEL_2); m_hPixelLightSpecularPS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_PS_Hor_Spec()).c_str(), GSSF_PIXEL, m_profile); m_vPixelLightSpecularPS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::PL_PS_Ver_Spec()).c_str(), GSSF_PIXEL, m_profile); m_defaultNM = m_video->CreateSprite(ETHGlobal::GetDataResourceFullPath(shaderPath, GS_L("default_nm.png"))); } }
gs2d::str_type::string AddLastSlash(const gs2d::str_type::string& path) { if (path.empty()) { return GS_L(""); } gs2d::str_type::string r = (path); FixSlashes(r); const std::size_t lastChar = r.size()-1; if (r.at(lastChar) == GS_L('\\')) { r[lastChar] = GS_L('/'); return r; } else if (r.at(lastChar) != GS_L('/')) { return r + GS_L("/"); } else { return r; } }
int ETHScriptWrapper::AddEntity(const str_type::string &file, const Vector3 &v3Pos, const float angle, ETHEntity **ppOutEntity, const str_type::string &alternativeName, const float scale) { if (WarnIfRunsInMainFunction(GS_L("AddEntity"))) return -1; const ETHEntityProperties* props = m_entityCache.Get(file, m_provider->GetResourcePath() + ETHDirectories::GetEntityPath(), m_provider->GetVideo()->GetFileManager()); if (!props) { return -1; } const float globalScale = m_provider->GetGlobalScaleManager()->GetScale(); ETHRenderEntity* entity = new ETHRenderEntity(m_provider, *props, angle, scale * globalScale); entity->SetOrphanPosition(v3Pos); entity->SetAngle(angle); if (entity->IsStatic() && entity->IsApplyLight()) { str_type::stringstream ss; ss << GS_L("AddEntity - This is a static entity and its lightmap has not been rendered yet. ") << GS_L("It might be incorrectly lit: ") << m_provider->GetResourcePath() << ETHDirectories::GetEntityPath() << file; ShowMessage(ss.str(), ETH_WARNING); } if (ppOutEntity) { entity->AddRef(); *ppOutEntity = entity; } return m_pScene->AddEntity(entity, alternativeName); }
gs2d::SpritePtr ETHGraphicResourceManager::FindSprite( const str_type::string& fullFilePath, const str_type::string& fileName, const str_type::string& resourceDirectory) { std::map<str_type::string, SpriteResource>::iterator iter = m_resource.find(fileName); if (iter != m_resource.end()) { str_type::string fixedPath(fullFilePath); Platform::FixSlashes(fixedPath); const SpriteResource& resource = iter->second; if (RemoveResourceDirectory(resourceDirectory, fixedPath) != resource.m_fullOriginPath) { str_type::stringstream ss; ss << GS_L("Duplicate resource name found: ") << fixedPath << GS_L(" <-> ") << resource.m_fullOriginPath; ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR); } return resource.m_sprite; } else { return SpritePtr(); } }
int FindCallbackFunction(asIScriptModule* pModule, const ETHScriptEntity* entity, const str_type::string& prefix, const Platform::Logger& logger) { const str_type::string entityName = Platform::RemoveExtension(entity->GetEntityName().c_str()); str_type::stringstream funcName; funcName << prefix << entityName; const int id = CScriptBuilder::GetFunctionIdByName(pModule, funcName.str()); if (id == asMULTIPLE_FUNCTIONS) { str_type::stringstream ss; ss << GS_L("ETHScene::FindCallbackFunction: found multiple functions named (") << funcName.str() << GS_L(")."); logger.Log(ss.str(), Platform::FileLogger::ERROR); } return id; }
void ETHEntityProperties::Reset() { ETHEntityMaterial::Reset(); entityName = GS_L(""); spriteCut = ETH_DEFAULT_SPRITE_CUT; pivotAdjust = ETH_DEFAULT_PIVOT_ADJUST; scale = ETH_DEFAULT_SCALE; staticEntity = ETH_FALSE; hideFromSceneEditor = ETH_FALSE; type = ET_HORIZONTAL; layerDepth = 0.0f; successfullyLoaded = false; soundVolume = ETH_DEFAULT_SOUND_VOLUME; parallaxIntensity = ETH_DEFAULT_PARALLAX_INTENS; shape = BS_NONE; }
bool ETH_COLLISION_BOX::ReadFromXMLFile(TiXmlElement *pElement) { TiXmlElement *pIter; pIter = pElement->FirstChild(GS_L("Position"))->ToElement(); if (pIter) { pIter->QueryFloatAttribute(GS_L("x"), &pos.x); pIter->QueryFloatAttribute(GS_L("y"), &pos.y); pIter->QueryFloatAttribute(GS_L("z"), &pos.z); } pIter = pElement->FirstChild(GS_L("Size"))->ToElement(); if (pIter) { pIter->QueryFloatAttribute(GS_L("x"), &size.x); pIter->QueryFloatAttribute(GS_L("y"), &size.y); pIter->QueryFloatAttribute(GS_L("z"), &size.z); } return true; }
/////////////////////////////////////////////////////////////// // Float input /////////////////////////////////////////////////////////////// GSGUI_FLOAT_INPUT::GSGUI_FLOAT_INPUT() { //m_video = 0; //m_input = 0; m_size = 14.0f; m_width = 256.0f; m_active = false; m_strInput.NumbersOnly(true); m_strInput.SetString(GS_L("0.0")); m_text.clear(); m_nMaxChars = 8; m_min = 0.0f; m_max = 0.0f; m_clamp = false; m_scrollAdd = 0.1f; m_mouseOver = false; m_active = false; }
bool ETHShaderManager::BeginAmbientPass(const ETHSpriteEntity *pRender, const float maxHeight, const float minHeight) { m_video->SetPixelShader(ShaderPtr()); if (pRender->GetType() == ETH_VERTICAL) { m_verticalStaticAmbientVS->SetConstant(GS_L("spaceLength"), (maxHeight-minHeight)); m_video->SetVertexShader(m_verticalStaticAmbientVS); } else { m_video->SetVertexShader(m_defaultStaticAmbientVS); } m_parallaxManager.SetShaderParameters(m_video, m_video->GetVertexShader(), pRender->GetPosition(), false); m_lastAM = m_video->GetAlphaMode(); return true; }
bool ETHEntity::IsTemporary() const { unsigned int temporary = 0, existent = 0; for (std::size_t t=0; t<m_properties.particleSystems.size(); t++) { if (m_properties.particleSystems[t]->nParticles > 0) { if (m_properties.particleSystems[t]->repeat > 0) temporary++; existent++; } } if (existent && temporary == existent && m_properties.spriteFile == GS_L("")) { return true; } return false; }
const gs2d::str_type::string ETHPolygon::GetENMLDeclaration() const { gs2d::str_type::stringstream ss; if (!IsValid()) ss << GS_L("/* warning: invalid polygon */ "); for (std::size_t t = 0; t < m_vertices.size(); t++) { ss << GS_L("v") << t << GS_L("{") << GS_L("x=") << m_vertices[t].x << GS_L(";y=") << m_vertices[t].y << GS_L(";} "); } return ss.str(); }
bool ETHBinaryStream::OpenW(const str_type::string& fileName) { CloseW(); SetFileName(fileName); #ifdef WIN32 errno_t error = fopen_s(&m_out, GetFileName().c_str(), GS_L("wb")); #else int error = 0; m_out = fopen(GetFileName().c_str(), "wb"); #endif if (!error && m_out) { return true; } else { m_out = 0; return false; } }
bool ETHScene::SaveToFile(const str_type::string& fileName) { if (m_buckets.IsEmpty()) { ETH_STREAM_DECL(ss) << GS_L("ETHScene::Save: there are no entities to save: ") << fileName; m_provider->Log(ss.str(), Platform::FileLogger::ERROR); return false; } // Write the header to the file TiXmlDocument doc; TiXmlDeclaration *pDecl = new TiXmlDeclaration(GS_L("1.0"), GS_L(""), GS_L("")); doc.LinkEndChild(pDecl); TiXmlElement *pElement = new TiXmlElement(GS_L("Ethanon")); doc.LinkEndChild(pElement); TiXmlElement *pRoot = doc.RootElement(); // write the property header m_sceneProps.WriteToXMLFile(pRoot); // start writing entities TiXmlElement *pEntities = new TiXmlElement(GS_L("EntitiesInScene")); pRoot->LinkEndChild(pEntities); // Write every entity for (ETHBucketMap::iterator bucketIter = m_buckets.GetFirstBucket(); bucketIter != m_buckets.GetLastBucket(); ++bucketIter) { ETHEntityList::const_iterator iEnd = bucketIter->second.end(); for (ETHEntityList::iterator iter = bucketIter->second.begin(); iter != iEnd; ++iter) { (*iter)->WriteToXMLFile(pEntities); #if defined(_DEBUG) || defined(DEBUG) ETH_STREAM_DECL(ss) << GS_L("Entity written to file: ") << (*iter)->GetEntityName(); m_provider->Log(ss.str(), Platform::FileLogger::INFO); #endif } } doc.SaveFile(fileName); #ifdef GS2D_STR_TYPE_ANSI m_provider->GetFileManager()->ConvertAnsiFileToUTF16LE(fileName); #endif return true; }
ETHShaderManager::ETHShaderManager(VideoPtr video, const str_type::string& shaderPath) : m_lastAM(GSAM_PIXEL), m_fakeEyeManager(new ETHFakeEyePositionManager) { m_video = video; m_defaultVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::DefaultVS()).c_str(), GSSF_VERTEX, GSSP_MODEL_2); m_particle = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::Particle_VS()).c_str(), GSSF_VERTEX, GSSP_MODEL_2, "particle"); m_defaultStaticAmbientVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::Ambient_VS_Hor()).c_str(), GSSF_VERTEX, GSSP_MODEL_2); m_verticalStaticAmbientVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::Ambient_VS_Ver()).c_str(), GSSF_VERTEX, GSSP_MODEL_2, "vertical"); m_shadowVS = m_video->LoadShaderFromFile(ETHGlobal::GetDataResourceFullPath(shaderPath, ETHShaders::Shadow_VS_Ver()).c_str(), GSSF_VERTEX, GSSP_MODEL_2); // TODO/TO-DO: use a wider macro here #ifndef ANDROID m_projShadow = m_video->CreateSprite(ETHGlobal::GetDataResourceFullPath(shaderPath, GS_L("shadow.dds"))); #else m_projShadow = m_video->CreateSprite(ETHGlobal::GetDataResourceFullPath(shaderPath, GS_L("shadow.png"))); #endif { ETHLightingProfilePtr profile(new ETHVertexLightDiffuse(m_video, shaderPath)); if (profile->IsSupportedByHardware()) { m_lightingProfiles[VERTEX_LIGHTING_DIFFUSE] = profile; } } { ETHLightingProfilePtr profile(new ETHPixelLightDiffuseSpecular(m_video, shaderPath, m_fakeEyeManager)); if (profile->IsSupportedByHardware()) { m_lightingProfiles[PIXEL_LIGHTING_DIFFUSE_SPECULAR] = profile; } } if (m_lightingProfiles.empty()) { video->Message(GS_L("ETHShaderManager::ETHShaderManager: no lighting profile"), GSMT_WARNING); } else { m_currentProfile = FindHighestLightingProfile(); } }
bool GLVideo::SetRenderTarget(SpritePtr pTarget, const unsigned int target) { if (!pTarget) { m_currentTarget.reset(); UnbindFrameBuffer(); } else { if (pTarget->GetType() == Sprite::T_TARGET) { m_currentTarget = pTarget->GetTexture(); } else { Message(GS_L("The current sprite has no render target texture"), GSMT_ERROR); } } return true; }
ETHParticleManager::ETHParticleManager( ETHResourceProviderPtr provider, const str_type::string& file, const Vector2& v2Pos, const Vector3& v3Pos, const float angle, const float entityVolume) : m_provider(provider) { ETHParticleSystem partSystem; if (partSystem.ReadFromFile(file, m_provider->GetFileManager())) { CreateParticleSystem(partSystem, v2Pos, v3Pos, angle, entityVolume, 1.0f); } else { ETH_STREAM_DECL(ss) << GS_L("ETHParticleManager: file not found: ") << file; m_provider->Log(ss.str(), Platform::FileLogger::ERROR); } }
void ParticleEditor::SetupMenu() { m_fileMenu.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), GS_L("Menu"), m_menuSize*m_menuScale, m_menuWidth*2, true); m_fileMenu.AddButton(SAVE_SYSTEM); m_fileMenu.AddButton(SAVE_SYSTEM_AS); m_fileMenu.AddButton(OPEN_SYSTEM); m_fileMenu.AddButton(LOAD_BMP); m_fileMenu.AddButton(LOAD_BG); m_fileMenu.AddButton(_S_GOTO_PROJ); m_alphaModes.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth*2, true, false, false); m_alphaModes.AddButton(ALPHA_MODE_PIXEL, true); m_alphaModes.AddButton(ALPHA_MODE_ADD, false); m_alphaModes.AddButton(ALPHA_MODE_MODULATE, false); m_animationModes.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth*2, true, false, false); m_animationModes.AddButton(ANIMATION_MODE_ANIMATE, true); m_animationModes.AddButton(ANIMATION_MODE_PICK, false); SetMenuConstants(); }
bool ETHVertexLightDiffuse::BeginLightPass(ETHSpriteEntity *pRender, Vector3 &v3LightPos, const Vector2 &v2Size, const ETHLight* light, const float maxHeight, const float minHeight, const float lightIntensity, const bool drawToTarget) { GS2D_UNUSED_ARGUMENT(drawToTarget); const Vector2 &v2Origin = pRender->ComputeOrigin(v2Size); const Vector3 &v3EntityPos = pRender->GetPosition(); m_video->SetPixelShader(ShaderPtr()); ShaderPtr pLightShader; if (pRender->GetType() == ETH_VERTICAL) { m_vVertexLightVS->SetConstant(GS_L("spaceLength"), (maxHeight-minHeight)); m_vVertexLightVS->SetConstant(GS_L("topLeft3DPos"), v3EntityPos-(Vector3(v2Origin.x, 0, -v2Origin.y))); pLightShader = m_vVertexLightVS; } else { m_hVertexLightVS->SetConstant(GS_L("topLeft3DPos"), v3EntityPos-Vector3(v2Origin, 0)); pLightShader = m_hVertexLightVS; } m_video->SetVertexShader(pLightShader); m_lastAM = m_video->GetAlphaMode(); m_video->SetAlphaMode(GSAM_ADD); // Set a depth value depending on the entity type pRender->SetDepth(maxHeight, minHeight); pLightShader->SetConstant(GS_L("pivotAdjust"), pRender->GetProperties()->pivotAdjust); pLightShader->SetConstant(GS_L("lightPos"), v3LightPos); pLightShader->SetConstant(GS_L("lightRange"), light->range); pLightShader->SetConstant(GS_L("lightColor"), light->color); pLightShader->SetConstant(GS_L("lightIntensity"), lightIntensity); return true; }
ETHEntity *ETHScriptWrapper::SeekEntity(const int id) { if (WarnIfRunsInMainFunction(GS_L("SeekEntity"))) return 0; ETHEntity *pEntity = m_pScene->GetBucketManager().SeekEntity(id); if (pEntity) { // don't let it return temporary handles if (pEntity->IsTemporary()) { return 0; } else { pEntity->AddRef(); return pEntity; } } return 0; }
void ETHParticleSystem::Reset() { alphaMode = Video::AM_PIXEL; nParticles = 0; lifeTime = 0.0f; randomizeLifeTime = 0.0f; size = 1.0f; growth = 0.0f; minSize = 0.0f; maxSize = 99999.0f; repeat = 0; randomizeSize = 0.0f; randAngleStart = 0.0f; angleStart = 0.0f; emissive = Vector3(1,1,1); allAtOnce = false; boundingSphere = 512.0f; soundFXFile = GS_L(""); bitmapFile = ETH_DEFAULT_PARTICLE_BITMAP; spriteCut = Vector2i(1,1); animationMode = PLAY_ANIMATION; }
str_type::string SDLInput::GetLastCharInput() const { if (SDLWindow::m_lastCharInput.length() == 1) { str_type::char_t c = SDLWindow::m_lastCharInput[0]; switch (c) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x0E: case 0x0F: case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x7F: return GS_L(""); } } return SDLWindow::m_lastCharInput; }
ETH_STARTUP_RESOURCES_ENML_FILE::ETH_STARTUP_RESOURCES_ENML_FILE(const str_type::string& fileName, const Platform::FileManagerPtr& fileManager) { emtprojFilename = GS_L(""); escFilename = GS_L(""); str_type::string out; fileManager->GetAnsiFileString(fileName, out); enml::File file(out); if (file.getError() == enml::enmlevSUCCESS) { emtprojFilename = file.get(GS_L("startup"), GS_L("project")); escFilename = file.get(GS_L("startup"), GS_L("scene")); } else { #ifdef GS2D_STR_TYPE_WCHAR std::wcerr #else std::cerr #endif << file.getErrorString() << std::endl; } }
void ParticleEditor::ParticlePanel() { std::string programPath = GetCurrentProjectPath(false); const VideoPtr& video = m_provider->GetVideo(); const InputPtr& input = m_provider->GetInput(); GSGUI_BUTTON file_r = m_fileMenu.PlaceMenu(Vector2(0,m_menuSize*2)); if (file_r.text == LOAD_BMP) { char path[___OUTPUT_LENGTH], file[___OUTPUT_LENGTH]; if (OpenParticleBMP(path, file)) { ETHGlobal::CopyFileToProject(programPath, path, ETHDirectories::GetParticlesDirectory(), m_provider->GetFileManager()); m_system.bitmapFile = file; m_provider->GetGraphicResourceManager()->ReleaseResource(m_system.bitmapFile); m_manager = ETHParticleManagerPtr( new ETHParticleManager(m_provider, m_system, m_v2Pos, Vector3(m_v2Pos, 0), m_systemAngle, 1.0f)); } } if (file_r.text == SAVE_SYSTEM) { if (m_untitled) SaveAs(); else Save(); } if (file_r.text == SAVE_SYSTEM_AS) { SaveAs(); } if (file_r.text == LOAD_BG) { char path[___OUTPUT_LENGTH], file[___OUTPUT_LENGTH]; if (OpenParticleBMP(path, file)) { m_backgroundSprite = video->CreateSprite(path); } } if (file_r.text == OPEN_SYSTEM) { m_systemAngle = 0.0f; char path[___OUTPUT_LENGTH], file[___OUTPUT_LENGTH]; if (OpenSystem(path, file)) { m_manager = ETHParticleManagerPtr( new ETHParticleManager(m_provider, path, m_v2Pos, Vector3(m_v2Pos, 0), m_systemAngle)); m_manager->SetZPosition(0.0f); m_manager->Kill(false); m_system = *m_manager->GetSystem(); SetMenuConstants(); SetCurrentFile(path); m_untitled = false; } } if (file_r.text == _S_GOTO_PROJ) { m_projManagerRequested = true; } if (input->GetKeyState(GSK_K) == GSKS_HIT) m_manager->Kill(!m_manager->Killed()); if (!m_fileMenu.IsActive()) { Vector2 v2ScreenDim = video->GetScreenSizeF(); float menu = m_menuSize*m_menuScale+(m_menuSize*2); // places the alpha mode menu ShadowPrint(Vector2(v2ScreenDim.x-m_alphaModes.GetWidth(), menu), GS_L("Alpha mode:"), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); menu += m_menuSize; m_alphaModes.PlaceMenu(Vector2(v2ScreenDim.x-m_alphaModes.GetWidth(), menu)); menu += m_alphaModes.GetNumButtons()*m_menuSize; // sets the alpha mode according to the selected item if (m_alphaModes.GetButtonStatus(ALPHA_MODE_PIXEL)) m_system.alphaMode = Video::AM_PIXEL; if (m_alphaModes.GetButtonStatus(ALPHA_MODE_ADD)) m_system.alphaMode = Video::AM_ADD; if (m_alphaModes.GetButtonStatus(ALPHA_MODE_MODULATE)) m_system.alphaMode = Video::AM_MODULATE; // places the sprite cut fields to the right menu += m_menuSize/2; ShadowPrint(Vector2(v2ScreenDim.x-m_alphaModes.GetWidth(), menu), GS_L("Sprite cut:"), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); menu += m_menuSize; m_system.spriteCut.x = Max(1, static_cast<int>(m_spriteCut[0].PlaceInput(Vector2(v2ScreenDim.x-m_alphaModes.GetWidth(),menu)))); menu += m_menuSize; m_system.spriteCut.y = Max(1, static_cast<int>(m_spriteCut[1].PlaceInput(Vector2(v2ScreenDim.x-m_alphaModes.GetWidth(),menu)))); menu += m_menuSize; // if there is sprite animation in the particle system, places the animation mode selector if (m_system.spriteCut.x > 1 || m_system.spriteCut.y > 1) { menu += m_menuSize/2; m_animationModes.PlaceMenu(Vector2(v2ScreenDim.x-m_animationModes.GetWidth(), menu)); menu += m_animationModes.GetNumButtons()*m_menuSize; if (m_animationModes.GetButtonStatus(ANIMATION_MODE_ANIMATE)) m_system.animationMode = ETHParticleSystem::PLAY_ANIMATION; if (m_animationModes.GetButtonStatus(ANIMATION_MODE_PICK)) m_system.animationMode = ETHParticleSystem::PICK_RANDOM_FRAME; } // inputs all data menu = m_menuSize*m_menuScale+(m_menuSize*2); menu += m_menuSize/2; ShadowPrint(Vector2(0.0f,menu), GS_L("Particles:"), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); int nParticles = m_particles.PlaceInput(Vector2(m_menuWidth,menu)); menu += m_menuSize; ShadowPrint(Vector2(0.0f,menu), GS_L("Repeats:"), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); m_system.repeat = m_repeats.PlaceInput(Vector2(m_menuWidth,menu)); menu += m_menuSize; menu += m_menuSize/2; if (nParticles != m_system.nParticles && nParticles > 0) { m_system.nParticles = nParticles; m_manager = ETHParticleManagerPtr( new ETHParticleManager(m_provider, m_system, m_v2Pos, Vector3(m_v2Pos, 0), m_systemAngle, 1.0f)); m_manager->Kill(false); } m_system.gravityVector.x = m_gravity[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.gravityVector.y = m_gravity[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.directionVector.x = m_direction[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.directionVector.y = m_direction[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randomizeDir.x = m_randDir[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randomizeDir.y = m_randDir[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.boundingSphere = m_boundingSphere.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.allAtOnce = (bool)(m_allAtOnce.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize) != 0); menu += m_menuSize; menu += m_menuSize/2; m_system.startPoint.x = m_startPoint[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.startPoint.y = m_startPoint[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.randStartPoint.x = m_randStart[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randStartPoint.y = m_randStart[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.color0.w = m_color0[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color0.x = m_color0[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color0.y = m_color0[2].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color0.z = m_color0[3].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.color1.w = m_color1[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color1.x = m_color1[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color1.y = m_color1[2].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.color1.z = m_color1[3].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.size = m_size.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.growth = m_growth.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randomizeSize = m_randSize.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.lifeTime = m_lifeTime.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randomizeLifeTime = m_randLifeTime.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.angleStart = m_angleStart.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.angleDir = m_angle.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randAngle = m_randAngle.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.randAngleStart = m_randAngleStart.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.minSize = m_minSize.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.maxSize = m_maxSize.PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_system.emissive.x = m_luminance[0].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.emissive.y = m_luminance[1].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; m_system.emissive.z = m_luminance[2].PlaceInput(Vector2(0.0f,menu), Vector2(0.0f, v2ScreenDim.y-m_menuSize), m_menuSize); menu += m_menuSize; menu += m_menuSize/2; m_manager->SetSystem(m_system); } }
void ParticleEditor::SetMenuConstants() { m_particles.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_particles.SetConstant(m_system.nParticles); m_particles.SetScrollAdd(1); m_particles.SetClamp(true, 0, 10000); m_particles.SetText(GS_L("Ptcles:")); m_repeats.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_repeats.SetScrollAdd(1); m_repeats.SetConstant(m_system.repeat); m_repeats.SetClamp(true, 0, 9999999); m_repeats.SetText(GS_L("Repeats:")); m_gravity[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_gravity[0].SetConstant(m_system.gravityVector.x); m_gravity[0].SetClamp(false, 0, 0); m_gravity[0].SetText(GS_L("Grav X:")); m_gravity[0].SetDescription(GS_L("Gravity vector")); m_gravity[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_gravity[1].SetConstant(m_system.gravityVector.y); m_gravity[1].SetClamp(false, 0, 0); m_gravity[1].SetText(GS_L("Grav Y:")); m_gravity[1].SetDescription(GS_L("Gravity vector")); m_direction[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_direction[0].SetConstant(m_system.directionVector.x); m_direction[0].SetClamp(false, 0, 0); m_direction[0].SetText(GS_L("Dir X:")); m_direction[0].SetDescription(GS_L("Particle direction")); m_direction[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_direction[1].SetConstant(m_system.directionVector.y); m_direction[1].SetClamp(false, 0, 0); m_direction[1].SetText(GS_L("Dir Y:")); m_direction[1].SetDescription(GS_L("Particle direction")); m_randDir[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randDir[0].SetConstant(m_system.randomizeDir.x); m_randDir[0].SetClamp(false, 0, 0); m_randDir[0].SetText(GS_L("R Dir X:")); m_randDir[0].SetDescription(GS_L("Particle direction randomizer")); m_randDir[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randDir[1].SetConstant(m_system.randomizeDir.y); m_randDir[1].SetClamp(false, 0, 0); m_randDir[1].SetText(GS_L("R Dir Y:")); m_randDir[1].SetDescription(GS_L("Particle direction randomizer")); m_startPoint[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_startPoint[0].SetConstant(m_system.startPoint.x); m_startPoint[0].SetClamp(false, 0, 0); m_startPoint[0].SetText(GS_L("Start X:")); m_startPoint[0].SetScrollAdd(1.0f); m_startPoint[0].SetDescription(GS_L("Particle starting position")); m_startPoint[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_startPoint[1].SetConstant(m_system.startPoint.y); m_startPoint[1].SetClamp(false, 0, 0); m_startPoint[1].SetText(GS_L("Start Y:")); m_startPoint[1].SetScrollAdd(1.0f); m_startPoint[1].SetDescription(GS_L("Particle starting position")); m_randStart[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randStart[0].SetConstant(m_system.randStartPoint.x); m_randStart[0].SetClamp(false, 0, 0); m_randStart[0].SetText(GS_L("R StartX:")); m_randStart[0].SetScrollAdd(1.0f); m_randStart[0].SetDescription(GS_L("Starting position randomizer")); m_randStart[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randStart[1].SetConstant(m_system.randStartPoint.y); m_randStart[1].SetClamp(false, 0, 0); m_randStart[1].SetText(GS_L("R StartY:")); m_randStart[1].SetScrollAdd(1.0f); m_randStart[1].SetDescription(GS_L("Starting position randomizer")); m_color0[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color0[0].SetConstant(m_system.color0.w); m_color0[0].SetClamp(true, 0, 1); m_color0[0].SetText(GS_L("Color0.A:")); m_color0[0].SetDescription(GS_L("Starting color alpha (transparency from 0.0 to 1.0)")); m_color0[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color0[1].SetConstant(m_system.color0.x); m_color0[1].SetClamp(true, 0, 8); m_color0[1].SetText(GS_L("Color0.R:")); m_color0[1].SetDescription(GS_L("Starting color red component (from 0.0 to 1.0)")); m_color0[2].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color0[2].SetConstant(m_system.color0.y); m_color0[2].SetClamp(true, 0, 8); m_color0[2].SetText(GS_L("Color0.G:")); m_color0[2].SetDescription(GS_L("Starting color green component (from 0.0 to 1.0)")); m_color0[3].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color0[3].SetConstant(m_system.color0.z); m_color0[3].SetClamp(true, 0, 8); m_color0[3].SetText(GS_L("Color0.B:")); m_color0[3].SetDescription(GS_L("Starting color blue component (from 0.0 to 1.0)")); m_color1[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color1[0].SetConstant(m_system.color1.w); m_color1[0].SetClamp(true, 0, 1); m_color1[0].SetText(GS_L("Color1.A:")); m_color1[0].SetDescription(GS_L("Ending color alpha (transparency)")); m_color1[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color1[1].SetConstant(m_system.color1.x); m_color1[1].SetClamp(true, 0, 8); m_color1[1].SetText(GS_L("Color1.R:")); m_color1[1].SetDescription(GS_L("Ending color red component (from 0.0 to 1.0)")); m_color1[2].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color1[2].SetConstant(m_system.color1.y); m_color1[2].SetClamp(true, 0, 8); m_color1[2].SetText(GS_L("Color1.G:")); m_color1[2].SetDescription(GS_L("Ending color green component (from 0.0 to 1.0)")); m_color1[3].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_color1[3].SetConstant(m_system.color1.z); m_color1[3].SetClamp(true, 0, 8); m_color1[3].SetText(GS_L("Color1.B:")); m_color1[3].SetDescription(GS_L("Ending color blue component (from 0.0 to 1.0)")); m_luminance[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_luminance[0].SetConstant(m_system.emissive.x); m_luminance[0].SetClamp(true, 0, 1); m_luminance[0].SetText(GS_L("Emissive.R:")); m_luminance[0].SetDescription(GS_L("Self-illumination color red component (color = diffuse*min(ambient+luminance,1))")); m_luminance[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_luminance[1].SetConstant(m_system.emissive.y); m_luminance[1].SetClamp(true, 0, 1); m_luminance[1].SetText(GS_L("Emissive.G:")); m_luminance[1].SetDescription(GS_L("Self-illumination color green component (color = diffuse*min(ambient+luminance,1))")); m_luminance[2].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_luminance[2].SetConstant(m_system.emissive.z); m_luminance[2].SetClamp(true, 0, 1); m_luminance[2].SetText(GS_L("Emissive.B:")); m_luminance[2].SetDescription(GS_L("Self-illumination color blue component (color = diffuse*min(ambient+luminance,1))")); m_size.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_size.SetConstant(m_system.size); m_size.SetClamp(true, 0, 9999999.0f); m_size.SetText(GS_L("Size:")); m_size.SetScrollAdd(1.0f); m_size.SetDescription(GS_L("Starting size")); m_growth.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_growth.SetConstant(m_system.growth); m_growth.SetClamp(false, 0, 0); m_growth.SetText(GS_L("Size+:")); m_growth.SetDescription(GS_L("Particle growth")); m_lifeTime.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_lifeTime.SetConstant(m_system.lifeTime); m_lifeTime.SetClamp(true, 0, 9999999.0f); m_lifeTime.SetText(GS_L("Time:")); m_lifeTime.SetScrollAdd(50.0f); m_lifeTime.SetDescription(GS_L("Particle life time (in milliseconds)")); m_randLifeTime.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randLifeTime.SetConstant(m_system.randomizeLifeTime); m_randLifeTime.SetClamp(true, 0, 9999999.0f); m_randLifeTime.SetText(GS_L("R Time:")); m_randLifeTime.SetScrollAdd(50.0f); m_randLifeTime.SetDescription(GS_L("Particle life time randomizer (in milliseconds)")); m_angle.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_angle.SetConstant(m_system.angleDir); m_angle.SetClamp(false, 0, 0); m_angle.SetText(GS_L("Angle Dir:")); m_angle.SetDescription(GS_L("Rotating direction")); m_randAngle.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randAngle.SetConstant(m_system.randAngle); m_randAngle.SetClamp(false, 0, 0); m_randAngle.SetText(GS_L("R Angle Dir:")); m_randAngle.SetDescription(GS_L("Rotating direction randomizer")); m_randSize.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randSize.SetConstant(m_system.randomizeSize); m_randSize.SetClamp(true, 0, 1000000); m_randSize.SetText(GS_L("R Size:")); m_randSize.SetScrollAdd(1.0f); m_randSize.SetDescription(GS_L("Particle size randomizer")); m_randAngleStart.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_randAngleStart.SetConstant(m_system.randAngleStart); m_randAngleStart.SetClamp(true, 0, 360); m_randAngleStart.SetText(GS_L("R Angle St:")); m_randAngleStart.SetScrollAdd(1.0f); m_randAngleStart.SetDescription(GS_L("Starting angle randomizer (from 0 to 360)")); m_minSize.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_minSize.SetConstant(m_system.minSize); m_minSize.SetClamp(false, 0, 0); m_minSize.SetText(GS_L("Min Size:")); m_minSize.SetScrollAdd(1.0f); m_minSize.SetDescription(GS_L("Particle minimum size")); m_maxSize.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_maxSize.SetConstant(m_system.maxSize); m_maxSize.SetClamp(false, 0, 0); m_maxSize.SetText(GS_L("Max Size:")); m_maxSize.SetScrollAdd(1.0f); m_maxSize.SetDescription(GS_L("Particle maximum size")); m_angleStart.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_angleStart.SetConstant(m_system.angleStart); m_angleStart.SetClamp(true, 0, 360); m_angleStart.SetText(GS_L("S Angle:")); m_angleStart.SetScrollAdd(1.0f); m_angleStart.SetDescription(GS_L("Particle starting angle")); m_boundingSphere.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_boundingSphere.SetConstant(m_system.boundingSphere); m_boundingSphere.SetClamp(true, 0, 2048); m_boundingSphere.SetText(GS_L("Bounding:")); m_boundingSphere.SetScrollAdd(2.0f); m_boundingSphere.SetDescription(GS_L("Bounding Sphere diameter")); m_allAtOnce.SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_allAtOnce.SetConstant((m_system.allAtOnce) ? 1.0f : 0.0f); m_allAtOnce.SetClamp(true, 0, 1); m_allAtOnce.SetText(GS_L("All at once:")); m_allAtOnce.SetScrollAdd(1.0f); m_allAtOnce.SetDescription(GS_L("All-at-once particle relasing (1=true/0=false)")); m_spriteCut[0].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_spriteCut[0].SetConstant(static_cast<float>(m_system.spriteCut.x)); m_spriteCut[0].SetClamp(true, 1, 9999); m_spriteCut[0].SetText(GS_L("Sprite columns:")); m_spriteCut[0].SetScrollAdd(1.0f); m_spriteCut[0].SetDescription(GS_L("Number of columns of the animated sprite")); m_spriteCut[1].SetupMenu(m_provider->GetVideo(), m_provider->GetInput(), m_menuSize, m_menuWidth, 9, false); m_spriteCut[1].SetConstant(static_cast<float>(m_system.spriteCut.y)); m_spriteCut[1].SetClamp(true, 1, 9999); m_spriteCut[1].SetText(GS_L("Sprite rows:")); m_spriteCut[1].SetScrollAdd(1.0f); m_spriteCut[1].SetDescription(GS_L("Number of rows of the animated sprite")); m_alphaModes.ResetButtons(); if (m_system.alphaMode == Video::AM_PIXEL) m_alphaModes.ActivateButton(ALPHA_MODE_PIXEL); if (m_system.alphaMode == Video::AM_ADD) m_alphaModes.ActivateButton(ALPHA_MODE_ADD); if (m_system.alphaMode == Video::AM_MODULATE) m_alphaModes.ActivateButton(ALPHA_MODE_MODULATE); m_animationModes.ResetButtons(); if (m_system.animationMode == ETHParticleSystem::PLAY_ANIMATION) m_animationModes.ActivateButton(ANIMATION_MODE_ANIMATE); if (m_system.animationMode == ETHParticleSystem::PICK_RANDOM_FRAME) m_animationModes.ActivateButton(ANIMATION_MODE_PICK); }
ETHLightmapGen::ETHLightmapGen(ETHRenderEntity* entity, boost::shared_ptr<ETHShaderManager> shaderManager, std::list<ETHLight>::iterator iBegin, std::list<ETHLight>::iterator iEnd, ETHBucketManager& buckets, const Vector3& oldPos, const Vector3& newPos, const float minHeight, const float maxHeight, const ETHSceneProperties &sceneProps) { const SpritePtr& sprite = entity->m_pSprite; const ETHEntityProperties& props = entity->m_properties; if (!sprite || !props.staticEntity || !props.applyLight) { return; } const VideoPtr& video = entity->m_provider->GetVideo(); const Platform::FileLogger* logger = entity->m_provider->GetLogger(); if (video->Rendering()) { ETH_STREAM_DECL(ss) << GS_L("Entity ID #") << entity->GetID() << GS_L(": lightmaps can't be generated during application render."); logger->Log(ss.str(), Platform::FileLogger::ERROR); return; } const Vector2 v2Size = (sprite->GetNumRects() <= 1) ? sprite->GetBitmapSizeF() : sprite->GetRect().size; if (!(entity->m_pLightmap = video->CreateRenderTarget(static_cast<unsigned int>(v2Size.x), static_cast<unsigned int>(v2Size.y)))) { ETH_STREAM_DECL(ss) << GS_L("ETHRenderEntity::GenerateLightmap: coudn't create the render target."); logger->Log(ss.str(), Platform::FileLogger::ERROR); entity->m_pLightmap.reset(); return; } // Paint it black video->SetRenderTarget(entity->m_pLightmap); if (!video->BeginTargetScene(GS_BLACK)) { ETH_STREAM_DECL(ss) << GS_L("ETHRenderEntity::GenerateLightmap: coudn't render to target."); logger->Log(ss.str(), Platform::FileLogger::ERROR); entity->m_pLightmap.reset(); return; } video->EndTargetScene(); entity->m_controller->SetPos(newPos); Vector2 v2CamPos = video->GetCameraPos(); video->SetCameraPos(Vector2(0,0)); for (std::list<ETHLight>::iterator iter = iBegin; iter != iEnd; iter++) { if (!iter->staticLight) continue; SpritePtr tempTarget; if (!(tempTarget = video->CreateRenderTarget(static_cast<unsigned int>(v2Size.x), static_cast<unsigned int>(v2Size.y)))) { ETH_STREAM_DECL(ss) << GS_L("ETHRenderEntity::GenerateLightmap: coudn't create temporary render target."); logger->Log(ss.str(), Platform::FileLogger::ERROR); entity->m_pLightmap.reset(); return; } if (!video->SetRenderTarget(tempTarget)) { ETH_STREAM_DECL(ss) << GS_L("ETHRenderEntity::GenerateLightmap: coudn't set render target."); logger->Log(ss.str(), Platform::FileLogger::ERROR); entity->m_pLightmap.reset(); return; } if (!video->BeginTargetScene(GS_BLACK)) { ETH_STREAM_DECL(ss) << GS_L("ETHRenderEntity::GenerateLightmap: coudn't render to temporary target."); logger->Log(ss.str(), Platform::FileLogger::ERROR); entity->m_pLightmap.reset(); return; } // draw light if (shaderManager->BeginLightPass(entity, &(*iter), video->GetScreenSizeF().y, 0.0f, sceneProps.lightIntensity, 0, true)) { entity->DrawLightPass(sceneProps.zAxisDirection, true); shaderManager->EndLightPass(); } // draw shadows if (entity->GetType() != ETH_VERTICAL) { for (ETHBucketMap::iterator bucketIter = buckets.GetFirstBucket(); bucketIter != buckets.GetLastBucket(); bucketIter++) { for (ETHEntityList::iterator entityIter = bucketIter->second.begin(); entityIter != bucketIter->second.end(); entityIter++) { if (!(*entityIter)->IsStatic()) continue; Vector3 oldPos2 = (*entityIter)->GetPosition(); Vector3 newPos2 = oldPos2-(oldPos-newPos); (*entityIter)->SetOrphanPosition(newPos2); if (shaderManager->BeginShadowPass((*entityIter), &(*iter), maxHeight, minHeight)) { (*entityIter)->DrawShadow(maxHeight, minHeight, sceneProps, *iter, 0, true, true, entity->GetAngle(), entity->GetPosition()); shaderManager->EndShadowPass(); } (*entityIter)->SetOrphanPosition(oldPos2); } } } video->EndTargetScene(); // draw the shadowed light by adding it to the final lightmap video->SetRenderTarget(entity->m_pLightmap); video->BeginTargetScene(GS_BLACK, false); const GS_ALPHA_MODE oldAM = video->GetAlphaMode(); video->SetAlphaMode(GSAM_ADD); tempTarget->Draw(Vector2(0,0)); video->SetAlphaMode(oldAM); video->EndTargetScene(); } entity->m_pLightmap->GenerateBackup(); video->SetRenderTarget(SpritePtr()); video->SetCameraPos(v2CamPos); }
bool ETHCustomDataManager::WriteDataToFile(TiXmlElement *pHeadRoot) const { TiXmlElement *pCustomData = new TiXmlElement(GS_L("CustomData")); pHeadRoot->LinkEndChild(pCustomData); for (std::map<str_type::string, ETHCustomDataPtr>::const_iterator iter = m_data.begin(); iter != m_data.end(); iter++) { TiXmlElement *pVariableRoot = new TiXmlElement(GS_L("Variable")); pCustomData->LinkEndChild(pVariableRoot); TiXmlElement *pElement; pElement = new TiXmlElement(GS_L("Type")); pElement->LinkEndChild(new TiXmlText(DATA_NAME[iter->second->GetType()] )); pVariableRoot->LinkEndChild(pElement); pElement = new TiXmlElement(GS_L("Name")); pElement->LinkEndChild(new TiXmlText(iter->first)); pVariableRoot->LinkEndChild(pElement); pElement = new TiXmlElement(GS_L("Value")); str_type::stringstream ss; switch (iter->second->GetType()) { case ETHDT_FLOAT: ss << iter->second->GetFloat(); break; case ETHDT_INT: ss << iter->second->GetInt(); break; case ETHDT_UINT: ss << iter->second->GetUInt(); break; case ETHDT_STRING: ss << iter->second->GetString(); break; }; switch (iter->second->GetType()) { case ETHDT_FLOAT: case ETHDT_INT: case ETHDT_UINT: case ETHDT_STRING: pElement->LinkEndChild(new TiXmlText(ss.str())); break; case ETHDT_VECTOR2: pElement->SetDoubleAttribute(GS_L("x"), iter->second->GetVector2().x); pElement->SetDoubleAttribute(GS_L("y"), iter->second->GetVector2().y); break; case ETHDT_VECTOR3: pElement->SetDoubleAttribute(GS_L("x"), iter->second->GetVector3().x); pElement->SetDoubleAttribute(GS_L("y"), iter->second->GetVector3().y); pElement->SetDoubleAttribute(GS_L("z"), iter->second->GetVector3().z); break; }; pVariableRoot->LinkEndChild(pElement); } return true; }
bool ETHCustomDataManager::ReadDataFromXMLFile(TiXmlElement *pRoot) { TiXmlNode *pNode = pRoot->FirstChild(GS_L("CustomData")); if (pNode) { TiXmlElement *pEntities = pNode->ToElement(); if (pEntities) { pNode = pEntities->FirstChild(GS_L("Variable")); if (pNode) { TiXmlElement *pVarIter = pNode->ToElement(); if (pVarIter) { do { str_type::string type, name, value; TiXmlElement *pElement; // read the variable type (as a string) pNode = pVarIter->FirstChild(GS_L("Type")); if (pNode) { pElement = pNode->ToElement(); if (pElement) { type = pElement->GetText(); } } // read the variable name pNode = pVarIter->FirstChild(GS_L("Name")); if (pNode) { pElement = pNode->ToElement(); if (pElement) { name = pElement->GetText(); } } // read the variable value if (type != GS_L("") && name != GS_L("")) { pNode = pVarIter->FirstChild(GS_L("Value")); if (pNode) { pElement = pNode->ToElement(); if (pElement) { if (type == DATA_NAME[ETHDT_VECTOR2]) { Vector2 value(0,0); pElement->QueryFloatAttribute(GS_L("x"), &value.x); pElement->QueryFloatAttribute(GS_L("y"), &value.y); SetVector2(name, value); } else if (type == DATA_NAME[ETHDT_VECTOR3]) { Vector3 value(0,0,0); pElement->QueryFloatAttribute(GS_L("x"), &value.x); pElement->QueryFloatAttribute(GS_L("y"), &value.y); pElement->QueryFloatAttribute(GS_L("z"), &value.z); SetVector3(name, value); } else { value = pElement->GetText(); // passing the variable to the map if (type == DATA_NAME[ETHDT_FLOAT]) { SetFloat(name, ETHGlobal::ParseFloat(value.c_str())); } else if (type == DATA_NAME[ETHDT_INT]) { SetInt(name, ETHGlobal::ParseInt(value.c_str())); } else if (type == DATA_NAME[ETHDT_UINT]) { SetUInt(name, ETHGlobal::ParseUInt(value.c_str())); } else if (type == DATA_NAME[ETHDT_STRING]) { SetString(name, value); } } } } } pVarIter = pVarIter->NextSiblingElement(); } while (pVarIter); } } } } return true; }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Ethanon Engine. If not, see <http://www.gnu.org/licenses/>. -----------------------------------------------------------------------*/ #include "ETHCustomDataManager.h" #include <iostream> const str_type::string ETHCustomDataManager::DATA_NAME[ETH_CUSTOM_DATA_TYPE_COUNT] = { (GS_L("")), (GS_L("float")), (GS_L("int")), (GS_L("uint")), (GS_L("string")), (GS_L("vector2")), (GS_L("vector3")) }; const str_type::string ÐCustomDataManager::GetDataName(const unsigned int n) { assert(n<ETH_CUSTOM_DATA_TYPE_COUNT); return DATA_NAME[n]; } void ETHCustomDataManager::SetFloat(const str_type::string &name, const float &value)
str_type::string ETHEntity::GetString(const str_type::string &name) const { str_type::string sOut = GS_L(""); m_properties.GetString(name, sOut); return sOut; }