本文整理汇总了C++中ogre::Entity::getBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::getBoundingBox方法的具体用法?C++ Entity::getBoundingBox怎么用?C++ Entity::getBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::getBoundingBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMesh
//-------------------------------------------------------------------------------------------
void MagickWidget::loadMesh(Ogre::MeshPtr pMesh)
{
QString directory(OgitorsRoot::getSingletonPtr()->GetProjectOptions()->ProjectDir.c_str());
if(directory.isEmpty())
directory = "./";
QDir(directory).mkpath("entitycache");
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "MeshMagickTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
512, 512, 0, Ogre::PF_R8G8B8A8 , Ogre::TU_RENDERTARGET );
Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget();
Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "MeshMagickTexMgr");
Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight");
dirl->setDirection(-1,-1,-1);
dirl->setDiffuseColour(1,1,1);
dirl->setType(Ogre::Light::LT_DIRECTIONAL);
Ogre::Camera* RTTCam = mSceneMgr->createCamera("MeshMagickCam");
RTTCam->setNearClipDistance(0.01F);
RTTCam->setFarClipDistance(0);
RTTCam->setAspectRatio(1);
RTTCam->setFOVy(Ogre::Degree(90));
RTTCam->setPosition(0,0,1);
RTTCam->lookAt(0,0,0);
Ogre::Viewport *v = rttTex->addViewport( RTTCam );
v->setClearEveryFrame( true );
v->setBackgroundColour(Ogre::ColourValue(0,0,0));
Ogre::Entity *mEntity;
mEntity = mSceneMgr->createEntity("scbDisplay", pMesh->getName());
mSceneMgr->getRootSceneNode()->attachObject(mEntity);
Ogre::Vector3 vSize = mEntity->getBoundingBox().getHalfSize();
Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter();
vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z);
float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z);
vSize = Ogre::Vector3(0, 0, maxsize * 1.15f) + vCenter;
RTTCam->setPosition(vSize.x,vSize.y,vSize.z);
RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z);
rttTex->update();
Ogre::String imagefile = OgitorsUtils::QualifyPath(directory.toStdString() + "/entitycache/meshmagick.png");
rttTex->writeContentsToFile(imagefile);
mEntity->detachFromParent();
mSceneMgr->destroyEntity(mEntity);
rttTex->removeAllViewports();
Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr);
mDisplayWidget->setImage(QString(imagefile.c_str()));
}
示例2: OnEditsceneAddentity
void CSceneEditorView::OnEditsceneAddentity()
{
CEntityCreatorDlg EntityCreatorDlg;
if (IDOK == EntityCreatorDlg.DoModal())
{
HTREEITEM Selected = m_SceneManagerDlg->m_SceneTree.GetSelectedItem();
m_SceneManagerDlg->m_SceneTree.InsertItem(EntityCreatorDlg.m_EntityName, Selected);
Ogre::String SceneNodeName = m_SceneManagerDlg->m_SceneTree.GetItemText(Selected);
Ogre::Entity *Entity = m_SceneManager->createEntity(Ogre::String(EntityCreatorDlg.m_EntityName), Ogre::String(EntityCreatorDlg.m_MeshName));
Ogre::SceneNode *SceneNode = m_SceneManager->getSceneNode(SceneNodeName);
SceneNode->attachObject(Entity);
Ogre::AxisAlignedBox Box = Entity->getBoundingBox();
Ogre::Vector3 Center = Box.getCenter();
m_Camera->lookAt(Center);
m_SceneManagerDlg->m_SceneTree.Expand(Selected, TVE_EXPAND);
if (m_Root != NULL)
{
m_Root->renderOneFrame();
}
}
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:26,代码来源:SceneEditorView.cpp
示例3: _updateBoundingBox
void VLogicModel::_updateBoundingBox()
{
if (VNULL == mFullBoundingBox)
{
mFullBoundingBox = new Ogre::AxisAlignedBox();
}
mFullBoundingBox->setNull();
for (VEntityMap::iterator itr = mEntities.begin(); itr != mEntities.end(); ++itr)
{
Ogre::Entity *entity = itr->second.mEntity;
if (entity != VNULL)
{
mFullBoundingBox->merge(entity->getBoundingBox());
}
}
VAttachedModelOriginSceneNodes::const_iterator itr = mAttachedModelOriginSceneNodes.begin();
while (itr != mAttachedModelOriginSceneNodes.end())
{
if (itr->first)
{
mFullBoundingBox->merge(itr->first->_getFullBoundingBox());
}
++itr;
}
}
示例4: _calculateExtents
void InputGeometry::_calculateExtents()
{
Ogre::Entity* ent = _sourceMeshes[0];
Ogre::AxisAlignedBox sourceMeshBB = ent->getBoundingBox();
Ogre::Matrix4 transform;
transform = _referenceNode->_getFullTransform().inverse() * ent->getParentSceneNode()->_getFullTransform();
sourceMeshBB.transform(transform);
Ogre::Vector3 min = sourceMeshBB.getMinimum();
Ogre::Vector3 max = sourceMeshBB.getMaximum();
for(auto itr = _sourceMeshes.begin(); itr != _sourceMeshes.end(); ++itr)
{
Ogre::Entity* tmpEnt = *itr;
transform = _referenceNode->_getFullTransform().inverse() * tmpEnt->getParentSceneNode()->_getFullTransform();
sourceMeshBB = ent->getBoundingBox();
sourceMeshBB.transform(transform);
Ogre::Vector3 min2 = sourceMeshBB.getMinimum();
if(min2.x < min.x)
min.x = min2.x;
if(min2.y < min.y)
min.y = min2.y;
if(min2.z < min.z)
min.z = min2.z;
Ogre::Vector3 max2 = sourceMeshBB.getMaximum();
if(max2.x > max.x)
max.x = max2.x;
if(max2.y > max.y)
max.y = max2.y;
if(max2.z > max.z)
max.z = max2.z;
}
if(!_boundMin)
{
_boundMin = new float[3];
}
if(!_boundMax)
{
_boundMax = new float[3];
}
Utility::vector3_toFloatPtr(min,_boundMin);
Utility::vector3_toFloatPtr(max,_boundMax);
}
示例5: mass
/* -----------------------------------------------------------------------
| build bullet box shape
|
| : default create 125 (5x5x5) dynamic object
----------------------------------------------------------------------- */
bool
buildBoxShapeArray(Ogre::SceneManager* sceneMgr, btDynamicsWorld* dynamicsWorld, btAlignedObjectArray<btCollisionShape*>& collisionShapes,
const btVector3& array_size, btScalar scale)
{
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(1.f);
btVector3 localInertia(0,0,0);
btBoxShape* colShape = new btBoxShape(btVector3(scale, scale, scale));
btAssert(colShape);
colShape->calculateLocalInertia(mass,localInertia);
collisionShapes.push_back(colShape);
float start_x = - array_size.getX()/2;
float start_y = array_size.getY();
float start_z = - array_size.getZ()/2;
int index = 0;
for (int k=0;k<array_size.getY();k++)
{
for (int i=0;i<array_size.getX();i++)
{
for(int j=0;j<array_size.getZ();j++)
{
startTransform.setOrigin(scale * btVector3(
btScalar(2.0*i + start_x),
btScalar(20+2.0*k + start_y),
btScalar(2.0*j + start_z)));
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
body->setContactProcessingThreshold(BT_LARGE_FLOAT);
if (sceneMgr)
{
Ogre::Entity* ent = sceneMgr->createEntity("ent_" + Ogre::StringConverter::toString(index++),"Barrel.mesh");
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("node_box_" + Ogre::StringConverter::toString(index++));
node->attachObject(ent);
node->setPosition(startTransform.getOrigin().getX(), startTransform.getOrigin().getY(), startTransform.getOrigin().getZ());
const Ogre::AxisAlignedBox& aabb = ent->getBoundingBox();
const Ogre::Vector3& boxScale = (aabb.getMaximum() - aabb.getMinimum())/2.0f;
node->scale(scale/boxScale.x, scale/boxScale.y, scale/boxScale.z);
body->setUserPointer((void*)node);
}
dynamicsWorld->addRigidBody(body);
}
}
}
return true;
}
示例6: createInstance
Monster* MonsterFactory::createInstance(SceneManager* sceneMgr, Maze* maze, MonsterManager* monsterMgr)
{
Ogre::SceneNode* monsterNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* entity = sceneMgr->createEntity(mParams["mesh"]);
//entity->setCastShadows(true);
monsterNode->attachObject(entity);
Monster* mon;
mon = new Monster(monsterNode, entity, maze, monsterMgr);
if (mParams.find("radius") != mParams.end())
mon->setRadius((float)atof(mParams["radius"].c_str()));
if (mParams.find("blood") != mParams.end())
{
mon->setBlood((float)atof(mParams["blood"].c_str()));
mon->setMaxBlood(mon->getBlood());
}
if (mParams.find("speed") != mParams.end())
mon->setSpeed((float)atof(mParams["speed"].c_str()));
if (mParams.find("spell") != mParams.end())
mon->setType((mParams["spell"].c_str()));
if (mParams.find("scale") != mParams.end())
{
float scale = (float)atof(mParams["scale"].c_str());
mon->setScale(scale, scale, scale);
}
//mon->setScale(2, 2, 2);
// 创建怪物头顶血条
BillboardSet* healthHUD = sceneMgr->createBillboardSet();
healthHUD->setMaterialName("Glass/Billboard");
healthHUD->setDefaultWidth(100);
healthHUD->setDefaultHeight(14);
SceneNode* hudNode = monsterNode->createChildSceneNode();
hudNode->attachObject(healthHUD);
/*Billboard* b2 = healthHUD->createBillboard(0, entity->getBoundingBox().getSize().y, 0);
b2->setColour(ColourValue::Black);*/
Billboard* b = healthHUD->createBillboard(0, entity->getBoundingBox().getSize().y, 0);
//b->setColour(ColourValue(0, 0.75f, 0));
//b->setDimensions(96, 12);
mon->setHealthHUD(healthHUD);
// 测试粒子by kid
Ogre::ParticleSystem* ps = sceneMgr->createParticleSystem(monsterNode->getName() + "frozen", "Glass/MonsterFrozen");
monsterNode->attachObject(ps);
ps->setVisible(false);
ps = sceneMgr->createParticleSystem(monsterNode->getName() + "burn", "Glass/MonsterBurn");
monsterNode->attachObject(ps);
ps->setVisible(false);
return mon;
}
示例7: create
int Create_Static_Object::create(Ogre::SceneManager *mainSceneMgr) {
if (meshName.empty() ) {
std::cout << "Whoops, what do you think you're doing? You didn't give a mesh name!" << std::endl;
return 0;
}
if (meshFile.empty() ) {
std::cout << "Well what did you expect? There's no mesh file to load!" << std::endl;
return 0;
}
Ogre::SceneNode *nodeStaticObject = mainSceneMgr->getRootSceneNode()->createChildSceneNode(meshName, location, rotation);
Ogre::Entity *entityStaticObject = mainSceneMgr->createEntity(meshName, meshFile);
if (!materialName.empty() ){
entityStaticObject->setMaterialName(materialName);
}
entityStaticObject->setCastShadows(shadow);
nodeStaticObject->attachObject(entityStaticObject);
nodeStaticObject->showBoundingBox(showBBox);
nodeStaticObject->scale(scale);
//Create the ground shape.
BtOgre::StaticMeshToShapeConverter ogreBulletShapeConverter(entityStaticObject);
if (bulletCollision == "sphere"){
shapeStaticObject = ogreBulletShapeConverter.createSphere();
} else if (bulletCollision == "box"){
shapeStaticObject = ogreBulletShapeConverter.createBox();
offsetLocation = entityStaticObject->getBoundingBox().getHalfSize();
location.y = location.y - offsetLocation.y;
} else if (bulletCollision == "trimesh"){
shapeStaticObject = ogreBulletShapeConverter.createTrimesh();
} else if (bulletCollision == "cylinder"){
shapeStaticObject = ogreBulletShapeConverter.createCylinder();
} else if (bulletCollision == "convex"){
shapeStaticObject = ogreBulletShapeConverter.createConvex();
}else{
return 0;
}
shapeStaticObject->setLocalScaling(BtOgre::Convert::toBullet(nodeStaticObject->getScale() ) );
//Create MotionState (no need for BtOgre here, you can use it if you want to though).
stateStaticObject = new btDefaultMotionState(btTransform( BtOgre::Convert::toBullet(rotation), BtOgre::Convert::toBullet(location) ) );
//Create the Body.
bodyStaticObject = new btRigidBody(0, stateStaticObject, shapeStaticObject, btVector3(0,0,0));
Globals::phyWorld->addRigidBody(bodyStaticObject);
return 1;
}
示例8: LoadFromHeightMap
//-------------------------------------------------------
void Ground::LoadFromHeightMap(std::shared_ptr<Ogre::Image> hmap, Ogre::SceneNode* parentNode)
{
mImage = hmap;
Ogre::Box box = Ogre::Box(0, 0, mImage->getWidth(), mImage->getHeight());
mRootNode = parentNode->createChildSceneNode();
mGlobalBoundingBox.setNull();
Ogre::Material* groundMaterial = CreateGroundMaterialTextured("Material/" + CLASS_NAME + "/Textured", mImage.get());
static const float VERTEX_STEP = 1.0f;
static const float HEIGHT_STEP = 8.0f;
float offsetX = GROUND_SIZE * VERTEX_STEP / 2.0f;
float offsetY = GROUND_SIZE * VERTEX_STEP / 2.0f;
size_t width = mImage->getWidth();
size_t height = mImage->getHeight();
float texStep = 1.0f / REGIONS_NUMBER;
size_t texRegionWidth = static_cast<size_t>(std::ceil(static_cast<float>(width) / REGIONS_NUMBER));
size_t texRegionHeight = static_cast<size_t>(std::ceil(static_cast<float>(height) / REGIONS_NUMBER));
for (size_t y = 0; y < REGIONS_NUMBER; ++y)
{
size_t top = y * texRegionHeight;
for (size_t x = 0; x < REGIONS_NUMBER; ++x)
{
size_t left = x * texRegionWidth;
Ogre::Box roi = Ogre::Box(left, height - std::min(top + texRegionHeight + 1, height), std::min(left + texRegionWidth + 1, width), height - top);
Ogre::MeshPtr mesh = CreateRegion(y * REGIONS_NUMBER + x, groundMaterial->getName(), roi,
Ogre::Vector3(x * VERTEX_STEP * REGION_SIZE - offsetX, y * VERTEX_STEP * REGION_SIZE - offsetY, 0.0f),
Ogre::Vector3(VERTEX_STEP, VERTEX_STEP, HEIGHT_STEP),
Ogre::Vector2(x * texStep, 1.0f - (y + 1) * texStep));
Ogre::Entity* entity = mSceneManager->createEntity(mesh);
auto node = mRootNode->createChildSceneNode();
node->attachObject(entity);
node->showBoundingBox(true);
mGlobalBoundingBox.merge(entity->getBoundingBox());
mEntities.push_back(entity);
}
}
}
示例9: createBox
Ogre::SceneNode* createBox(Ogre::SceneManager* sceneMgr, Ogre::String name)
{
// create an ordinary Ogre mesh with texture
Ogre::Entity* boxEnt = sceneMgr->createEntity(name , "cube.mesh");
// we need the bounding box of the cube.mesh to set the size of the Bullet box
Ogre::AxisAlignedBox boxBb = boxEnt->getBoundingBox();
//Ogre::Vector3 size = boxBb.getSize();
boxEnt->setMaterialName("Examples/BumpyMetal");
// create the node
Ogre::SceneNode* boxNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject( boxEnt );
return boxNode;
}
示例10: sceneNodeCreated
void OgreColladaContentImporter::sceneNodeCreated(Ogre::SceneNode* pNode, FCDSceneNode* pFColladaSceneNode)
{
NxOgre::ActorParams actorParams;
NxOgre::ShapeParams shapeParams;
Ogre::Vector3 boxSize;
Ogre::Vector3 scale;
Ogre::Entity *pEntity;
std::list<Ogre::Entity*> entityList;
std::list<Ogre::Entity*>::iterator entityListIter;
NxVec3 row;
pEntity = NULL;
Ogre::SceneNode::ObjectIterator iter = pNode->getAttachedObjectIterator();
while (iter.hasMoreElements())
{
pEntity = dynamic_cast<Ogre::Entity*>(iter.getNext());
if (pEntity != NULL)
{
entityList.push_back(pEntity);
}
}
shapeParams.setToDefault();
//scale = pNode->_getDerivedScale();
//shapeParams.mMeshScale = NxVec3(scale.x, scale.y, scale.z);
for (entityListIter = entityList.begin(); entityListIter != entityList.end(); ++entityListIter)
{
pEntity = *entityListIter;
boxSize = pEntity->getBoundingBox().getSize();
pNode->detachObject(pEntity);
actorParams.setToDefault();
actorParams.mMass = 0.0f;
actorParams.mBodyFlags |= NX_BF_KINEMATIC;
GameObjectFactory::getSingleton().makeBody(pEntity->getName(), pNode, pEntity, scene
,new NxOgre::CubeShape(boxSize.x, boxSize.y, boxSize.z, shapeParams), actorParams);
}
sceneNodes.push_back(pNode);
}
示例11: setupNodes
void Player::setupNodes (Ogre::SceneManager* sceneManager)
{
// Create the nodes
mPlayerNode = sceneManager->getRootSceneNode()->createChildSceneNode("PlayerNode");
mPlayerCameraNode = mPlayerNode->createChildSceneNode("PlayerCameraNode");
mCharacterNode = mPlayerNode->createChildSceneNode("PlayerCharacterNode");
mTargettingPathNode = mPlayerNode->createChildSceneNode("PlayerPathNode");
mTargettingEndNode = sceneManager->getRootSceneNode()->createChildSceneNode("TargettingEndNode");
mTargettingPathNode->setVisible(false);
mPlayerCameraNode->setPosition(0, 100, 200);
// Add the entities
// Add player
Ogre::Entity* playerEntity = sceneManager->createEntity("PlayerCharacter", "potato.mesh");
Ogre::AxisAlignedBox bb = playerEntity->getBoundingBox();
mPlayerHeight = (bb.getMaximum().y - bb.getMinimum().y) * 0.1f * 0.5f;
mCharacterNode->attachObject(playerEntity);
mCharacterNode->setScale(0.1f, 0.1f, 0.1f);
mCharacterNode->setPosition(0, 0, 0);
// Add target marker
mTargettingEndNode = sceneManager->getRootSceneNode()->createChildSceneNode("TargetNode");
Ogre::Entity* targetEntity = sceneManager->createEntity("TargetEntity", "sphere.mesh");
mTargettingEndNode->attachObject(targetEntity);
targetEntity = sceneManager->createEntity("TargetEntity2", "column.mesh");
mTargettingEndNode->attachObject(targetEntity);
mTargettingEndNode->setScale(0.1f, 0.1f, 0.1f);
mTargettingEndNode->setPosition(0, 0, 0);
// Billboard set
/*mTargettingEndBBS = sceneManager->createBillboardSet("TargetBillboardSet", 2);
sceneManager->getRootSceneNode()->attachObject(mTargettingEndBBS);
mTargettingEndBBS->setMaterialName("Examples/Flare");
mTargettingEndBBS->setVisible(true);
mTargettingEndBBS->createBillboard(0, 300, 0, Ogre::ColourValue(0.5f, 0.6f, 1.0f));
mTargettingEndBBS->setDefaultDimensions(100, 100);
mTargettingEndBBS->setBillboardType(Ogre::BBT_ORIENTED_COMMON);
mTargettingEndBBS->setCommonUpVector(Ogre::Vector3(0, 1, 0));*/
}
示例12: mouseReleased
bool TutorialApplication::mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
{
if (m_mode == TrollMode) {
const Vector3 p = m_cursorNode->getPosition();
m_ogres.push_back(p);
Ogre::Entity *troll = m_SceneMgr->createEntity("ogrehead.mesh");
Vector3 bounds = troll->getBoundingBox().getSize();
Real dim = std::max({bounds.x, bounds.y, bounds.z});
Real scale = GRID_SPACING / dim;
bounds = bounds * scale * 0.5f;
Ogre::SceneNode *node = m_SceneMgr->getRootSceneNode()->createChildSceneNode();
node->setPosition(p.x + bounds.x, p.y + bounds.y, p.z + bounds.z);
// node->showBoundingBox(true);
node->scale(scale, scale, scale);
node->attachObject(troll);
}
return BaseApplication::mouseReleased(arg, id);
}
示例13: AddObstacle
void MapManager::AddObstacle(MapArea* area, Objects* input)
{
if(input->mLoaded)
return;
char areaString[30];
sprintf(areaString, "map_area_%d", area->getIndex());
//get the area node from map node.
Ogre::SceneNode* areaNode = (Ogre::SceneNode*)mMapNode->getChild(Ogre::String(areaString));
char cubeString[30];
sprintf(cubeString, "cube_%d", input->index);
Ogre::Entity* cubeEntity = mSceneMgr->createEntity(Ogre::String(cubeString),"cube.mesh");
cubeEntity->setMaterialName("Cube");
//cubeEntity->getMesh()->setAutoBuildEdgeLists(true);
//cubeEntity->getMesh()->buildEdgeList();
cubeEntity->setCastShadows(false);
//create a node for the cube
Ogre::SceneNode* cubeNode = areaNode->createChildSceneNode(Ogre::String(cubeString));
//attach the cube to the node
cubeNode->attachObject(cubeEntity);
//move the cube to it's position
cubeNode->setPosition(input->mPosition);
//cube entity actual size = 100 by 100 by 100
Ogre::Vector3 scale;
scale.x = Ogre::Real(0.01f)*input->sizeWidth;
scale.y = 0.1f;
scale.z = Ogre::Real(0.01f)*input->sizeHeight;
cubeNode->setScale(scale);
input->mLoaded = true;
Ogre::Vector3 size = cubeEntity->getBoundingBox().getSize();
size /= 2.f;
size *= 0.96f;
//size rescale. refer to prac07 for full calculation
size.x *= Ogre::Real(0.01f)*input->sizeWidth;
size.y *= Ogre::Real(0.1f);
size.z *= Ogre::Real(0.01f)*input->sizeHeight;
OgreBulletCollisions::BoxCollisionShape *sceneBoxShape = new OgreBulletCollisions::BoxCollisionShape(size);
OgreBulletDynamics::RigidBody *boxBody = new OgreBulletDynamics::RigidBody("BoxRigid" + Ogre::StringConverter::toString(input->index),
PhysicManager::getSingletonPtr()->getPhysicWorld(),
PhysicManager::COL_OBSTACLE,
PhysicManager::mObstacleCollideWith);
boxBody->setStaticShape(cubeNode, sceneBoxShape,
1.f,
1.f,
input->mPosition,
Ogre::Quaternion(0,0,0,1));
mRigidBodyList.push_back(boxBody);
mNumEntitiesInstanced++;
}
示例14: EngineSetup
void CResourceManagementView::EngineSetup(void)
{
CEngine* Engine = ((CResourceManagementApp*)AfxGetApp())->m_Engine;
Ogre::Root *Root = Engine->GetRoot();
Ogre::SceneManager *SceneManager = NULL;
SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "ResourceManagement");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Resource Management");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("Resource Management", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(200.0, 50.0, 100.0));
m_Camera->lookAt(0.0, 0.0, 0.0);
Ogre::SceneNode *CameraNode = NULL;
CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 1.0f, 0.8f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
Ogre::StringVector Groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
Ogre::Entity *MobiusEntity = Engine->m_StlFileManager->createEntity("Mobius", "1_4.stl");
Ogre::SceneNode *MobiusNode = SceneManager->getRootSceneNode()->createChildSceneNode();
MobiusNode->attachObject(MobiusEntity);
Ogre::AxisAlignedBox MobiusBox = MobiusEntity->getBoundingBox();
Ogre::Vector3 MobiusCenter = MobiusBox.getCenter();
m_Camera->lookAt(MobiusCenter);
Ogre::Real Radius = MobiusEntity->getBoundingRadius();
m_Camera->setPosition(300, 100, 200);
m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);
}
示例15: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif
Ogre::Root *ogre;
Ogre::RenderWindow *window;
Ogre::SceneManager *sceneMgr;
Ogre::SceneManager *guiSceneMgr;
Ogre::Camera *camera;
Ogre::Camera *guiCamera;
// fire up an Ogre rendering window. Clearing the first two (of three) params will let us
// specify plugins and resources in code instead of via text file
ogre = new Ogre::Root("", "");
#if defined(_DEBUG)
ogre->loadPlugin("RenderSystem_GL_d");
#else
ogre->loadPlugin("RenderSystem_GL");
#endif
Ogre::RenderSystemList *renderSystems = NULL;
Ogre::RenderSystemList::iterator r_it;
renderSystems = ogre->getAvailableRenderers();
r_it = renderSystems->begin();
ogre->setRenderSystem(*r_it);
ogre->initialise(false);
// load common plugins
#if defined(_DEBUG)
//ogre->loadPlugin("Plugin_CgProgramManager_d");
ogre->loadPlugin("Plugin_OctreeSceneManager_d");
#else
//ogre->loadPlugin("Plugin_CgProgramManager");
ogre->loadPlugin("Plugin_OctreeSceneManager");
#endif
// load the basic resource location(s)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/gui.zip", "Zip", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("meshes", "FileSystem", "Meshes");
#if defined(WIN32)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\windows\\fonts", "FileSystem", "GUI");
#endif
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Meshes");
// setup main window; hardcode some defaults for the sake of presentation
Ogre::NameValuePairList opts;
opts["resolution"] = "1024x768";
opts["fullscreen"] = "false";
opts["vsync"] = "false";
// create a rendering window with the title "CDK"
window = ogre->createRenderWindow("Bouwgame Client v0.1", 1024, 768, false, &opts);
// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article
// we'll see how to change this
sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
guiSceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
guiCamera = guiSceneMgr->createCamera("GUICamera");
guiCamera->setNearClipDistance(5);
camera = sceneMgr->createCamera("camera");
camera->setNearClipDistance(5);
Ogre::Viewport* vp = window->addViewport(guiCamera);
vp->setBackgroundColour(Ogre::ColourValue(0.2f,0.2f,0.8f));
/* ambient light */
sceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8));
sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
/* meshes */
Ogre::Entity* ent = sceneMgr->createEntity( "BouwPlaatsEntity", "world.mesh" );
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("BouwNode", Ogre::Vector3(0, 0, 0));
node->attachObject(ent);
//node->setScale(Ogre::Vector3(0.7,0.7,0.7));
ent = sceneMgr->createEntity("plaats", "bouwplaats_step_00.mesh");
Ogre::Vector3 size = ent->getBoundingBox().getSize();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats size: ") + Ogre::StringConverter::toString(size));
size = ent->getBoundingBox().getMaximum();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats max: ") + Ogre::StringConverter::toString(size));
size = ent->getBoundingBox().getMinimum();
Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats min: ") + Ogre::StringConverter::toString(size));
Ogre::Entity* ent1 = sceneMgr->createEntity( "KeetEntity", "keet.mesh" );
Ogre::SceneNode* scenenode = sceneMgr->getRootSceneNode()->createChildSceneNode("KeetNode", Ogre::Vector3(0, 0, 0));
scenenode->attachObject(ent1);
Ogre::Entity* ent2 = sceneMgr->createEntity( "HekjeEntity", "hekje.mesh" );
Ogre::SceneNode* scenenode2 = sceneMgr->getRootSceneNode()->createChildSceneNode("HekjeNode", Ogre::Vector3(0, -100, 0));
scenenode2->attachObject(ent2);
scenenode2->setScale(Ogre::Vector3(400,0,100));
// most examples get the viewport size to calculate this; for now, we'll just
//.........这里部分代码省略.........