本文整理汇总了C++中ogre::AxisAlignedBox::getMinimum方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::getMinimum方法的具体用法?C++ AxisAlignedBox::getMinimum怎么用?C++ AxisAlignedBox::getMinimum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox::getMinimum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
InputGeometry::InputGeometry(std::vector<Ogre::Entity*> sourceMeshes,const Ogre::AxisAlignedBox& tileBounds)
: _sourceMeshes(sourceMeshes),
_numVertices(0),
_numTriangles(0),
_referenceNode(0),
_boundMin(0),
_boundMax(0),
_normals(0),
_vertices(0),
_triangles(0)
{
if(sourceMeshes.empty())
{
return;
}
Ogre::Entity* ent = sourceMeshes[0];
_referenceNode = ent->getParentSceneNode()->getCreator()->getRootSceneNode();
_boundMin = new float[3];
_boundMax = new float[3];
Utility::vector3_toFloatPtr(tileBounds.getMinimum(),_boundMin);
Utility::vector3_toFloatPtr(tileBounds.getMaximum(),_boundMax);
_convertOgreEntities(tileBounds);
//eventually add _buildChunkyTriMesh()
}
示例2:
ConvexVolume::ConvexVolume(Ogre::AxisAlignedBox boundingBox, float offset)
{
Ogre::Vector3 max = boundingBox.getMaximum();
Ogre::Vector3 min = boundingBox.getMinimum();
// Offset bounding box (except height)
if(offset > 0.01f) {
max = max + offset*Ogre::Vector3(1,0,1);
min = min - offset*Ogre::Vector3(1,0,1);
}
// Create box verts (in clockwise fashion!!)
verts[0]= min.x; verts[1]= min.y; verts[2]= max.z;
verts[3]= max.x; verts[4]= max.y; verts[5]= max.z;
verts[6]= max.x; verts[7]= max.y; verts[8]= min.z;
verts[9]= min.x; verts[10]= min.y; verts[11]= min.z;
nverts = 4; // For rcMarkConvexPoly the verts of the shape need to be in clockwise order
// Set bounding box limits
OgreRecast::OgreVect3ToFloatA(min, bmin);
OgreRecast::OgreVect3ToFloatA(max, bmax);
// Set height limits
hmin = min.y;
hmax = max.y;
area = SAMPLE_POLYAREA_DOOR; // You can choose whatever flag you assing to the poly area
}
示例3: _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);
}
示例4: convertBounds
void World::convertBounds(Ogre::AxisAlignedBox& bounds)
{
switch (mAlign)
{
case Align_XY:
return;
case Align_XZ:
convertPosition(bounds.getMinimum());
convertPosition(bounds.getMaximum());
// Because we changed sign of Z
std::swap(bounds.getMinimum().z, bounds.getMaximum().z);
return;
case Align_YZ:
convertPosition(bounds.getMinimum());
convertPosition(bounds.getMaximum());
return;
}
}
示例5: updateBoundingBoxAndSphereFromBillboards
void GPUBillboardSet::updateBoundingBoxAndSphereFromBillboards(const std::vector<PhotoSynth::Vertex>& vertices)
{
Ogre::AxisAlignedBox box = calculateBillboardsBoundingBox(vertices);
setBoundingBox(box);
Ogre::Vector3 vmax = box.getMaximum();
Ogre::Vector3 vmin = box.getMinimum();
Ogre::Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength());
mBBRadius = Ogre::Math::Sqrt(sqLen);
}
示例6: mBuildingBlock
ModelBlock::ModelBlock(Ogre::SceneNode* baseNode,const Carpenter::BuildingBlock* buildingBlock, Model::Model* model, Construction* construction)
: mBuildingBlock(buildingBlock)
, mModel(model)
, mModelNode(0)
, mConstruction(construction)
{
mNode = baseNode->createChildSceneNode(Convert::toOgre(buildingBlock->getPosition()), Convert::toOgre(buildingBlock->getOrientation()));
mPointBillBoardSet = mNode->getCreator()->createBillboardSet( std::string("__construction_") + construction->getBluePrint()->getName() + "_" + buildingBlock->getName() + "_billboardset__" + mNode->getName());
mPointBillBoardSet->setDefaultDimensions(1, 1);
mPointBillBoardSet->setMaterialName("carpenter/flare");
mPointBillBoardSet->setVisible(false);
// Ogre::SceneNode* aNode = EmberOgre::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode();
mNode->attachObject(mPointBillBoardSet);
if (model) {
JesusPickerObject* pickerObject = new JesusPickerObject(this, 0);
model->setUserObject(pickerObject);
mModelNode = mNode->createChildSceneNode();
mModelNode->attachObject(model);
model->setQueryFlags(Jesus::CM_MODELBLOCK);
//only autoscale the model if we've not set the scale in the modeldefinition
//TODO: it would of course be best if all models were correctly scaled and this code could be removed
if (model->getDefinition()->getScale() == 0) {
const Ogre::AxisAlignedBox ogreBoundingBox = model->getBoundingBox();
const Ogre::Vector3 ogreMax = ogreBoundingBox.getMaximum();
const Ogre::Vector3 ogreMin = ogreBoundingBox.getMinimum();
const WFMath::AxisBox<3> wfBoundingBox = buildingBlock->getBuildingBlockSpec()->getBlockSpec()->getBoundingBox();
const WFMath::Point<3> wfMax = wfBoundingBox.highCorner();
const WFMath::Point<3> wfMin = wfBoundingBox.lowCorner();
Ogre::Real scaleX;
Ogre::Real scaleY;
Ogre::Real scaleZ;
scaleX = fabs((wfMax.x() - wfMin.x()) / (ogreMax.x - ogreMin.x));
scaleY = fabs((wfMax.z() - wfMin.z()) / (ogreMax.y - ogreMin.y));
scaleZ = fabs((wfMax.y() - wfMin.y()) / (ogreMax.z - ogreMin.z));
mModelNode->setScale(scaleX, scaleY, scaleZ);
}
}
}
示例7: unloadTiles
void OgreDetourTileCache::unloadTiles(const Ogre::AxisAlignedBox &areaToUpdate)
{
// Determine which navmesh tiles have to be removed
float bmin[3], bmax[3];
OgreRecast::OgreVect3ToFloatA(areaToUpdate.getMinimum(), bmin);
OgreRecast::OgreVect3ToFloatA(areaToUpdate.getMaximum(), bmax);
dtCompressedTileRef touched[DT_MAX_TOUCHED_TILES];
int ntouched = 0;
m_tileCache->queryTiles(bmin, bmax, touched, &ntouched, DT_MAX_TOUCHED_TILES);
// Remove tiles
for (int i = 0; i < ntouched; ++i)
{
removeTile(touched[i]);
}
}
示例8: 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));*/
}
示例9: buildTiles
void OgreDetourTileCache::buildTiles(InputGeom *inputGeom, const Ogre::AxisAlignedBox *areaToUpdate)
{
// Use bounding box from inputgeom if no area was explicitly specified
Ogre::AxisAlignedBox updateArea;
if(!areaToUpdate)
updateArea = inputGeom->getBoundingBox();
else
updateArea = *areaToUpdate;
// Reduce bounding area a little with one cell in size, to be sure that if it was already tile-aligned, we don't select an extra tile
updateArea.setMinimum( updateArea.getMinimum() + Ogre::Vector3(m_cellSize, 0, m_cellSize) );
updateArea.setMaximum( updateArea.getMaximum() - Ogre::Vector3(m_cellSize, 0, m_cellSize) );
// Select tiles to build or rebuild (builds a tile-aligned BB)
TileSelection selection = getTileSelection(updateArea);
// Debug drawing of bounding area that is updated
// Remove previous debug drawn bounding box of rebuilt area
if(mDebugRebuiltBB) {
mDebugRebuiltBB->detachFromParent();
m_recast->m_pSceneMgr->destroyManualObject(mDebugRebuiltBB);
mDebugRebuiltBB = NULL;
}
if(DEBUG_DRAW_REBUILT_BB)
mDebugRebuiltBB = InputGeom::drawBoundingBox(selection.bounds, m_recast->m_pSceneMgr);
int tilesToBuildX = (selection.maxTx - selection.minTx)+1; // Tile ranges are inclusive
int tilesToBuildY = (selection.maxTy - selection.minTy)+1;
if(tilesToBuildX * tilesToBuildY > 5)
Ogre::LogManager::getSingletonPtr()->logMessage("Building "+Ogre::StringConverter::toString(tilesToBuildX)+" x "+Ogre::StringConverter::toString(tilesToBuildY)+" navmesh tiles.");
// Build tiles
for (int ty = selection.minTy; ty <= selection.maxTy; ty++) {
for (int tx = selection.minTx; tx <= selection.maxTx; tx++) {
buildTile(tx, ty, inputGeom);
}
}
}
示例10: OnFileOpen
void MaterialEditorFrame::OnFileOpen(wxCommandEvent& event)
{
wxFileDialog * openDialog = new wxFileDialog(this, wxT("Choose a file to open"), wxEmptyString, wxEmptyString,
wxT("All Ogre Files (*.material;*.mesh;*.program;*.cg;*.vert;*.frag)|*.material;*.mesh;*.program;*.cg;*.vert;*.frag|Material Files (*.material)|*.material|Mesh Files (*.mesh)|*.mesh|Program Files (*.program)|*.program|Cg Files (*.cg)|*.cg|GLSL Files(*.vert; *.frag)|*.vert;*.frag|All Files (*.*)|*.*"));
if(openDialog->ShowModal() == wxID_OK)
{
wxString path = openDialog->GetPath();
if(path.EndsWith(wxT(".material")) || path.EndsWith(wxT(".program")))
{
MaterialScriptEditor* editor = new MaterialScriptEditor(EditorManager::getSingletonPtr()->getEditorNotebook());
editor->loadFile(path);
int index = (int)path.find_last_of('\\');
if(index == -1) index = (int)path.find_last_of('/');
editor->setName((index != -1) ? path.substr(index + 1, path.Length()) : path);
EditorManager::getSingletonPtr()->openEditor(editor);
}
else if(path.EndsWith(wxT(".cg")))
{
CgEditor* editor = new CgEditor(EditorManager::getSingletonPtr()->getEditorNotebook());
editor->loadFile(path);
int index = (int)path.find_last_of('\\');
if(index == -1) index = (int)path.find_last_of('/');
editor->setName((index != -1) ? path.substr(index + 1, path.Length()) : path);
EditorManager::getSingletonPtr()->openEditor(editor);
}
else if(path.EndsWith(wxT(".mesh")))
{
Ogre::SceneManager *sceneMgr = wxOgre::getSingleton().getSceneManager();
Ogre::Camera *camera = wxOgre::getSingleton().getCamera();
if(mEntity)
{
sceneMgr->getRootSceneNode()->detachObject(mEntity);
sceneMgr->destroyEntity(mEntity);
mEntity = 0;
}
static int meshNumber = 0;
Ogre::String meshName = Ogre::String("Mesh") + Ogre::StringConverter::toString(meshNumber++);
int index = (int)path.find_last_of('\\');
if(index == -1) index = (int)path.find_last_of('/');
wxString mesh = (index != -1) ? path.substr(index + 1, path.Length()) : path;
mEntity = sceneMgr->createEntity(meshName, mesh.GetData());
sceneMgr->getRootSceneNode()->attachObject(mEntity);
Ogre::AxisAlignedBox box = mEntity->getBoundingBox();
Ogre::Vector3 minPoint = box.getMinimum();
Ogre::Vector3 maxPoint = box.getMaximum();
Ogre::Vector3 size = box.getSize();
wxOgre::getSingleton().setZoomScale(max(size.x, max(size.y, size.z)));
wxOgre::getSingleton().resetCamera();
Ogre::Vector3 camPos;
camPos.x = minPoint.x + (size.x / 2.0);
camPos.y = minPoint.y + (size.y / 2.0);
Ogre::Real width = max(size.x, size.y);
camPos.z = (width / tan(camera->getFOVy().valueRadians())) + size.z / 2;
wxOgre::getSingleton().getCamera()->setPosition(camPos);
wxOgre::getSingleton().getCamera()->lookAt(0,0,0);
wxOgre::getSingleton().getLight()->setPosition(maxPoint * 2);
}
}
}
示例11: clearGeometry
void
Terrain::buildGeometry(Ogre::SceneNode* parent, bool editable)
{
clearGeometry();
assert(parent);
// NB: We must adjust world geometry bounding box, especially for OctreeSceneManager
Ogre::AxisAlignedBox aabb = mData->getBoundBox();
Ogre::Vector3 centre = aabb.getCenter();
const Ogre::Vector3 adjust(2000, 10000, 2000);
const Ogre::Real scale = 1.5f;
aabb.setExtents(
(aabb.getMinimum() - centre) * scale + centre - adjust,
(aabb.getMaximum() - centre) * scale + centre + adjust);
parent->getCreator()->setOption("Size", &aabb);
mEditable = editable;
if (!mData->mXSize || !mData->mZSize)
{
// Do nothing if it's empty terrain.
return;
}
// Prepare atlas texture
for (size_t pixmapId = 0, numPixmap = mData->mPixmaps.size(); pixmapId < numPixmap; ++pixmapId)
{
_getPixmapAtlasId(pixmapId);
}
prepareLightmapTexture();
int depth = mData->mZSize;
int width = mData->mXSize;
int tileSize = mData->mTileSize;
int numTilePerX = mData->mNumTilePerX;
int numTilePerZ = mData->mNumTilePerZ;
if (mEditable)
{
mGridTypeInfos.resize(2);
mGridTypeInfos[0].material.setNull();
mGridTypeInfos[1].material = Ogre::MaterialManager::getSingleton().getByName(
"FairyEditor/GridType");
}
else
{
_initIndexBuffer(tileSize * tileSize);
}
mTiles.reserve(numTilePerX * numTilePerZ);
for (int z = 0; z < numTilePerZ; ++z)
{
for (int x = 0; x < numTilePerX; ++x)
{
// Create the tile
int tileX = x * tileSize;
int tileZ = z * tileSize;
int tileWidth = std::min(width - tileX, tileSize);
int tileDepth = std::min(depth - tileZ, tileSize);
TerrainTile* tile;
if (mEditable)
tile = new TerrainTileEditable(parent, this, tileX, tileZ, tileWidth, tileDepth);
else
tile = new TerrainTileOptimized(parent, this, tileX, tileZ, tileWidth, tileDepth);
// Use the render queue that the world geometry associated with.
tile->setRenderQueueGroup(parent->getCreator()->getWorldGeometryRenderQueue());
// Attach it to the aux data
mTiles.push_back(tile);
}
}
}
示例12: outputTextures
bool MiniMapMaker::outputTextures(void)
{
// 如果需要(纹理大小改变了或第一次输出文件时),就重建render texture
if (mNeedRecreate)
{
destroy();
init();
}
mTempOutputFileNames.clear();
static const String TEMP_GROUP_NAME = "#TEMP#";
// 创建临时的资源组
Ogre::ResourceGroupManager& rgm = Ogre::ResourceGroupManager::getSingleton();
rgm.addResourceLocation(mPath, "FileSystem", TEMP_GROUP_NAME, false);
// 合并所有物体的包围盒
Ogre::AxisAlignedBox aabb;
Ogre::SceneManager::MovableObjectIterator itm =
mManipulator->getSceneManager()->getMovableObjectIterator(Ogre::EntityFactory::FACTORY_TYPE_NAME);
while (itm.hasMoreElements())
{
Ogre::MovableObject* movable = itm.getNext();
aabb.merge(movable->getWorldBoundingBox(true));
}
mCamera->setFarClipDistance(mCamera->getNearClipDistance() + 2 * (aabb.getMaximum().y - aabb.getMinimum().y ));
mCamera->setNearClipDistance(mTileSize/2);
// 设置摄像机的高度
Real yPos = mCamera->getNearClipDistance() + aabb.getMaximum().y;
TerrainData* terrainData = mManipulator->getTerrainData();
assert (terrainData);
float terrainHeight = terrainData->mMaxZ - terrainData->mMinZ;
float terrainWidth = terrainData->mMaxX - terrainData->mMinX;
// 投影的真正面积
Real projectSize = 0.0f;
// 最终切割成小块纹理的块数
int xIndex = 0;
int zIndex = 0;
Ogre::Vector3 originPoint(Ogre::Vector3::ZERO);
if (mUseRealCameraAngle)
{
float outerSquareWidth = 0.0f;
float outerSquareHeight = 0.0f;
Ogre::Radian alphaAngle = Ogre::Math::ATan( Ogre::Math::Abs(mMoveZDir.z / mMoveZDir.x) );
switch (mCameraDirQuadrant)
{
case WestNorth :
{
float leftWidth = Ogre::Math::Sin(alphaAngle) * terrainHeight;
float rightWidth = Ogre::Math::Cos(alphaAngle) * terrainWidth;
outerSquareWidth = leftWidth + rightWidth;
float topHeight = Ogre::Math::Cos(alphaAngle) * terrainHeight;
float bottomHeight = Ogre::Math::Sin(alphaAngle) * terrainWidth;
outerSquareHeight = topHeight + bottomHeight;
originPoint = Ogre::Vector3(terrainData->mMinX,0,terrainData->mMinZ) +
(-mMoveZDir * leftWidth);
float projectOffset = yPos / Ogre::Math::Tan(mCamDirAngle);
originPoint.x += (mInvertCameraDir * projectOffset ).x;
originPoint.z += (mInvertCameraDir * projectOffset ).z;
break;
}
case EastNorth :
{
float leftWidth = Ogre::Math::Cos(alphaAngle) * terrainWidth;
float rightWidth = Ogre::Math::Sin(alphaAngle) * terrainHeight;
outerSquareWidth = leftWidth + rightWidth;
float topHeight = Ogre::Math::Cos(alphaAngle) * terrainHeight;
float bottomHeight = Ogre::Math::Sin(alphaAngle) * terrainWidth;
outerSquareHeight = topHeight + bottomHeight;
originPoint = Ogre::Vector3(terrainData->mMaxX,0,terrainData->mMinZ) +
(-mMoveZDir * leftWidth);
float projectOffset = yPos / Ogre::Math::Tan(mCamDirAngle);
originPoint.x += (mInvertCameraDir * projectOffset ).x;
originPoint.z += (mInvertCameraDir * projectOffset ).z;
break;
}
case EastSouth :
//.........这里部分代码省略.........
示例13: getHeight
float SimpleVehicle::getHeight() const
{
Ogre::AxisAlignedBox aab = mCreature->getActor()->getPhysicalThing()->_getBody()->getCollision()->getAABB();
return aab.getMaximum().y - aab.getMinimum().y;
}
示例14: getRadius
float SimpleVehicle::getRadius() const
{
// this is only the radius in x axis, but i think, this is the value that should be used here
Ogre::AxisAlignedBox aab = mCreature->getActor()->getPhysicalThing()->_getBody()->getCollision()->getAABB();
return(aab.getMaximum().x - aab.getMinimum().x)/2;
}
示例15: setWorldSize
void World::setWorldSize( const Ogre::AxisAlignedBox& box )
{
NewtonSetWorldSize( m_world, (float*)&box.getMinimum(), (float*)&box.getMaximum() );
m_limits = box;
}