City* Game::CreateCity( const Point& pos, Faction& owner ) { // Create a graphical entity ITexture* pTexture = AssetManager::Get().GetAsset< ITexture >( "BTNSteelMelee.png" ); Material* pMaterial = AssetManager::Get().GetAsset<Material>( "Materials/GhoulMat.xmat" ); // Create entity Entity* pCubeEntity = GameManager::CreateEntity(); MeshComponent* pMesh = pCubeEntity->AddComponent<MeshComponent>(); pMesh->SetMesh( Mesh::CreateBox() ); pMesh->GetMesh()->Release(); pMesh->SetMaterial( pMaterial ); pCubeEntity->GetTransform().SetPosition( m_pWorld->GetPositionForTile( pos.x, pos.y ) ); // Create the city City* pCity = pCubeEntity->AddComponent<City>(); pCity->SetFaction( &owner ); m_Cities.push_back( pCity ); pCity->AddRef(); m_pWorld->SetEntityPosition( pCubeEntity, pos.x, pos.y ); return pCity; }
void GCL::RenderComponent::PostInit() { //must find the mesh component and hook it up with us if (!mParentActor->HasComponent("MeshComponent")) return; Component *meshComponent = mParentActor->GetComponent("MeshComponent"); MeshComponent *tempMeshComponent = static_cast<MeshComponent*>(meshComponent); if (!tempMeshComponent->HasMesh()) return; Mesh &mesh = tempMeshComponent->GetMesh(); switch ((size_t)mesh.GetVertexType()) { case ePOSITION: mObj = new RenderObject(mesh.GetMaterial(), (const VertexP*)mesh.GetVertexData(0), mesh.GetVertexCount(0)); break; case ePOSITION|eNORMAL: mObj = new RenderObject(mesh.GetMaterial(), (const VertexPN*)mesh.GetVertexData(0), mesh.GetVertexCount(0)); break; case ePOSITION|eNORMAL|eTEXTURE_COORD: mObj = new RenderObject(mesh.GetMaterial(), (const VertexPNT*)mesh.GetVertexData(0), mesh.GetVertexCount(0)); break; default: GCLAssert(false); } }