Beispiel #1
0
bool Game::initialize() {
	if( !initializeOgre() )
		return false;

	if( !initializeCEGUI() )
		return false;

	if( !initializeOIS() )
		return false;

	if( !initializeBullet() )
		return false;

	//create the plane in Ogre3D
	Ogre::Plane plane(Ogre::Vector3::UNIT_Z, -15);
	Ogre::MeshManager::getSingleton().createPlane("ground", "meshes", plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Y);
	Ogre::Entity* entGround = m_pScene->createEntity("ground");
	Ogre::SceneNode* groundNode = m_pScene->getRootSceneNode()->createChildSceneNode("groundNode");
	groundNode->attachObject(entGround);
	entGround->setMaterialName("BluePill");

	//create the Bullet ground plane
	m_pGroundShape = new btStaticPlaneShape(btVector3(0, 0, 1), -15);
	m_pGroundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0, -1)));
	btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0, m_pGroundMotionState, m_pGroundShape, btVector3(0, 0, 0));
	m_pGroundBody = new btRigidBody(groundRigidBodyCI);
	m_pDynamicsWorld->addRigidBody(m_pGroundBody);

	//create the player in Ogre3D
	Ogre::String meshname = "Pill.mesh";
	Ogre::Entity* entity = m_pScene->createEntity(meshname);
	m_pPlayerSceneNode = m_pRootSceneNode->createChildSceneNode();
	m_pPlayerSceneNode->attachObject(entity);
	m_pPlayerSceneNode->scale(Ogre::Vector3(0.5f, 0.5f, 0.5f));
	m_PlayerPosition = Ogre::Vector3(0.0f, 0.0f, -10.0f);
	m_PlayerVelocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
	m_pPlayerSceneNode->translate(m_PlayerPosition);

	//create the Bullet player
	m_pPlayerShape = new btBoxShape(btVector3(1,1,1));
	m_pPlayerMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0, -10)));
	btScalar playerMass = 1;
	btVector3 playerInertia(0, 0, 0);
	m_pPlayerShape->calculateLocalInertia(playerMass, playerInertia);
	btRigidBody::btRigidBodyConstructionInfo playerRigidBodyCI(playerMass, m_pPlayerMotionState, m_pPlayerShape, playerInertia);
	m_pPlayerBody = new btRigidBody(playerRigidBodyCI);
	//body->setRestitution(1);
	m_pPlayerBody->setUserPointer(m_pPlayerSceneNode);
	m_pDynamicsWorld->addRigidBody(m_pPlayerBody);

	return true;
}//Game::initialize
/**
 * @brief      Initializes any OpenGL operations.
 */
void OGLWidget::initializeGL()
{
    // Init OpenGL Backend
    initializeOpenGLFunctions();
    printContextInfo();
    initializeBullet();

    for( QMap<QString, Renderable*>::iterator iter = renderables.begin();
            iter != renderables.end(); iter++ )
    {
        (*iter)->initializeGL();
    }

    m_dynamicsWorld->addRigidBody(
        ((Board*)renderables["Board"])->RigidBody, COL_TABLE, tableCollidesWith );
    m_dynamicsWorld->addRigidBody(
        ((Cube*)renderables["Cube"])->RigidBody, COL_CUBE, cubeCollidesWith );
}
Beispiel #3
0
void LetterHunter::initialize()
{
	// Initizlie text objects
	initializeText();
	initializeBullet();
}