[Python-ogre-commit] SF.net SVN: python-ogre:[846] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2009-01-25 10:08:17
|
Revision: 846 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=846&view=rev Author: andy_miller Date: 2009-01-25 10:08:11 +0000 (Sun, 25 Jan 2009) Log Message: ----------- Updated to latest QuickGui Needed to add GIMPACT library to OgreBullet build Update to latest OgreBullet Modified Paths: -------------- trunk/python-ogre/ThirdParty/forests/BatchedGeometry.cpp trunk/python-ogre/ThirdParty/forests/ImpostorPage.cpp trunk/python-ogre/ThirdParty/forests/ImpostorPage.h trunk/python-ogre/ThirdParty/forests/PagedGeometry.cpp trunk/python-ogre/ThirdParty/forests/PagedGeometry.h trunk/python-ogre/ThirdParty/forests/TreeLoader2D.cpp trunk/python-ogre/ThirdParty/forests/TreeLoader2D.h trunk/python-ogre/ThirdParty/forests/TreeLoader3D.cpp trunk/python-ogre/ThirdParty/forests/TreeLoader3D.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisions.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObject.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObject.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObjectState.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObjectState.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsPreRequisites.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsPrecompiled.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsRay.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsRay.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsWorld.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsWorld.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Utils/OgreBulletConverter.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamics.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPreRequisites.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPrecompiled.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsWorld.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsWorld.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIBaseDesc.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIBrush.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIBrush.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIButton.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIButton.h trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICharacter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIComponentWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIComponentWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsole.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIContainerWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIContainerWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIEventTypes.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIException.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIExportDLL.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIForwardDeclaredDesc.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIForwardDeclaredDesc.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIHScrollBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIHScrollBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIImage.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIImage.h trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIListItem.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIListItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIListTextItem.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIListTextItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenu.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenu.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuItem.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuPanel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuPanel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIModalWindow.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIModalWindow.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMouseCursor.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIMouseCursor.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIPoint.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPoint.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIProgressBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIProgressBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIRoot.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIRoot.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptDefinition.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptDefinition.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptReader.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptWriter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIScriptWriter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialBase.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialReader.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialReader.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialWriter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISerialWriter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISize.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISize.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinDefinitionManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinDefinitionManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinElement.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinType.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinTypeManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinTypeManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIStringConverter.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIStringConverter.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITab.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITab.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITabControl.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITabControl.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITabPage.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITabPage.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIText.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextArea.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextArea.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextCursor.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextCursor.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextLine.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextLine.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITimer.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITimer.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITimerManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITimerManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBarItem.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIToolBarItem.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIVScrollBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIVScrollBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWindow.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWindow.h trunk/python-ogre/code_generators/ogreforests/python_forests_sizeof.h trunk/python-ogre/code_generators/quickgui/python_quickgui_aliases.h trunk/python-ogre/code_generators/quickgui/python_quickgui_sizeof.h trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/ThirdParty/quickgui/QuickGUIComboBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIComboBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsoleEnums.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIConsoleInputHandler.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIFactory.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIFactoryManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIFactoryManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISheetManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISheetManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITreeView.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITreeView.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidgetFactory.h Removed Paths: ------------- trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidgetDescFactoryManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidgetDescFactoryManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidgetFactoryManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidgetFactoryManager.h Modified: trunk/python-ogre/ThirdParty/forests/BatchedGeometry.cpp =================================================================== --- trunk/python-ogre/ThirdParty/forests/BatchedGeometry.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/BatchedGeometry.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -32,8 +32,14 @@ #include <OgreHardwareBuffer.h> #include <OgreMaterialManager.h> #include <OgreMaterial.h> +#include <string> using namespace Ogre; +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + + namespace Forests { //------------------------------------------------------------------------------------- @@ -350,7 +356,7 @@ //Calculate camera distance Vector3 camVec = _convertToLocal(cam->getDerivedPosition()) - center; Real centerDistanceSquared = camVec.squaredLength(); - minDistanceSquared = std::max(0.0f, centerDistanceSquared - (radius * radius)); + minDistanceSquared = max(0.0f, centerDistanceSquared - (radius * radius)); //Note: centerDistanceSquared measures the distance between the camera and the center of the GeomBatch, //while minDistanceSquared measures the closest distance between the camera and the closest edge of the //geometry's bounding sphere. @@ -380,7 +386,7 @@ // Material must always exist Material *origMat = ((MaterialPtr)MaterialManager::getSingleton().getByName(ent->getMaterialName())).getPointer(); if (origMat) { - material = MaterialManager::getSingleton().getByName(getMaterialClone(*origMat)->getName()); + material = MaterialManager::getSingleton().getByName(getMaterialClone(*origMat)->getName()); } else { MaterialManager::ResourceCreateOrRetrieveResult result = MaterialManager::getSingleton().createOrRetrieve("PagedGeometry_Batched_Material", "General"); if (result.first.isNull()) { @@ -762,7 +768,7 @@ if (built){ //Update material technique based on camera distance assert(!material.isNull()); - bestTechnique = material->getBestTechnique(material->getLodIndexSquaredDepth(parent->minDistanceSquared)); + bestTechnique = material->getBestTechnique(material->getLodIndex(parent->minDistanceSquared * parent->minDistanceSquared)); //Add to render queue queue->addRenderable(this, group); Modified: trunk/python-ogre/ThirdParty/forests/ImpostorPage.cpp =================================================================== --- trunk/python-ogre/ThirdParty/forests/ImpostorPage.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/ImpostorPage.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -50,6 +50,7 @@ //Set up a single instance of a scene node which will be used when rendering impostor textures geom->getSceneNode()->createChildSceneNode("ImpostorPage::renderNode"); geom->getSceneNode()->createChildSceneNode("ImpostorPage::cameraNode"); + ResourceGroupManager::getSingleton().createResourceGroup("Impostors"); } } @@ -65,6 +66,7 @@ if (--selfInstances == 0){ sceneMgr->destroySceneNode("ImpostorPage::renderNode"); sceneMgr->destroySceneNode("ImpostorPage::cameraNode"); + ResourceGroupManager::getSingleton().destroyResourceGroup("Impostors"); } } @@ -251,20 +253,29 @@ void ImpostorBatch::setAngle(float pitchDeg, float yawDeg) { //Calculate pitch material index - Ogre::uint16 newPitchIndex; - if (pitchDeg > 0){ - newPitchIndex = static_cast<Ogre::uint16>(IMPOSTOR_PITCH_ANGLES * (pitchDeg / 67.5f)); + int newPitchIndex; +#ifdef IMPOSTOR_RENDER_ABOVE_ONLY + if (pitchDeg > 0) { + float maxPitchIndexDeg = (90.0f * (IMPOSTOR_PITCH_ANGLES-1)) / IMPOSTOR_PITCH_ANGLES; + newPitchIndex = (int)(IMPOSTOR_PITCH_ANGLES * (pitchDeg / maxPitchIndexDeg)); if (newPitchIndex > IMPOSTOR_PITCH_ANGLES-1) newPitchIndex = IMPOSTOR_PITCH_ANGLES-1; } else { newPitchIndex = 0; } +#else + float minPitchIndexDeg = -90.0f; + float maxPitchIndexDeg = ((180.0f * (IMPOSTOR_PITCH_ANGLES-1)) / IMPOSTOR_PITCH_ANGLES) - 90.0f; + newPitchIndex = (int)(IMPOSTOR_PITCH_ANGLES * ((pitchDeg - minPitchIndexDeg) / (maxPitchIndexDeg - minPitchIndexDeg))); + if (newPitchIndex > IMPOSTOR_PITCH_ANGLES-1) newPitchIndex = IMPOSTOR_PITCH_ANGLES-1; + if (newPitchIndex < 0) newPitchIndex = 0; +#endif //Calculate yaw material index - Ogre::uint16 newYawIndex; - if (yawDeg > 0){ - newYawIndex = static_cast<Ogre::uint16>(IMPOSTOR_YAW_ANGLES * (yawDeg / 360.0f) + 0.5f) % IMPOSTOR_YAW_ANGLES; + int newYawIndex; + if (yawDeg > 0) { + newYawIndex = (int)(IMPOSTOR_YAW_ANGLES * (yawDeg / 360.0f) + 0.5f) % IMPOSTOR_YAW_ANGLES; } else { - newYawIndex = static_cast<Ogre::uint16>(IMPOSTOR_YAW_ANGLES + IMPOSTOR_YAW_ANGLES * (yawDeg / 360.0f) + 0.5f) % IMPOSTOR_YAW_ANGLES; + newYawIndex = (int)(IMPOSTOR_YAW_ANGLES + IMPOSTOR_YAW_ANGLES * (yawDeg / 360.0f) + 0.5f) % IMPOSTOR_YAW_ANGLES; } //Change materials if necessary @@ -292,6 +303,10 @@ for (uint32 i = 0; i < entity->getNumSubEntities(); ++i){ entityKey << "-" << entity->getSubEntity(i)->getMaterialName(); } + entityKey << "-" << IMPOSTOR_YAW_ANGLES << "_" << IMPOSTOR_PITCH_ANGLES; +#ifdef IMPOSTOR_RENDER_ABOVE_ONLY + entityKey << "_RAO"; +#endif return entityKey.str(); } @@ -381,7 +396,6 @@ Material *m = material[i][o].getPointer(); Pass *p = m->getTechnique(0)->getPass(0); -// int x = p->getNumTextureUnitStates(); TextureUnitState *t = p->getTextureUnitState(0); t->setTextureName(texture->getName()); @@ -437,7 +451,7 @@ void ImpostorTexture::renderTextures(bool force) { -#if IMPOSTOR_FILE_SAVE +#ifdef IMPOSTOR_FILE_SAVE TexturePtr renderTexture; #else TexturePtr renderTexture(texture); @@ -521,8 +535,8 @@ entity->setRenderingDistance(0); bool needsRegen = true; -#if IMPOSTOR_FILE_SAVE - //Calculate the filename used to uniquely identity this render +#ifdef IMPOSTOR_FILE_SAVE + //Calculate the filename hash used to uniquely identity this render String strKey = entityKey; char key[32] = {0}; uint32 i = 0; @@ -560,17 +574,19 @@ const float xDivFactor = 1.0f / IMPOSTOR_YAW_ANGLES; const float yDivFactor = 1.0f / IMPOSTOR_PITCH_ANGLES; for (int o = 0; o < IMPOSTOR_PITCH_ANGLES; ++o){ //4 pitch angle renders +#ifdef IMPOSTOR_RENDER_ABOVE_ONLY Radian pitch = Degree((90.0f * o) * yDivFactor); //0, 22.5, 45, 67.5 +#else + Radian pitch = Degree((180.0f * o) * yDivFactor - 90.0f); +#endif for (int i = 0; i < IMPOSTOR_YAW_ANGLES; ++i){ //8 yaw angle renders Radian yaw = Degree((360.0f * i) * xDivFactor); //0, 45, 90, 135, 180, 225, 270, 315 //Position camera - renderCamera->setPosition(0, 0, 0); - renderCamera->setOrientation(Quaternion::IDENTITY); - renderCamera->pitch(-pitch); - renderCamera->yaw(yaw); - renderCamera->moveRelative(Vector3(0, 0, objDist)); + camNode->setPosition(0, 0, 0); + camNode->setOrientation(Quaternion(yaw, Vector3::UNIT_Y) * Quaternion(-pitch, Vector3::UNIT_X)); + camNode->translate(Vector3(0, 0, objDist), Node::TS_LOCAL); //Render the impostor renderViewport->setDimensions((float)(i) * xDivFactor, (float)(o) * yDivFactor, xDivFactor, yDivFactor); @@ -578,7 +594,7 @@ } } -#if IMPOSTOR_FILE_SAVE +#ifdef IMPOSTOR_FILE_SAVE //Save RTT to file renderTarget->writeContentsToFile(fileNamePNG); @@ -612,7 +628,7 @@ if (oldSceneNode) { oldSceneNode->attachObject(entity); } -#if IMPOSTOR_FILE_SAVE +#ifdef IMPOSTOR_FILE_SAVE //Delete RTT texture assert(!renderTexture.isNull()); String texName2(renderTexture->getName()); Modified: trunk/python-ogre/ThirdParty/forests/ImpostorPage.h =================================================================== --- trunk/python-ogre/ThirdParty/forests/ImpostorPage.h 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/ImpostorPage.h 2009-01-25 10:08:11 UTC (rev 846) @@ -23,11 +23,24 @@ #include <OgreTextureManager.h> #include <OgreRenderTexture.h> +//The number of angle increments around the yaw axis to render impostor "snapshots" of trees +#define IMPOSTOR_YAW_ANGLES 8 -#define IMPOSTOR_YAW_ANGLES 8 +//The number of angle increments around the pitch axis to render impostor "snapshots" of trees #define IMPOSTOR_PITCH_ANGLES 4 -//If set to 1, imposter textures will be read and saved to disc; if set to 0 they will stay in memory and need to be regenerated each time the application is run. -#define IMPOSTOR_FILE_SAVE 1 + +//When IMPOSTOR_RENDER_ABOVE_ONLY is defined, impostor images will only be rendered from angles around and +//above entities. If this is disabled, bottom views of the entities will be rendered to the impostor atlas +//and therefore allow those angles to be viewed from a distance. However, this requires the IMPOSTOR_PITCH_ANGLES +//to be doubled to maintain an equal level of impostor angle correctness compared to when impostors are rendered +//from above only. +#define IMPOSTOR_RENDER_ABOVE_ONLY + +//When IMPOSTOR_FILE_SAVE is defined, impostor textures will be read and saved to disc; if not, they will stay +//in memory and need to be regenerated each time the application is run (remove or comment out the line below if this +//is desired) +#define IMPOSTOR_FILE_SAVE + namespace Forests { class ImpostorBatch; Modified: trunk/python-ogre/ThirdParty/forests/PagedGeometry.cpp =================================================================== --- trunk/python-ogre/ThirdParty/forests/PagedGeometry.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/PagedGeometry.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -62,6 +62,7 @@ //Misc. pageLoader = NULL; + geometryAllowedVisible = true; } PagedGeometry::~PagedGeometry() @@ -349,27 +350,26 @@ managerList.push_back(mgr); } -void PagedGeometry::setCustomParam( string entity, string paramName, float paramValue ) +void PagedGeometry::setCustomParam(string entity, string paramName, float paramValue) { - setCustomParam( entity + "." + paramName, paramValue ); + setCustomParam(entity + "." + paramName, paramValue); } -void PagedGeometry::setCustomParam( string paramName, float paramValue ) +void PagedGeometry::setCustomParam(string paramName, float paramValue) { - customParam[ paramName ] = paramValue; + customParam[paramName] = paramValue; } -float PagedGeometry::getCustomParam( string entity, string paramName, float defaultParamValue ) const +float PagedGeometry::getCustomParam(string entity, string paramName, float defaultParamValue) const { - return getCustomParam( entity + "." + paramName, defaultParamValue );; + return getCustomParam(entity + "." + paramName, defaultParamValue); } -float PagedGeometry::getCustomParam( string paramName, float defaultParamValue ) const +float PagedGeometry::getCustomParam(string paramName, float defaultParamValue) const { map<string, float>::const_iterator it; - it = customParam.find( paramName ); - if ( it != customParam.end() ) - { + it = customParam.find(paramName); + if (it != customParam.end()) { float x = it->second; return x; } @@ -631,6 +631,9 @@ //Non-fade visibility if (distSq >= nearDistSq && distSq < farDistSq) visible = true; + //Hide all? + if (!mainGeom->getVisible()) + visible = false; //Update visibility if (visible){ Modified: trunk/python-ogre/ThirdParty/forests/PagedGeometry.h =================================================================== --- trunk/python-ogre/ThirdParty/forests/PagedGeometry.h 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/PagedGeometry.h 2009-01-25 10:08:11 UTC (rev 846) @@ -633,6 +633,23 @@ */ void resetPreloadedGeometry(); + /** + \brief Hides or unhides all geometry managed by this PagedGeometry instance + \params visible Whether or not you want this PagedGeometry to be visible + + By default everything is visible. This can be used to hide an entire PagedGeometry + "group" of geometry if desired. + */ + void setVisible(bool visible) { geometryAllowedVisible = visible; } + + /** + \brief Returns whether or not geometry managed by this PagedGeometry instance is visible + + By default, everything will be visible of course. This function simply returns the + visible/invisible state as set by the setVisible() command. + */ + bool getVisible() { return geometryAllowedVisible; } + /* \brief Immediately loads visible geometry. \param maxTime The maximum amount of time (in milliseconds) which cacheGeometry() @@ -719,34 +736,36 @@ //Internal function - do not use void _addDetailLevel(GeometryPageManager *mgr, Ogre::Real maxRange, Ogre::Real transitionLength); - Ogre::SceneManager* sceneMgr; - Ogre::SceneNode* rootNode; //PagedGeometry's own "root" node + Ogre::SceneManager *sceneMgr; + Ogre::SceneNode *rootNode; //PagedGeometry's own "root" node + bool geometryAllowedVisible; //If set to false, all geometry managed by this PagedGeometry is hidden + #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM - Ogre::Quaternion coordinateSystemQuat; //The orientation of rootNode + Ogre::Quaternion coordinateSystemQuat; //The orientation of rootNode #endif //Camera data - Ogre::Camera* sceneCam; - Ogre::Vector3 oldCamPos; + Ogre::Camera *sceneCam; + Ogre::Vector3 oldCamPos; - Ogre::Camera* lastSceneCam; - Ogre::Vector3 lastOldCamPos; + Ogre::Camera *lastSceneCam; + Ogre::Vector3 lastOldCamPos; //This list keeps track of all the GeometryPageManager's added with addPageManager() - std::list<GeometryPageManager *> managerList; + std::list<GeometryPageManager*> managerList; //The assigned PageLoader used to load entities - PageLoader* pageLoader; + PageLoader *pageLoader; //The bounds and page size - TBounds m_bounds; + TBounds m_bounds; //The page size - Ogre::Real pageSize; + Ogre::Real pageSize; //Time-related data - Ogre::Timer timer; - unsigned long lastTime; + Ogre::Timer timer; + unsigned long lastTime; private: std::map<std::string, float> customParam; @@ -897,7 +916,7 @@ Do not leave any remains of the entities in memory after this function is called. One of the advantages of using paged geometry is that you can have near-infinite game worlds, which would normally exceed a computer's RAM capacity. This advantage - would completely dissappear if you did not clean up properly when the page manager + would completely disappear if you did not clean up properly when the page manager calls this function. */ virtual void removeEntities() = 0; Modified: trunk/python-ogre/ThirdParty/forests/TreeLoader2D.cpp =================================================================== --- trunk/python-ogre/ThirdParty/forests/TreeLoader2D.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/TreeLoader2D.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -143,7 +143,7 @@ #else void #endif -TreeLoader2D::deleteTrees(const Ogre::Vector3 &position, Real radius, Entity *type) +TreeLoader2D::deleteTrees(const Ogre::Vector3 &position, Ogre::Real radius, Entity *type) { //First convert the coordinate to PagedGeometry's local system #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM @@ -504,6 +504,13 @@ { TreeIterator2D::trees = trees; + //Test if the GridList has anything in it + if (trees->pageGridList.empty()) { + // If not, set hasMore to false and return. + hasMore = false; + return; + } + //Setup iterators currentGrid = trees->pageGridList.begin(); currentX = 0; currentZ = 0; Modified: trunk/python-ogre/ThirdParty/forests/TreeLoader2D.h =================================================================== --- trunk/python-ogre/ThirdParty/forests/TreeLoader2D.h 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/TreeLoader2D.h 2009-01-25 10:08:11 UTC (rev 846) @@ -92,7 +92,7 @@ #else void #endif - deleteTrees(const Ogre::Vector3 &position, float radius = 0.001f, Ogre::Entity *type = NULL); + deleteTrees(const Ogre::Vector3 &position, Ogre::Real radius = 0.001f, Ogre::Entity *type = NULL); /** \brief Deletes trees within a certain rectangular area. \param area The area where trees are to be deleted @@ -162,6 +162,8 @@ to this TreeLoader fairly efficiently. \see The TreeIterator class documentation for more info. + \warning Be sure to test TreeIterator3D::hasMoreElements() before calling other members of the + TreeIterator3D class. */ TreeIterator2D getTrees(); Modified: trunk/python-ogre/ThirdParty/forests/TreeLoader3D.cpp =================================================================== --- trunk/python-ogre/ThirdParty/forests/TreeLoader3D.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/TreeLoader3D.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -135,7 +135,7 @@ #else void #endif -TreeLoader3D::deleteTrees(const Ogre::Vector3 &position, Real radius, Entity *type) +TreeLoader3D::deleteTrees(const Vector3 &position, Real radius, Entity *type) { //First convert the coordinate to PagedGeometry's local system #ifdef PAGEDGEOMETRY_ALTERNATE_COORDSYSTEM @@ -488,6 +488,13 @@ { TreeIterator3D::trees = trees; + //Test if the GridList has anything in it + if (trees->pageGridList.empty()) { + // If not, set hasMore to false and return. + hasMore = false; + return; + } + //Setup iterators currentGrid = trees->pageGridList.begin(); currentX = 0; currentZ = 0; Modified: trunk/python-ogre/ThirdParty/forests/TreeLoader3D.h =================================================================== --- trunk/python-ogre/ThirdParty/forests/TreeLoader3D.h 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/forests/TreeLoader3D.h 2009-01-25 10:08:11 UTC (rev 846) @@ -72,7 +72,7 @@ #else void #endif - deleteTrees(const Ogre::Vector3 &position, float radius, Ogre::Entity *type = NULL); + deleteTrees(const Ogre::Vector3 &position, Ogre::Real radius, Ogre::Entity *type = NULL); #ifdef PAGEDGEOMETRY_USER_DATA /** \brief Find trees within a certain radius of the given coordinates. @@ -105,7 +105,8 @@ to this TreeLoader3D fairly efficiently. \see The TreeIterator class documentation for more info. - */ + \warning Be sure to test TreeIterator3D::hasMoreElements() before calling other members of the + TreeIterator3D class. */ TreeIterator3D getTrees(); /** \brief Sets the color map used to color trees Modified: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp =================================================================== --- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp 2009-01-25 03:51:12 UTC (rev 845) +++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp 2009-01-25 10:08:11 UTC (rev 846) @@ -1,650 +1,650 @@ -/*************************************************************************** - -This source file is part of OGREBULLET -(Object-oriented Graphics Rendering Engine Bullet Wrapper) -For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 - -Copyright (c) 2007 tua...@gm... - - - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place - Suite 330, Boston, MA 02111-1307, USA, or go to -http://www.gnu.org/copyleft/lesser.txt. ------------------------------------------------------------------------------ -*/ - - -#include "OgreBulletCollisions.h" - -#include "Ogre.h" -#include "OgreFontManager.h" - -#include "Debug/OgreBulletCollisionsDebugContact.h" -#include "OgreBulletCollisionsShape.h" -#include "OgreBulletCollisionsObject.h" -#include "OgreBulletCollisionsWorld.h" - -using namespace Ogre; - -#define POS_TEX_BINDING 0 -#define COLOUR_BINDING 1 - -namespace OgreBulletCollisions -{ - //------------------------------------------------------------------------------------------------ - DebugContact::DebugContact(const String &name, CollisionsWorld *world) : - _name(name), - _world(world), - _enabled(false) - { - // scene node - _node = _world->getSceneManager()->getRootSceneNode ()->createChildSceneNode (); - - // sphere attach to contact point - _point = _world->getSceneManager()->createEntity(name + String("_debug_point"), "sphere.mesh"); - _point_node = _node->createChildSceneNode (); - _point_node->attachObject (_point); - _point_node->setScale(0.001, 0.001, 0.001); - - // normal direction debug - _normal = new DebugNormal(); - _node->attachObject (_normal); - - // text info on contact - _text = new DebugContactText(name + String("_debug_text"), _node->createChildSceneNode ()); - _text->setPosition (Vector3(0,5,0)); - _text->setCaption ("-"); - _text->setVisible (false); - - _node->setVisible (false); - } - //------------------------------------------------------------------------------------------------ - DebugContact::~DebugContact() - { - delete _text; - - _point_node->detachObject (_point->getName ()); - _node->detachObject (_normal->getName ()); - - _world->getSceneManager()->destroyEntity (_point->getName ()); - - _node->detachAllObjects (); - _node->removeAndDestroyAllChildren (); - - delete _normal; - } - //------------------------------------------------------------------------------------------------ - void DebugContact::update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth) - { - _node->setPosition (pt); - - _point_node->setPosition (depth * normal); - - //String contactLabel("p: "); - //contactLabel = contactLabel + StringConverter::toString(contact->getPosition()); - //contactLabel = contactLabel + ", n: "; - //contactLabel = contactLabel + StringConverter::toString(contact->getNormal()); - //_text->setCaption (contactLabel); - //_text->setVisible (false); - - //_text->setPosition (contact->getPosition () + Vector3(0,5,0)); - - _normal->update (normal, pt, depth); - } - //------------------------------------------------------------------------------------------------ - bool DebugContact::isEnabled () const - { - return _enabled; - } - //------------------------------------------------------------------------------------------------ - void DebugContact::setEnabled (bool enable) - { - _enabled = enable; - _node->setVisible (_enabled); - }; - //------------------------------------------------------------------------------------------------ - void DebugNormal::update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth) - { - DebugLines::clear (); - // set normal following contact normal - //contact->_normal - //contact->_position - DebugLines::addLine (Vector3::ZERO, - 5*normal); - DebugLines::draw (); - } - //------------------------------------------------------------------------------------------------ - DebugContactText::DebugContactText(const String &name, - SceneNode *node, - const String &caption, - const String &fontName, - int charHeight, - const ColourValue &color) - : mpCam(NULL) - , mpWin(NULL) - , mpFont(NULL) - , mName(name) - , mCaption(caption) - , mFontName(fontName) - , mCharHeight(charHeight) - , mColor(color) - , mType("DebugContact") - , mTimeUntilNextToggle(0) - , mSpaceWidth(0) - , mUpdateColors(true) - , mOnTop(false) - , mHorizontalAlignment(H_LEFT) - , mVerticalAlignment(V_BELOW) - , mAdditionalHeight(0.0) - , mNode(node) - - { - if (name.empty()) - Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without name", "DebugContact::DebugContact"); -// -// if (caption.empty()) -// Exception(Exception::ERR_INVALIDPARAMS, "Trying to create DebugContact without caption", "DebugContact::DebugContact"); - - mRenderOp.vertexData = NULL; - this->setFontName(mFontName); - //this->_setupGeometry(); - mNode->attachObject(this); - } - //------------------------------------------------------------------------------------------------ - DebugContactText::~DebugContactText() - { - mNode->detachObject(this->getName()); - if (mRenderOp.vertexData) - delete mRenderOp.vertexData; - } -#if (OGRE_VERSION >= ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0) - void DebugContactText::visitRenderables(Renderable::Visitor* visitor, - bool debugRenderables) - { - visitor->visit(this, 0, false); - } -#endif - //------------------------------------------------------------------------------------------------ - void DebugContactText::setPosition(const Vector3 &pos) - { - mNode->setPosition (pos); - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setFontName(const String &fontName) - { - if((Ogre::MaterialManager::getSingletonPtr()->resourceExists(mName + "Material"))) - { - Ogre::MaterialManager::getSingleton().remove(mName + "Material"); - } - - if (mFontName != fontName || mpMaterial.isNull() || !mpFont) - { - mFontName = fontName; - mpFont = (Font *)FontManager::getSingleton().getByName(mFontName).getPointer(); - if (!mpFont) - Exception(Exception::ERR_ITEM_NOT_FOUND, "Could not find font " + fontName, "DebugContact::setFontName"); - - mpFont->load(); - if (!mpMaterial.isNull()) - { - MaterialManager::getSingletonPtr()->remove(mpMaterial->getName()); - mpMaterial.setNull(); - } - - mpMaterial = mpFont->getMaterial()->clone(mName + "Material"); - if (!mpMaterial->isLoaded()) - mpMaterial->load(); - - mpMaterial->setDepthCheckEnabled(!mOnTop); - //mpMaterial->setDepthBias(!mOnTop); - mpMaterial->setDepthBias(0,!mOnTop); - mpMaterial->setDepthWriteEnabled(mOnTop); - mpMaterial->setLightingEnabled(false); - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setCaption(const String &caption) - { - if (caption != mCaption) - { - mCaption = caption; - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setColor(const ColourValue &color) - { - if (color != mColor) - { - mColor = color; - mUpdateColors = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setCharacterHeight(unsigned int height) - { - if (height != mCharHeight) - { - mCharHeight = height; - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setSpaceWidth(unsigned int width) - { - if (width != mSpaceWidth) - { - mSpaceWidth = width; - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment) - { - if(mHorizontalAlignment != horizontalAlignment) - { - mHorizontalAlignment = horizontalAlignment; - mNeedUpdate = true; - } - if(mVerticalAlignment != verticalAlignment) - { - mVerticalAlignment = verticalAlignment; - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::setAdditionalHeight( Real height ) - { - if( mAdditionalHeight != height ) - { - mAdditionalHeight = height; - mNeedUpdate = true; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::showOnTop(bool show) - { - if( mOnTop != show && !mpMaterial.isNull() ) - { - mOnTop = show; - mpMaterial->setDepthBias(0,!mOnTop); - mpMaterial->setDepthCheckEnabled(!mOnTop); - mpMaterial->setDepthWriteEnabled(mOnTop); - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::_setupGeometry() - { - assert(mpFont); - assert(!mpMaterial.isNull()); - - unsigned int vertexCount = static_cast<unsigned int>(mCaption.size() * 6); - - if (mRenderOp.vertexData) - { - // Removed this test as it causes problems when replacing a caption - // of the same size: replacing "Hello" with "hello" - // as well as when changing the text alignment - //if (mRenderOp.vertexData->vertexCount != vertexCount) - { - delete mRenderOp.vertexData; - mRenderOp.vertexData = NULL; - mUpdateColors = true; - } - } - - if (!mRenderOp.vertexData) - mRenderOp.vertexData = new VertexData(); - - mRenderOp.indexData = 0; - mRenderOp.vertexData->vertexStart = 0; - mRenderOp.vertexData->vertexCount = vertexCount; - mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST; - mRenderOp.useIndexes = false; - - VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration; - VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding; - size_t offset = 0; - - // create/bind positions/tex.ccord. buffer - if (!decl->findElementBySemantic(VES_POSITION)) - decl->addElement(POS_TEX_BINDING, offset, VET_FLOAT3, VES_POSITION); - - offset += VertexElement::getTypeSize(VET_FLOAT3); - - if (!decl->findElementBySemantic(VES_TEXTURE_COORDINATES)) - decl->addElement(POS_TEX_BINDING, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0); - - HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(POS_TEX_BINDING), - mRenderOp.vertexData->vertexCount, - HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); - bind->setBinding(POS_TEX_BINDING, ptbuf); - - // Colours - store these in a separate buffer because they change less often - if (!decl->findElementBySemantic(VES_DIFFUSE)) - decl->addElement(COLOUR_BINDING, 0, VET_COLOUR, VES_DIFFUSE); - - HardwareVertexBufferSharedPtr cbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(COLOUR_BINDING), - mRenderOp.vertexData->vertexCount, - HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); - bind->setBinding(COLOUR_BINDING, cbuf); - - size_t charlen = mCaption.size(); - Real *pPCBuff = static_cast<Real*>(ptbuf->lock(HardwareBuffer::HBL_DISCARD)); - - float largestWidth = 0; - float left = 0 * 2.0 - 1.0; - float top = -((0 * 2.0) - 1.0); - - // Derive space width from a capital A - if (mSpaceWidth == 0) - mSpaceWidth = mpFont->getGlyphAspectRatio('A') * mCharHeight * 2.0; - - // for calculation of AABB - Ogre::Vector3 min, max, currPos; - Ogre::Real maxSquaredRadius; - bool first = true; - - // Use iterator - String::iterator i, iend; - iend = mCaption.end(); - bool newLine = true; - Real len = 0.0f; - - if(mVerticalAlignment == DebugContactText::V_ABOVE) - { - // Raise the first line of the caption - top += mCharHeight; - for (i = mCaption.begin(); i != iend; ++i) - { - if (*i == '\n') - top += mCharHeight * 2.0; - } - } - - for (i = mCaption.begin(); i != iend; ++i) - { - if (newLine) - { - len = 0.0f; - for (String::iterator j = i; j != iend && *j != '\n'; j++) - { - if (*j == ' ') - len += mSpaceWidth; - else - len += mpFont->getGlyphAspectRatio(*j) * mCharHeight * 2.0; - } - newLine = false; - } - - if (*i == '\n') - { - left = 0 * 2.0 - 1.0; - top -= mCharHeight * 2.0; - newLine = true; - continue; - } - - if (*i == ' ') - { - // Just leave a gap, no tris - left += mSpaceWidth; - // Also reduce tri count - mRenderOp.vertexData->vertexCount -= 6; - continue; - } - - Real horiz_height = mpFont->getGlyphAspectRatio(*i); - - //mpFont->getGlyphTexCoords(*i, u1, v1, u2, v2); - const Font::UVRect &uvRect = mpFont->getGlyphTexCoords(*i); - const Real u1 = uvRect.left; - const Real u2 = uvRect.right; - const Real v1 = uvRect.top; - const Real v2 = uvRect.bottom; - - // each vert is (x, y, z, u, v) - //------------------------------------------------------------------------------------- - // First tri - // - // Upper left - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u1; - *pPCBuff++ = v1; - - // Deal with bounds - if(mHorizontalAlignment == DebugContactText::H_LEFT) - currPos = Ogre::Vector3(left, top, -1.0); - else - currPos = Ogre::Vector3(left - (len / 2), top, -1.0); - if (first) - { - min = max = currPos; - maxSquaredRadius = currPos.squaredLength(); - first = false; - } - else - { - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - } - - top -= mCharHeight * 2.0; - - // Bottom left - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u1; - *pPCBuff++ = v2; - - // Deal with bounds - if(mHorizontalAlignment == DebugContactText::H_LEFT) - currPos = Ogre::Vector3(left, top, -1.0); - else - currPos = Ogre::Vector3(left - (len / 2), top, -1.0); - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - - top += mCharHeight * 2.0; - left += horiz_height * mCharHeight * 2.0; - - // Top right - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u2; - *pPCBuff++ = v1; - //------------------------------------------------------------------------------------- - - // Deal with bounds - if(mHorizontalAlignment == DebugContactText::H_LEFT) - currPos = Ogre::Vector3(left, top, -1.0); - else - currPos = Ogre::Vector3(left - (len / 2), top, -1.0); - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - - //------------------------------------------------------------------------------------- - // Second tri - // - // Top right (again) - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u2; - *pPCBuff++ = v1; - - currPos = Ogre::Vector3(left, top, -1.0); - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - - top -= mCharHeight * 2.0; - left -= horiz_height * mCharHeight * 2.0; - - // Bottom left (again) - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u1; - *pPCBuff++ = v2; - - currPos = Ogre::Vector3(left, top, -1.0); - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - - left += horiz_height * mCharHeight * 2.0; - - // Bottom right - if(mHorizontalAlignment == DebugContactText::H_LEFT) - *pPCBuff++ = left; - else - *pPCBuff++ = left - (len / 2); - *pPCBuff++ = top; - *pPCBuff++ = -1.0; - *pPCBuff++ = u2; - *pPCBuff++ = v2; - //------------------------------------------------------------------------------------- - - currPos = Ogre::Vector3(left, top, -1.0); - min.makeFloor(currPos); - max.makeCeil(currPos); - maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength()); - - // Go back up with top - top += mCharHeight * 2.0; - - float currentWidth = (left + 1)/2 - 0; - if (currentWidth > largestWidth) - largestWidth = currentWidth; - } - - // Unlock vertex buffer - ptbuf->unlock(); - - // update AABB/Sphere radius - mAABB = Ogre::AxisAlignedBox(min, max); - mRadius = Ogre::Math::Sqrt(maxSquaredRadius); - - if (mUpdateColors) - this->_updateColors(); - - mNeedUpdate = false; - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::_updateColors(void) - { - assert(mpFont); - assert(!mpMaterial.isNull()); - - // Convert to system-specific - RGBA color; - Root::getSingleton().convertColourValue(mColor, &color); - HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(COLOUR_BINDING); - RGBA *pDest = static_cast<RGBA*>(vbuf->lock(HardwareBuffer::HBL_DISCARD)); - for (unsigned int i = 0; i < mRenderOp.vertexData->vertexCount; ++i) - *pDest++ = color; - vbuf->unlock(); - mUpdateColors = false; - } - //------------------------------------------------------------------------------------------------ - const Quaternion& DebugContactText::getWorldOrientation(void) const - { - assert(mpCam); - return const_cast<Quaternion&>(mpCam->getDerivedOrientation()); - } - //------------------------------------------------------------------------------------------------ - const Vector3& DebugContactText::getWorldPosition(void) const - { - assert(mParentNode); - return mParentNode->_getDerivedPosition(); - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::getWorldTransforms(Matrix4 *xform) const - { - if (this->isVisible() && mpCam) - { - Matrix3 rot3x3, scale3x3 = Matrix3::IDENTITY; - - // store rotation in a matrix - mpCam->getDerivedOrientation().ToRotationMatrix(rot3x3); - - // parent node position - Vector3 ppos = mParentNode->_getDerivedPosition() + Vector3::UNIT_Y*mAdditionalHeight; - - // apply scale - scale3x3[0][0] = mParentNode->_getDerivedScale().x / 2; - scale3x3[1][1] = mParentNode->_getDerivedScale().y / 2; - scale3x3[2][2] = mParentNode->_getDerivedScale().z / 2; - - // apply all transforms to xform - *xform = (rot3x3 * scale3x3); - xform->setTrans(ppos); - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::getRenderOperation(RenderOperation &op) - { - if (this->isVisible()) - { - if (mNeedUpdate) - this->_setupGeometry(); - if (mUpdateColors) - this->_updateColors(); - op = mRenderOp; - } - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::_notifyCurrentCamera(Camera *cam) - { - mpCam = cam; - } - //------------------------------------------------------------------------------------------------ - void DebugContactText::_updateRenderQueue(RenderQueue* queue) - { - if (this->isVisible()) - { - if (mNeedUpdate) - this->_setupGeometry(); - if (mUpdateColors) - this->_updateColors(); - - queue->addRenderable(this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY); - // queue->addRenderable(this, mRenderQueueID, RENDER_QUEUE_SKIES_LATE); - } - } -} +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +This program is free software; you can redistribute it and/or modify it under +the terms of the GPL General Public License with runtime exception as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details. + +You should have received a copy of the GPL General Public License with runtime exception along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +----------------------------------------------------------------------------- +*/ + + +#include "OgreBulletCollisions.h" + +#include "Ogre.h" +#include "OgreFontManager.h" + +#include "Debug/OgreBulletCollisionsDebugContact.h" +#include "OgreBulletCollisionsShape.h" +#include "OgreBulletCollisionsObject.h" +#include "OgreBulletCollisionsWorld.h" + +using namespace Ogre; + +#define POS_TEX_BINDING 0 +#define COLOUR_BINDING 1 + +namespace OgreBulletCollisions +{ + //--------------------------------------------------... [truncated message content] |