Example #1
0
//
// ---------------------------------------------------------
// CDosSaeExample::StartSaeL
// ---------------------------------------------------------
//  
TInt CDosSaeExample::StartSaeL()
{
	FLOG(_L("CDosSaeExample::StartSaeL()"));

	EventManager()->PhonePowerOn();
	EventManager()->SimState(ESimStateOk);
	EventManager()->SecurityCode(EPSSecurityCodeNotRequired);
	EventManager()->SimPresentStateChangedL(ESimPresentTrue);

	return KErrNone;
}
Example #2
0
Kylin::Scene::Scene( const SceneHag& kSceneHag )
    : m_kSceneHag(kSceneHag)
    , m_pSceneLoader(NULL)
{
    m_pEntityManager = KNEW EntityManager();
    m_pEventManager  = KNEW EventManager(m_pEntityManager);

}
Example #3
0
System::System() :
    _device_manager(DeviceManager()), _interrupt_manager(InterruptManager()), _event_manager(
        EventManager()), _timer_manager(TimerManager()), _time(0), _current_app(
        std::shared_ptr<Application>()), _running(false)
{
  SysTick_Config(SystemCoreClock / 1000);
  NVIC_SetPriority(SysTick_IRQn, 0);
}
Example #4
0
bool GameApp::InitInstance(HINSTANCE hInstance, LPWSTR lpCmdLine, HWND hWnd, int screenWidth, int screenHeight)
{
	SetCursor( NULL );

	m_hInstance = hInstance;

	m_pOptions = GCC_NEW GameOptions("m_pOptions->ini");
	ParseCommandLine(lpCmdLine);

	m_pEventManager = GCC_NEW EventManager("CometConquest Event Mgr", true );
	if (!m_pEventManager)
	{
		return false;
	}

	RegisterBaseGameEvents();

	DXUTInit( true, true, NULL );

	if(hWnd==NULL)
	{
		DXUTCreateWindow( VGetGameTitle(), hInstance, VGetIcon() );
	}
	else
	{
		DXUTSetWindow( hWnd, hWnd, hWnd);
	}

	if(!GetHwnd())
	{
		return false;
	}
	SetWindowText(GetHwnd(), VGetGameTitle());

	DXUTCreateDevice (D3D_FEATURE_LEVEL_9_2, true, 800, 600 );

	m_pGame = VCreateGameAndView();
	if (!m_pGame)
		return false;

	m_bIsRunning = true;

	return true;

}
Example #5
0
void tNDP2kMedusa::Initialise()
{
    tNDP2k::Initialise();

    tNDP2kEventManager& eventManager = EventManager();

    // User group for following events fixed at 100 for Medusa
    eventManager.GetEventObjectById(eNDP2kEventId_AlarmActivate).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_AlarmDeactivate).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_AlarmSilence).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_AlarmAcknowledge).SetUserGroup(100);

    eventManager.GetEventObjectById(eNDP2kEventId_SourceSelectionContinueWait).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_SourceSelectionInitWait).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_SourceSelectionResetWait).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_SourceSelectionContinueOrStop).SetUserGroup(100);
    eventManager.GetEventObjectById(eNDP2kEventId_GlobalReset).SetUserGroup(100);

    tNDP2kParamManager& paramManager = ParamManager();

    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdCompass).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdAppWind).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdTrueWind).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdDepth).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdPosition).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdNavigation).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdSpeed).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdSeaTemperature).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdDistanceLog).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdRudder).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdBaroPressure).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdOutsideTemperature).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdHeelRoll).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdTrimPitch).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdSailing).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdSailingNavigation).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdAutopilotFunction).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdAutopilotControl).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdMonitorCompass).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdBackupSpeed).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdBackupPosition).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdBackupAutopilotFunction).SetUserGroup(100);
    paramManager.GetParamObjectById(eNDP2kParamId_SourceIdAftDepth).SetUserGroup(100);
}
Example #6
0
EventManager &EventManager::getInstance(){
    static EventManager instance = EventManager();
    return instance;
}
Example #7
0
//===================================================================
// Win32 Specific Stuff
//
// InitInstance - this checks system resources, creates your window, and launches the game
//
// preprocessor macro setting in the C++ options of the project provides the base macro
// C preprocessor string concatenation takes care of the rest.
//
// AlphaApp::InitInstance - Chapter 5, page 136
//
//===================================================================
bool AlphaApp::InitInstance(HINSTANCE hInstance, LPWSTR lpCmdLine, HWND hWnd, int screenWidth, int screenHeight, bool windowed)
{	
	AC_LOG("Script","Init");
	// Check for existing instance of the same window - Chapter 5, page 137
    // 
#ifndef _DEBUG
    // Note - it can be really useful to debug network code to have
    // more than one instance of the game up at one time - so
    // feel free to comment these lines in or out as you wish!
    if (!IsOnlyInstance(VGetGameTitle()))
		return false;

#endif

	// We don't need a mouse cursor by default, let the game turn it on
	SetCursor(NULL);

	// Check for adequate machine resources.
	// Check secondary storage space and memory. - Chapter 5, page 138-139
	// Calculate the CPU speed. - Chapter 5, page 140
	bool resourceCheck = false;
	while (!resourceCheck)
	{
		const DWORDLONG physicalRAM = 512 * MEGABYTE;
		const DWORDLONG virtualRAM = 1024 * MEGABYTE;
		const DWORDLONG diskSpace = 10 * MEGABYTE;
		if (!CheckStorage(diskSpace))
			return false;

		const DWORD minCpuSpeed = 1300;     // 1.3Ghz
		DWORD thisCPU = ReadCPUSpeed();
		if (thisCPU < minCpuSpeed)
		{
			AC_ERROR("GetCPUSpeed reports CPU is too slow for this game.");
			return false;
		}

		resourceCheck = true;
	}

	m_hInstance = hInstance;

    // register all events
    RegisterEngineEvents();
    VRegisterGameEvents();

	//
	// Initialize the ResCache - Chapter 5, page 141
	//
	//    Note - this is a little different from the book. Here we have a speccial resource ZIP file class, DevelopmentResourceZipFile,
	//    that actually reads directly from the source asset files, rather than the ZIP file. This is MUCH better during development, since
	//    you don't want to have to rebuild the ZIP file every time you make a minor change to an asset.
	//
	IResourceFile *zipFile = (m_bIsEditorRunning || m_Options.m_useDevelopmentDirectories) ? 
		AC_NEW DevelopmentResourceZipFile(L"Assets.zip", DevelopmentResourceZipFile::Editor) :
		AC_NEW ResourceZipFile(L"Assets.zip");

	m_ResCache = AC_NEW ResCache(50, zipFile);

	if (!m_ResCache->Init())
	{
        AC_ERROR("Failed to initialize resource cache!  Are your paths set up correctly?");
		return false;
	}
	
	//extern shared_ptr<IResourceLoader> CreateWAVResourceLoader();
	//extern shared_ptr<IResourceLoader> CreateOGGResourceLoader();
	extern shared_ptr<IResourceLoader> CreateDDSResourceLoader();
	extern shared_ptr<IResourceLoader> CreateJPGResourceLoader();
    extern shared_ptr<IResourceLoader> CreateXmlResourceLoader();
    //extern shared_ptr<IResourceLoader> CreateSdkMeshResourceLoader();
    extern shared_ptr<IResourceLoader> CreateScriptResourceLoader();

	// Note - register these in order from least specific to most specific! They get pushed onto a list.
	// RegisterLoader is discussed in Chapter 5, page 142
	//m_ResCache->RegisterLoader(CreateWAVResourceLoader());
	//m_ResCache->RegisterLoader(CreateOGGResourceLoader());
	m_ResCache->RegisterLoader(CreateDDSResourceLoader());
	m_ResCache->RegisterLoader(CreateJPGResourceLoader());
    m_ResCache->RegisterLoader(CreateXmlResourceLoader());
	//m_ResCache->RegisterLoader(CreateSdkMeshResourceLoader());
    m_ResCache->RegisterLoader(CreateScriptResourceLoader());

	//// Load strings that will be presented to the player. - Chapter 5, page 142
	//if(!LoadStrings("English"))
	//{
 //       AC_ERROR("Failed to load strings");
	//	return false;
	//}

	// Create the LUA script manager. - Chapter 5, page 144
	if (!LuaStateManager::Create())
	{
		AC_ERROR("Failed to initialize Lua");
		return false;
	}

	// Load the preinit file.  This is within braces to create a scope and destroy the resource once it's loaded.  We
    // don't need to do anything with it, we just need to load it.
    {
        Resource resource(SCRIPT_PREINIT_FILE);
        shared_ptr<ResHandle> pResourceHandle = m_ResCache->GetHandle(&resource);  // this actually loads the XML file from the zip file
    }

    // Register function exported from C++
    ScriptExports::Register();
    ScriptProcess::RegisterScriptClass();
    BaseScriptComponent::RegisterScriptFunctions();

	// Create the game's event manager. - Chapter 5, page 145
	m_pEventManager = AC_NEW EventManager("AlphaApp Event Mgr", true);
	if (!m_pEventManager)
	{
		AC_ERROR("Failed to create EventManager.");
		return false;
	}

	// Inititalize DirectX, the application's window, and the D3D device. - Chapter 5, page 145
	//DXUTInit(true, true, lpCmdLine, true);
	//Init DirectX11Wrapper class
	g_pDX11W->DX11WInit(lpCmdLine);// may need to be put in the alpha app init instance function

	if (hWnd==NULL)
	{
		//DXUTCreateWindow(VGetGameTitle(), hInstance, VGetIcon());
		g_pDX11W->DX11WCreateWindow(VGetGameTitle(), hInstance, VGetIcon());
	}
	else
	{
	    //DXUTSetWindow( hWnd, hWnd, hWnd );
	}

	if(!GetHwnd())
	{
		return false;
	}
	SetWindowText(GetHwnd(), VGetGameTitle());
	
	// initialize the directory location you can store save game files
	//_tcscpy_s(m_saveGameDirectory, GetSaveGameDirectory(GetHwnd(), VGetGameAppDirectory()));

    // DXUTCreateDevice - Chapter 5 - page 139
    m_screenSize = Point(screenWidth, screenHeight);

	//DXUTCreateDevice( D3D_FEATURE_LEVEL_10_1, true, screenWidth, screenHeight);
	g_pDX11W->DX11WCreateDevice(windowed, screenWidth, screenHeight);

	m_Renderer = shared_ptr<IRenderer>(AC_NEW D3DRenderer11());
    m_Renderer->VSetBackgroundColor(0, 50, 100, 255);
    m_Renderer->VOnRestore();

	// You usually must have an HWND to initialize your game views...
	//    VCreateGameAndView			- Chapter 5, page 145
	m_pGame = VCreateGameAndView();
	if (!m_pGame)
		return false;

	// now that all the major systems are initialized, preload resources 
	//    Preload calls are discussed in Chapter 5, page 148
	//m_ResCache->Preload("*.ogg", NULL);
	m_ResCache->Preload("*.dds", NULL);
	//m_ResCache->Preload("*.jpg", NULL);

	//if ( GameCodeApp::GetRendererImpl() == GameCodeApp::Renderer_D3D11 )
	//	m_ResCache->Preload("*.sdkmesh", NULL);

	m_bIsRunning = TRUE;

	return TRUE;
}
Example #8
0
namespace Dodge {


EventManager Entity::m_eventManager = EventManager();
int Entity::m_count = 0;


#ifdef DEBUG
//===========================================
// Entity::dbg_print
//===========================================
void Entity::dbg_print(std::ostream& out, int tab) const {
   for (int i = 0; i < tab; ++i) out << "\t";
   out << "Entity\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "name: " << getInternedString(m_name) << "\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "type: " << getInternedString(m_type) << "\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "scale: (" << m_scale.x << ", " << m_scale.y << ")\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "translation: (" << m_transl.x << ", " << m_transl.y << ")\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "z: " << m_z << "\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "rotation: " << m_rot << "\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "shape (src):\n";
   if (m_shape) m_shape->dbg_print(out, tab + 1);

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "boundary:\n";
   m_boundary.dbg_print(out, tab + 1);

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "parent: " << (m_parent ? getInternedString(m_parent->getName()) : "NULL") << "\n";

   for (int i = 0; i < tab + 1; ++i) out << "\t";
   out << "children: ";
   if (m_children.size() > 0) {
      out << "\n";
      for (set<pEntity_t>::const_iterator c = m_children.begin(); c != m_children.end(); ++c) {
         for (int i = 0; i < tab + 2; ++i) out << "\t";
         out << getInternedString((*c)->getName()) << "\n";
      }
   }
   else
      out << "(none)\n";
}
#endif

//===========================================
// Entity::Entity
//===========================================
Entity::Entity(const XmlNode data)
   : Asset(internString("Entity")),
     m_silent(false),
     m_parent(NULL) {

   AssetManager assetManager;
   ShapeFactory shapeFactory;

   try {
      setSilent(true);

      XML_NODE_CHECK(data, Entity);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, type);
      m_type = internString(attr.getString());

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, name);
      m_name = internString(attr.getString());

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, x);
      m_transl.x = attr.getFloat();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, y);
      m_transl.y = attr.getFloat();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, z);
      m_z = attr.getFloat();

      // So that no Z values are 'exactly' equal
      m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, rot);
      float32_t rot = attr.getFloat();

      XmlNode node = data.firstChild();
      if (!node.isNull() && node.name() == "shape") {
         m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
         node = node.nextSibling();
      }

      m_rot = 0;
      setRotation(rot);

      XML_NODE_CHECK(node, scale);
      m_scale = Vec2f(1.f, 1.f);
      setScale(Vec2f(node.firstChild()));

      node = node.nextSibling();
      XML_NODE_CHECK(node, fillColour);
      m_fillColour = Colour(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, lineColour);
      m_lineColour = Colour(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, lineWidth);
      m_lineWidth = node.getInt();

      node = node.nextSibling();
      XML_NODE_CHECK(node, children);
      XmlNode node_ = node.firstChild();
      while (!node_.isNull() && node_.name() == "child") {
         XmlAttribute attr = node_.firstAttribute();

         if (!attr.isNull() && attr.name() == "ptr") {
            long id = attr.getLong();

            pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));

            if (!child)
               throw XmlException("Bad entity asset id", __FILE__, __LINE__);

            addChild(child);
         }

         node_ = node_.nextSibling();
      }

      setSilent(false);

      ++m_count;
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Entity; ");
      throw;
   }

   recomputeBoundary();
}

//===========================================
// Entity::Entity
//===========================================
Entity::Entity(long name, long type)
   : Asset(internString("Entity")),
     m_name(name),
     m_type(type),
     m_silent(false),
     m_scale(1.f, 1.f),
     m_transl(0.f, 0.f),
     m_z(1),
     m_rot(0.f),
     m_lineWidth(0),
     m_parent(NULL) {

   // So that no Z values are 'exactly' equal
   m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

   ++m_count;
}

//===========================================
// Entity::Entity
//===========================================
Entity::Entity(long type)
   : Asset(internString("Entity")),
     m_type(type),
     m_silent(false),
     m_scale(1.f, 1.f),
     m_transl(0.f, 0.f),
     m_z(1),
     m_rot(0.f),
     m_lineWidth(0),
     m_parent(NULL) {

   // So that no Z values are 'exactly' equal
   m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

   m_name = generateName();

   ++m_count;
}

//===========================================
// Entity::Entity
//
// Construct deep copy.
//===========================================
Entity::Entity(const Entity& copy)
   : Asset(internString("Entity")),
     m_silent(false),
     m_parent(NULL) {

   deepCopy(copy);
   m_name = generateName();

   ++m_count;
}

//===========================================
// Entity::Entity
//
// Construct deep copy.
//===========================================
Entity::Entity(const Entity& copy, long name)
   : Asset(internString("Entity")),
     m_silent(false),
     m_parent(NULL) {

   deepCopy(copy);
   m_name = name;

   ++m_count;
}

//===========================================
// Entity::deepCopy
//
// Copy's 'family' is not inherited
//===========================================
void Entity::deepCopy(const Entity& copy) {
   m_name = copy.m_name;
   m_type = copy.m_type;
   m_scale = copy.m_scale;
   m_fillColour = copy.m_fillColour;
   m_lineColour = copy.m_lineColour;
   m_lineWidth = copy.m_lineWidth;
   m_transl = copy.m_transl;
   m_z = copy.m_z;
   m_rot = copy.m_rot;

   // So that no Z values are 'exactly' equal
   m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

   if (copy.m_shape)
      m_shape = unique_ptr<Shape>(dynamic_cast<Shape*>(copy.m_shape->clone()));

   m_boundary = copy.m_boundary;

   if (copy.m_auxData)
      m_auxData = unique_ptr<IAuxData>(copy.m_auxData->clone());
}

//===========================================
// Entity::getSize
//===========================================
size_t Entity::getSize() const {
   return sizeof(Entity)
      + (m_shape ? m_shape->getSize() : 0)
      + m_children.size() * sizeof(pEntity_t)
      + (m_auxData ? m_auxData->getSize() : 0);
}

//===========================================
// Entity::generateName
//===========================================
long Entity::generateName() {
   stringstream str;
   str << "entity" << m_count;
   return internString(str.str());
}

//===========================================
// Entity::assignData
//===========================================
void Entity::assignData(const XmlNode data) {
   if (data.isNull() || data.name() != "Entity") return;

   AssetManager assetManager;
   ShapeFactory shapeFactory;

   try {
      bool silent = isSilent();
      setSilent(true);

      XmlAttribute attr = data.firstAttribute();
      if (!attr.isNull() && attr.name() == "type") {
         m_type = internString(attr.getString());
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "name") {
         m_name = internString(attr.getString());
         attr = attr.nextAttribute();
      }

      Vec2f transl = m_transl;

      if (!attr.isNull() && attr.name() == "x") {
         transl.x = attr.getFloat();
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "y") {
         transl.y = attr.getFloat();
         attr = attr.nextAttribute();
      }

      setTranslation(transl);

      if (!attr.isNull() && attr.name() == "z") {
         m_z = attr.getFloat();

         // So that no Z values are 'exactly' equal
         m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

         attr = attr.nextAttribute();
      }

      XmlNode node = data.firstChild();
      if (!node.isNull() && node.name() == "shape") {
         m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "scale") {
         setScale(Vec2f(node.firstChild()));
         node = node.nextSibling();
      }

      if (!attr.isNull() && attr.name() == "rot") {
         setRotation(attr.getFloat());
      }

      if (!node.isNull() && node.name() == "fillColour") {
         m_fillColour = Colour(node.firstChild());
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "lineColour") {
         m_lineColour = Colour(node.firstChild());
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "lineWidth") {
         m_lineWidth = node.getInt();
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "children") {
         XmlNode node_ = node.firstChild();

         while (!node_.isNull() && node_.name() == "child") {
            XmlAttribute attr = node_.firstAttribute();

            if (!attr.isNull() && attr.name() == "ptr") {
               long id = attr.getLong();

               pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));

               if (!child)
                  throw XmlException("Bad entity asset id", __FILE__, __LINE__);

               addChild(child);
            }

            node_ = node_.nextSibling();
         }
      }

      setSilent(silent);
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Entity; ");
      throw;
   }

   recomputeBoundary();
}

//===========================================
// Entity::draw
//===========================================
void Entity::draw() const {
   if (m_shape) {
      Vec2f pos = getTranslation_abs();
      m_shape->setRenderTransform(pos.x, pos.y, m_z);

      m_shape->draw();
   }
}

//===========================================
// Entity::setParent
//===========================================
void Entity::setParent(Entity* parent) {
   Entity* oldParent = m_parent;

   if (m_parent) m_parent->removeChild(shared_from_this());
   m_parent = parent;
   m_parent->m_children.insert(shared_from_this());

   rotateShapes_r(m_parent->getRotation_abs());

   onParentTransformation(oldParent ? oldParent->getRotation_abs() : 0.f,
      oldParent ? oldParent->getTranslation_abs() : Vec2f(0.f, 0.f));

   Range bounds = m_boundary;
   recomputeBoundary();

   if (!m_silent) {
      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);

      onEvent(event1);

      m_eventManager.queueEvent(event1);
   }
}

//===========================================
// Entity::addChild
//===========================================
void Entity::addChild(pEntity_t child) {
   child->setParent(this);
}

//===========================================
// Entity::removeChild
//===========================================
void Entity::removeChild(pEntity_t child) {
   assert(child->m_parent == this);

   child->rotateShapes_r(-getRotation_abs());

   child->m_parent = NULL;

   child->onParentTransformation(getRotation_abs(), getTranslation_abs());

   m_children.erase(child);
}

//===========================================
// Entity::setZ
//===========================================
void Entity::setZ(float32_t z) {
   m_z = z;

   // So that no Z values are 'exactly' equal
   m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);
}

//===========================================
// Entity::getTranslation_abs
//===========================================
Vec2f Entity::getTranslation_abs() const {
   if (m_parent) {
      float32_t x = m_transl.x * cos(DEG_TO_RAD(m_parent->getRotation_abs()))
         - m_transl.y * sin(DEG_TO_RAD(m_parent->getRotation_abs()));

      float32_t y = m_transl.x * sin(DEG_TO_RAD(m_parent->getRotation_abs()))
         + m_transl.y * cos(DEG_TO_RAD(m_parent->getRotation_abs()));

      Vec2f t = m_parent->getTranslation_abs();

      return t + Vec2f(x, y);
   }
   else {
      return getTranslation();
   }
}

//===========================================
// Entity::recomputeBoundary
//===========================================
void Entity::recomputeBoundary() {
   Vec2f min = m_shape ? m_shape->getMinimum() : Vec2f(0.f, 0.f);
   Vec2f max = m_shape ? m_shape->getMaximum() : Vec2f(0.001f, 0.001f);

   m_boundary.setPosition(getTranslation_abs() + min);
   m_boundary.setSize(max - min);
}

//===========================================
// Entity::translate
//===========================================
void Entity::translate(float32_t x, float32_t y) {
   Range bounds = m_boundary;

   float32_t oldRot = getRotation_abs();
   Vec2f oldTransl = getTranslation_abs();

   m_transl = m_transl + Vec2f(x, y);
   recomputeBoundary();

   if (!m_silent) {
      Vec2f t = getTranslation_abs();

      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);
      EEvent* event2 = new EEntityTranslation(shared_from_this(), m_transl - Vec2f(x, y), oldTransl, m_transl, t);

      onEvent(event1);
      onEvent(event2);

      m_eventManager.queueEvent(event1);
      m_eventManager.queueEvent(event2);
   }

   for (set<pEntity_t>::iterator i = m_children.begin(); i != m_children.end(); ++i)
      (*i)->onParentTransformation(oldRot, oldTransl);
}

//===========================================
// Entity::setTranslation_abs
//===========================================
void Entity::setTranslation_abs(float32_t x, float32_t y) {
   if (m_parent) {
      Vec2f r = Vec2f(x, y) - m_parent->getTranslation_abs();
      Vec2f s;

      s.x = r.x * cos(DEG_TO_RAD(-m_parent->getRotation_abs()))
         - r.y * sin(DEG_TO_RAD(-m_parent->getRotation_abs()));

      s.y = r.x * sin(DEG_TO_RAD(-m_parent->getRotation_abs()))
         + r.y * cos(DEG_TO_RAD(-m_parent->getRotation_abs()));

      setTranslation(s);
   }
   else {
      setTranslation(x, y);
   }
}

//===========================================
// Entity::setRotation_abs
//
// Pivot is in model space
//===========================================
void Entity::setRotation_abs(float32_t deg) {
   rotate(deg - getRotation_abs());
}

//===========================================
// Entity::rotate
//
// Pivot is in model space
//===========================================
void Entity::rotate(float32_t deg, const Vec2f& pivot) {
   float32_t oldRot = m_rot;
   float32_t oldRot_abs = getRotation_abs();
   Vec2f oldTransl = m_transl;
   Vec2f oldTransl_abs = getTranslation_abs();

   // - Find model's origin (bottom-left corner) in parent's model space (o)
   //    - This is just m_transl (despite any prior rotations)
   // - Find pivot in parent's model space (p)
   //    - p = (pivot rotated by m_rot) + o
   // - Compute value of o rotated about p by deg degrees
   // - Set m_transl to o
   // - Add deg to m_rot

   // Pivot in parent's model space (or world space if this is root)
   float32_t px = pivot.x * cos(DEG_TO_RAD(m_rot)) - pivot.y * sin(DEG_TO_RAD(m_rot));
   float32_t py = pivot.x * sin(DEG_TO_RAD(m_rot)) + pivot.y * cos(DEG_TO_RAD(m_rot));
   Vec2f p(px + m_transl.x, py + m_transl.y);

   // Rotate bottom-left corner around pivot
   Vec2f o = m_transl - p;
   o.x = o.x * cos(DEG_TO_RAD(deg)) - o.y * sin(DEG_TO_RAD(deg));
   o.y = o.x * sin(DEG_TO_RAD(deg)) + o.y * cos(DEG_TO_RAD(deg));

   m_transl.x = p.x + o.x;
   m_transl.y = p.y + o.y;

   m_rot += deg;

   rotateShapes_r(deg);

   Range bounds = m_boundary;
   recomputeBoundary();

   Vec2f ds = m_transl - oldTransl;

   if (!m_silent) {
      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);
      EEvent* event2 = new EEntityRotation(shared_from_this(), oldRot, oldRot_abs, m_rot, getRotation_abs());
      EEvent* event3 = new EEntityTranslation(shared_from_this(), oldTransl, oldTransl_abs, m_transl, oldTransl_abs + ds);

      onEvent(event1);
      onEvent(event2);
      onEvent(event3);

      m_eventManager.queueEvent(event1);
      m_eventManager.queueEvent(event2);
      m_eventManager.queueEvent(event3);
   }

   for (set<pEntity_t>::iterator i = m_children.begin(); i != m_children.end(); ++i)
      (*i)->onParentTransformation(oldRot_abs, oldTransl_abs);
}

//===========================================
// Entity::rotateShapes_r
//===========================================
void Entity::rotateShapes_r(float32_t deg) {
   if (m_shape) m_shape->rotate(deg);
   for (set<pEntity_t>::iterator i = m_children.begin(); i != m_children.end(); ++i)
      (*i)->rotateShapes_r(deg);
}

//===========================================
// Entity::onParentTransformation
//===========================================
void Entity::onParentTransformation(float32_t a, const Vec2f& s) {
   Range bounds = m_boundary;
   recomputeBoundary();

   float32_t x = m_transl.x * cos(DEG_TO_RAD(a))
      - m_transl.y * sin(DEG_TO_RAD(a));

   float32_t y = m_transl.x * sin(DEG_TO_RAD(a))
      + m_transl.y * cos(DEG_TO_RAD(a));

   Vec2f oldTransl(x, y);
   Vec2f oldTransl_abs = s + oldTransl;

   float32_t oldRot_abs = a + m_rot;

   if (!m_silent) {
      float32_t rot_abs = getRotation_abs();
      Vec2f transl_abs = getTranslation_abs();

      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);
      EEvent* event2 = new EEntityRotation(shared_from_this(), m_rot, oldRot_abs, m_rot, rot_abs);
      EEvent* event3 = new EEntityTranslation(shared_from_this(), m_transl, oldTransl_abs, m_transl, transl_abs);

      onEvent(event1);
      onEvent(event2);
      onEvent(event3);

      m_eventManager.queueEvent(event1);
      m_eventManager.queueEvent(event2);
      m_eventManager.queueEvent(event3);
   }

   for (set<pEntity_t>::iterator i = m_children.begin(); i != m_children.end(); ++i)
      (*i)->onParentTransformation(oldRot_abs, oldTransl_abs);
}

//===========================================
// Entity::setShape
//===========================================
void Entity::setShape(std::unique_ptr<Shape> shape) {
   Range bounds = m_boundary;
   Shape* oldShape = m_shape ? dynamic_cast<Shape*>(m_shape->clone()) : NULL;
   float32_t oldRot_abs = getRotation_abs();

   m_shape = std::move(shape);

   if (m_shape) {
      m_shape->rotate(m_rot);
      m_shape->scale(m_scale);

      m_shape->setLineWidth(m_lineWidth);
      m_shape->setFillColour(m_fillColour);
      m_shape->setLineColour(m_lineColour);
   }

   recomputeBoundary();

   if (!m_silent) {
      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);
      EEvent* event2 = new EEntityShape(shared_from_this(), pShape_t(oldShape), oldRot_abs, pShape_t(dynamic_cast<Shape*>(m_shape->clone())), getRotation_abs());

      onEvent(event1);
      onEvent(event2);

      m_eventManager.queueEvent(event1);
      m_eventManager.queueEvent(event2);
   }
}

//===========================================
// Entity::scale
//===========================================
void Entity::scale(float32_t x, float32_t y) {
   Range bounds = m_boundary;
   pShape_t oldShape = m_shape ? pShape_t(dynamic_cast<Shape*>(m_shape->clone())) : pShape_t();
   float32_t oldRot_abs = getRotation_abs();

   if (m_shape) m_shape->scale(Vec2f(x, y));
   m_scale.x *= x;
   m_scale.y *= y;
   recomputeBoundary();

   if (!m_silent) {
      EEvent* event1 = new EEntityBoundingBox(shared_from_this(), bounds, m_boundary);

      EEvent* event2 = new EEntityShape(shared_from_this(), oldShape, oldRot_abs,
         pShape_t(m_shape ? dynamic_cast<Shape*>(m_shape->clone()) : NULL), getRotation_abs());

      onEvent(event1);
      onEvent(event2);

      m_eventManager.queueEvent(event1);
      m_eventManager.queueEvent(event2);
   }
}

//===========================================
// Entity::setSilent
//===========================================
void Entity::setSilent(bool b) {
   m_silent = b;
}

//===========================================
// Entity::clone
//===========================================
Asset* Entity::clone() const {
   return new Entity(*this);
}

//===========================================
// Entity::setFillColour
//===========================================
void Entity::setFillColour(const Colour& colour) {
   m_fillColour = colour;
   if (m_shape) m_shape->setFillColour(colour);
}

//===========================================
// Entity::setLineColour
//===========================================
void Entity::setLineColour(const Colour& colour) {
   m_lineColour = colour;
   if (m_shape) m_shape->setLineColour(colour);
}

//===========================================
// Entity::setLineWidth
//===========================================
void Entity::setLineWidth(Renderer::int_t lineWidth) {
   m_lineWidth = lineWidth;
   if (m_shape) m_shape->setLineWidth(lineWidth);
}

//===========================================
// Entity::getFillColour
//===========================================
const Colour& Entity::getFillColour() const {
   return m_fillColour;
}

//===========================================
// Entity::getLineColour
//===========================================
const Colour& Entity::getLineColour() const {
   return m_lineColour;
}

//===========================================
// Entity::getLineWidth
//===========================================
Renderer::int_t Entity::getLineWidth() const {
   return m_lineWidth;
}

//===========================================
// Entity::~Entity
//===========================================
Entity::~Entity() {}


}
Example #9
0
bool EngineApp::InitInstance( SDL_Window* window, int screenWidth, int screenHeight )
   {
   /*auto test = std::vector< Vec2 >( { Vec2( 1.0f, 1.0f ), Vec2( 5.0f, 5.0f ), Vec2( 4.0f, 4.0f ), Vec2( 1.0f, -3.0f ) } );*/
   //auto test = std::vector< Vec2 >( { Vec2( 0.0f, 2.0f ), Vec2( 1.0f, 4.0f ), Vec2( 2.0f, 0.0f ), Vec2( 3.0f, 1.0f ), Vec2( 4.0f, 3.0f ) } );
   //Triangulation( test );
   // Check for existing instance of the same window
	// Not sure if this feature is working normally.... 
   #ifndef _DEBUG
	// Note - it can be really useful to debug network code to have
	// more than one instance of the game up at one time - so
	// feel free to comment these lines in or out as you wish!
   if (!IsOnlyInstance( VGetGameTitle() ) )
      {
      return false;
      }
   #endif
   
   //--------------------------------- 
   // Check system requirements
   //--------------------------------- 
   bool resourceCheck = false;
	while (!resourceCheck)
	   {
		const DWORDLONG physicalRAM = 512 * MEGABYTE;
		const DWORDLONG virtualRAM = 1024 * MEGABYTE;
		const DWORDLONG diskSpace = 10 * MEGABYTE;
		if ( !CheckStorage(diskSpace) )
         {
			return false;
         }
		const DWORD minCpuSpeed = 1300;			// 1.3Ghz
		DWORD thisCPU = ReadCPUSpeed();
		if ( thisCPU < minCpuSpeed )
		   {
			ENG_ERROR("GetCPUSpeed reports CPU is too slow for this game.");
			return false;
		   }

		resourceCheck = true;
	   }
   //--------------------------------- 
   // Check system requirements
   //--------------------------------- 

	//--------------------------------- 
   //  Initialize ResCache, all assets are within a zip file
   //--------------------------------- 
   IResourceFile *pFile = NULL;
   if( m_EngineOptions.GetIsUsingDevDirectory() )
      {
      pFile = ENG_NEW DevResourceFile( DevResourceFile::Editor );
      }
   else
      {
      pFile = ENG_NEW ResourceZipFile( L"Assets.zip" );
      }
   m_pResCache = ENG_NEW ResourceCache( 50, pFile );

	if ( !m_pResCache->Init() )
	   {
      ENG_ERROR("Failed to initialize resource cache!  Are your paths set up correctly?");
		return false;
	   }

 //  extern shared_ptr<IResourceLoader> CreateWAVResourceLoader();
   m_pResCache->RegisterLoader< XmlResourceLoader >();
   m_pResCache->RegisterLoader< MeshResourceLoader >();
   m_pResCache->RegisterLoader< TextureResourceLoader >();
   m_pResCache->RegisterLoader< ScriptResourceLoader >();

   if( !LoadStrings("English") )
	   {
      ENG_ERROR("Failed to load strings");
		return false;
	   }
   //--------------------------------- 
   //  Initialize ResCache
   //--------------------------------- 

   //--------------------------------- 
   //  Initialize Lua scripting
   //---------------------------------

   // Rez up the Lua State manager now, and run the initial script - discussed in Chapter 5, page 144.
   if( !LuaStateManager::GetSingleton().VInit() )
      {
      ENG_ERROR( "Failed to initialize Lua" );
      return false;
      }

   ScriptExports::Register();
   
   Resource resource( m_EngineOptions.GetPreInitScriptFile() );
   shared_ptr<ResHandle> pResourceHandle = m_pResCache->GetHandle( resource );  
   ENG_ASSERT( pResourceHandle );

   RegisterScriptClass< AnimationClipNode, IAnimationNode >();
   RegisterScriptClass< AnimationLerpNode, IAnimationNode >();
   RegisterScriptClass< AnimationState >();

   //--------------------------------- 
   //  Initialize Lua scripting
   //---------------------------------

   //--------------------------------- 
   //  Initialize EventManager
   //--------------------------------- 

   // Set as global EventManager
   m_pEventManager = ENG_NEW EventManager( "Engine Event Manager", true );
	if ( !m_pEventManager )
	   {
		ENG_ERROR( "Failed to create EventManager." );
		return false;
	   }
   
   //--------------------------------- 
   //  Initialize EventManager
   //--------------------------------- 


   //--------------------------------- 
   // Initiate window & SDL, glew
   //--------------------------------- 
   if ( SDL_Init(SDL_INIT_EVERYTHING) != 0 )
      {
      ENG_ERROR( SDL_GetError() );
      return false;
      }

   CHAR charTitle[100];
   if(  GenericToAnsiCch( charTitle, VGetGameTitle(),  strlen( charTitle ) ) != S_OK )
      {
      ENG_ERROR( "Game title translation failed" );
      }
   if( !window )
      {
      m_pWindow = SDL_CreateWindow( charTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenWidth,screenHeight, SDL_WINDOW_OPENGL );
      if ( !m_pWindow ) 
         {
         ENG_ERROR( SDL_GetError() );
         return false;
         }
      }
   else
      {
      m_pWindow = window;
      }

   // Only if execute under editor can engine allow file drop 
   if( m_EngineOptions.GetEngineEnvironment() == Environment_Editor )
      {
      SDL_EventState( SDL_DROPFILE, SDL_ENABLE );
      }

   if( m_EngineOptions.GetShowMouseCursor() )
      {
      SDL_ShowCursor( SDL_ENABLE );
      }
   else
      {
      SDL_ShowCursor( SDL_DISABLE );
      }
   
   SDL_WarpMouseInWindow( g_pApp->GetWindow(), g_pApp->GetScreenSize().GetX() / 2, g_pApp->GetScreenSize().GetY() / 2 );
   // setup opengl rendering context
   SDL_GLContext glContext = SDL_GL_CreateContext( m_pWindow );
   if( !glContext )
      {
      ENG_ERROR( SDL_GetError() );
      }
   
   // Needed for core profile
   glewExperimental = true; 

   GLenum error = glewInit();

   if( error != GLEW_OK )
      {
      ENG_ERROR( reinterpret_cast<const char *>( gluErrorString( error ) ) );
      }
   // set two buffer for rendering
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

   m_ShutDownEventType = RegisterEvent( 1 );
   //--------------------------------- 
   // Initiate window & SDL, glew
   //--------------------------------- 

   //--------------------------------- 
   // SDL_Image
   //--------------------------------- 
   int initFlags= IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF;
   int initted = IMG_Init( initFlags );

   if( ( initted & initFlags ) != initFlags ) 
      {
      ENG_ERROR( IMG_GetError() );
      }
   //--------------------------------- 
   // SDL_Image
   //--------------------------------- 

   //--------------------------------- 
   // Set Renderer
   //--------------------------------- 
    if( GetRendererImpl() == Renderer_OpenGL )
      {
      m_pRenderer = shared_ptr<IRenderer>( ENG_NEW OpenGLRenderer() );
      }
   else
      {
      ENG_ERROR( "Not supported renderer type" );
      }
   m_pRenderer->VSetBackgroundColor( g_Black );
   // Enable depth test
	glEnable( GL_DEPTH_TEST );
	// Accept fragment if it closer to the camera than the former one
	glDepthFunc( GL_LESS ); 
   // Cull triangles which normal is not towards the camera
   glEnable( GL_CULL_FACE );
   m_pRenderer->VOnRestore();
   //--------------------------------- 
   // Set Renderer
   //--------------------------------- 


   // Start global timer
   GetGlobalTimer()->Reset();

   // initialize the directory location you can store save game files
	_tcscpy_s( m_saveGameDirectory, GetSaveGameDirectory( GetHwnd(), VGetGameAppDirectory() ) );
   //--------------------------------- 
   // Create game & view
   //--------------------------------- 
   m_pEngineLogic = VCreateLogic();
   if (!m_pEngineLogic)
      {
      return false;
      }
   //--------------------------------- 
   // Create game & view
   //--------------------------------- 
   m_bIsRunning = true;

   return true;
   }
Example #10
0
bool Application::VInitializeInstance()
	{
		/*m_pGame = VCreateGameAndView();
		if (!m_pGame)
			return false;*/

		//
		// Initialize the ResCache - Chapter 5, page 141
		//
		//    Note - this is a little different from the book. Here we have a speccial resource ZIP file class, DevelopmentResourceZipFile,
		//    that actually reads directly from the source asset files, rather than the ZIP file. This is MUCH better during development, since
		//    you don't want to have to rebuild the ZIP file every time you make a minor change to an asset.
		//
		//IResourceFile *zipFile = (m_bIsEditorRunning || m_Options.m_useDevelopmentDirectories) ? 
			//WE_NEW DevelopmentResourceZipFile(L"Assets.zip", DevelopmentResourceZipFile::Editor) :
		IResourceFile *ZipFile = WE_NEW ResourceZipFile(L"Assets.zip");

		m_ResCache = WE_NEW ResCache(50, ZipFile);

		if (!m_ResCache->Init())
		{
			printf("Failed to initialize resource cache!  Are your paths set up correctly?");
			return false;
		}

		//extern shared_ptr<IResourceLoader> CreateWAVResourceLoader();
		//extern shared_ptr<IResourceLoader> CreateOGGResourceLoader();
		//extern shared_ptr<IResourceLoader> CreateDDSResourceLoader();
		//extern shared_ptr<IResourceLoader> CreateJPGResourceLoader();

		extern shared_ptr<IResourceLoader> CreateXMLResourceLoader();
		//extern shared_ptr<IResourceLoader> CreateSdkMeshResourceLoader();
		//extern shared_ptr<IResourceLoader> CreateScriptResourceLoader();

		// Note - register these in order from least specific to most specific! They get pushed onto a list.
		// RegisterLoader is discussed in Chapter 5, page 142
		//m_ResCache->RegisterLoader(CreateWAVResourceLoader());
		//m_ResCache->RegisterLoader(CreateOGGResourceLoader());
		//m_ResCache->RegisterLoader(CreateDDSResourceLoader());
		//m_ResCache->RegisterLoader(CreateJPGResourceLoader());
		m_ResCache->RegisterLoader(CreateXMLResourceLoader());
		//m_ResCache->RegisterLoader(CreateSdkMeshResourceLoader());
		//m_ResCache->RegisterLoader(CreateScriptResourceLoader());

		m_ProcessManager = new ProcessManager;
		m_pEventManager = WE_NEW EventManager("Warp Engine Generic Event Manager", true);

		EventListenerDelegate DelegateFunction = fastdelegate::MakeDelegate(this, &Application::EngineLoadedDelegate);
		IEventManager::Get()->VAddListener(DelegateFunction, EventData_Engine_Loaded::sk_EventType);

		TS = WE_NEW TestSystem();
		TS->Initialize();
		
		// Create a window
		//IWindow* Wind = new GLFWWindow();
		//Wind->VInitializeInstance(640, 400, "Main Window");

		// Splash Screen Creation
		m_pSplash = new GLFWSplashScreen();
		m_pSplash->VInitializeInstance(1024, 512, "Splash");

		// Renderer setup
		m_Renderer = shared_ptr<IRenderer>(WE_NEW OpenGLRenderer());
		//m_Renderer->SetBackgroundColor()

		// Temporary!
		m_pGame = WE_NEW BaseGameLogic;
		if (!m_pGame)
			return false;

		
		Human = WE_NEW HumanView(m_Renderer);
		m_pGame->VAddView(shared_ptr<IGameView>(Human));

		Human->SetWindow(m_pSplash);
		m_pSplash->VOnUpdate(1.0f);
		m_pSplash->VOnRender();
		//Human->SetWindow(Wind);

		StrongProcessPtr EngineLoad(new ProcessEngineLoad(3));
		m_ProcessManager->AttachProcess(EngineLoad);

		//m_Renderer->VAddRenderTarget(Wind);
		/*
		Mat4x4 Mat = Mat4x4();
		Mat.BuildRotationX(0.5f);
		Mat.BuildTranslation(2.0f, 3.0f, 10.0f);
		Mat.BuildTranslation(1.0f, 0.0f, 0.0f);
		Mat.BuildTranslation(1.0f, 0.0f, 0.0f);
		Mat.BuildTranslation(1.0f, 0.0f, 0.0f);
		Mat.BuildTranslation(1.0f, 0.0f, 0.0f);
		Mat.BuildTranslation(2.0f, 0.0f, 0.0f);
	
	StrongProcessPtr Render(new ProcessRender());

	StrongProcessPtr Delay(new ProcessDelay(10));
	StrongProcessPtr Delay2(new ProcessDelay(2));
	m_ProcessManager->AttachProcess(Delay);
	Delay->AttachChild(Delay2);
	Delay->AttachChild(Render);
	*/
		return true;
	}