예제 #1
0
void CreateCameraBox(Game *pGame)
{
	Vector3 pos;
	pos.x = 0; pos.y = 0; pos.z = 0;
	GameObject *pObj = pGame->CreateObject(pos,Quaternion(pos.x,0,0,0),"testent",eStaticMeshObject,false);
	// render mesh component
	OgreRenderInstanceComponent *pORC = dynamic_cast<OgreRenderInstanceComponent *>(pGame->CreateComponent(GameComponent::eCom_Render3D));
	if (pORC) pORC->Create("Box01.mesh",pObj,true);
	pObj->AddComponent(pORC);
	// animation handler component
	AnimationComponent *pAnim = dynamic_cast<AnimationComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleAnimation));
	pAnim->setParent(pObj);
	pAnim->Init(0.001f);
	pObj->AddComponent(pAnim);

	pGame->AddGob(pObj);

	// path controller component
	PathCameraComponent *pPath = dynamic_cast<PathCameraComponent *>(pGame->CreateComponent(GameComponent::eCom_PathCameraController));
	if(pPath)
	{
		pObj->AddComponent(pPath);
		pPath->Init();
	}

}
예제 #2
0
void CreateRandomRobot(Game *pGame)
{
	Vector3 pos = pGame->getRandomVector(2000.0f);
	
	GameObject *pRobot = pGame->CreateObject(pos,Quaternion(1,0,0,0),"testent",eStaticMeshObject,false);
	OgreRenderInstanceComponent *pORC = dynamic_cast<OgreRenderInstanceComponent *>(pGame->CreateComponent(GameComponent::eCom_Render3D));
	if (pORC) pORC->Create("robot.mesh",pRobot,true);
	pRobot->AddComponent(pORC);
	MoverComponent *pMover = dynamic_cast<MoverComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleMover));
	pMover->setParent(pRobot);
	pMover->Init(1000.0f,70.0f,40.0f,pos,1.5f,true);
	pRobot->AddComponent(pMover);
	AnimationComponent *pAnim = dynamic_cast<AnimationComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleAnimation));
	pAnim->setParent(pRobot);
	pAnim->Init(0.001f);
	pRobot->AddComponent(pAnim);

	
	// a selector component, this allows a gameobject to know wether its selected or not
   SelectionComponent *pSelect = dynamic_cast<SelectionComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleSelection));
   pSelect->setParent(pRobot);
   pSelect->Init();
   pRobot->AddComponent(pSelect);
	
	pGame->AddGob(pRobot);
}