Revision: 436
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=436&view=rev
Author: andy_miller
Date: 2007-10-17 22:11:08 -0700 (Wed, 17 Oct 2007)
Log Message:
-----------
ogrebullet BACK into the SVN
Added Paths:
-----------
trunk/python-ogre/ThirdParty/ogrebullet/
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/
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/OgreBulletCollisionsBoxShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsCompoundShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsConeShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsConvexCast.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsConvexCast.h
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsConvexHullShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsCylinderShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsDebugContact.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsDebugDrawer.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsDebugLines.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsDebugShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsMeshToShapeConverter.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsMinkowskiSumShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsMultiSphereShape.cpp
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/OgreBulletCollisionsPrecompiled.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsPrerequisites.h
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/OgreBulletCollisionsSphereShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsStaticPlaneShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsTriangleShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsTrimeshShape.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsWorld.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsWorld.h
trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/
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/
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/
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/
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/OgreBulletDynamics6DofConstraint.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConeTwistConstraint.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsHingeConstraint.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPoint2pointConstraint.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPrecompiled.cpp
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPrerequisites.h
trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsRaycastVehicle.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
Added: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp (rev 0)
+++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp 2007-10-18 05:11:08 UTC (rev 436)
@@ -0,0 +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);
+ }
+ }
+}
Added: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h
===================================================================
--- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h (rev 0)
+++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h 2007-10-18 05:11:08 UTC (rev 436)
@@ -0,0 +1,177 @@
+/***************************************************************************
+
+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.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef __OgreBulletCollisionsDebugContact_H__
+#define __OgreBulletCollisionsDebugContact_H__
+
+#include "OgreBulletCollisionsPreRequisites.h"
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+
+namespace OgreBulletCollisions
+{
+ //------------------------------------------------------------------------------------------------
+ class DebugContact
+ {
+ public:
+ DebugContact(const Ogre::String &name, CollisionsWorld *world);
+ ~DebugContact();
+
+ bool isEnabled () const;
+ void setEnabled (bool enable);
+
+ void update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
+
+ private:
+ DebugNormal *_normal;
+ DebugContactText *_text;
+ Ogre::Entity *_point;
+ bool _enabled;
+ Ogre::String _name;
+ Ogre::SceneNode *_node;
+ Ogre::SceneNode *_point_node;
+ CollisionsWorld *_world;
+ };
+
+ //------------------------------------------------------------------------------------------------
+ class DebugNormal : public DebugLines
+ {
+ public:
+ DebugNormal() : DebugLines(){};
+ ~DebugNormal(){};
+
+ void update (const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
+ };
+
+ //------------------------------------------------------------------------------------------------
+ class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable
+ {
+ public:
+ enum HorizontalAlignment {H_LEFT, H_CENTER};
+ enum VerticalAlignment {V_BELOW, V_ABOVE};
+ /******************************** public methods ******************************/
+ public:
+ DebugContactText(const Ogre::String &name,
+ Ogre::SceneNode *node,
+ const Ogre::String &caption = "",
+ const Ogre::String &fontName = "BlueHighway",
+ int charHeight = 32,
+ const Ogre::ColourValue &color = Ogre::ColourValue::White);
+
+
+ ~DebugContactText();
+
+#if (OGRE_VERSION >= ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
+ void visitRenderables(Renderable::Visitor* visitor, bool debugRenderables);
+#endif
+ // Set settings
+ void setPosition(const Ogre::Vector3 &pos);
+
+ void setFontName(const Ogre::String &fontName);
+ void setCaption(const Ogre::String &caption);
+ void setColor(const Ogre::ColourValue &color);
+ void setCharacterHeight(unsigned int height);
+ void setSpaceWidth(unsigned int width);
+ void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
+ const VerticalAlignment& verticalAlignment);
+ void setAdditionalHeight( Ogre::Real height );
+ void showOnTop(bool show=true);
+
+ // Get settings
+ const Ogre::String &getFontName() const {return mFontName;}
+ const Ogre::String &getCaption() const {return mCaption;}
+ const Ogre::ColourValue &getColor() const {return mColor;}
+
+ unsigned int getCharacterHeight() const {return mCharHeight;}
+ unsigned int getSpaceWidth() const {return mSpaceWidth;}
+ Ogre::Real getAdditionalHeight() const {return mAdditionalHeight;}
+ bool getShowOnTop() const {return mOnTop;}
+ Ogre::AxisAlignedBox GetAABB(void) { return mAABB; }
+
+ /******************************** protected methods and overload **************/
+ protected:
+
+ // from OgreBulletCollisionsDebugContact, create the object
+ void _setupGeometry();
+ void _updateColors();
+
+ // from MovableObject
+ void getWorldTransforms(Ogre::Matrix4 *xform) const;
+ Ogre::Real getBoundingRadius(void) const {return mRadius;};
+ Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
+ const Ogre::Quaternion &getWorldOrientation(void) const;
+ const Ogre::Vector3 &getWorldPosition(void) const;
+ const Ogre::AxisAlignedBox &getBoundingBox(void) const {return mAABB;};
+ const Ogre::String &getName(void) const {return mName;};
+ const Ogre::String &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
+
+ void _notifyCurrentCamera(Ogre::Camera *cam);
+ void _updateRenderQueue(Ogre::RenderQueue* queue);
+
+ // from renderable
+ void getRenderOperation(Ogre::RenderOperation &op);
+ const Ogre::MaterialPtr &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
+ const Ogre::LightList &getLights(void) const {return mLList;};
+
+ /******************************** OgreBulletCollisionsDebugContact data ****************************/
+
+
+ protected:
+ Ogre::String mFontName;
+ Ogre::String mType;
+ Ogre::String mName;
+ Ogre::String mCaption;
+ HorizontalAlignment mHorizontalAlignment;
+ VerticalAlignment mVerticalAlignment;
+
+ Ogre::ColourValue mColor;
+ Ogre::RenderOperation mRenderOp;
+ Ogre::AxisAlignedBox mAABB;
+ Ogre::LightList mLList;
+
+ unsigned int mCharHeight;
+ unsigned int mSpaceWidth;
+
+ bool mNeedUpdate;
+ bool mUpdateColors;
+ bool mOnTop;
+
+ Ogre::Real mTimeUntilNextToggle;
+ Ogre::Real mRadius;
+ Ogre::Real mAdditionalHeight;
+
+ Ogre::Camera *mpCam;
+ Ogre::RenderWindow *mpWin;
+ Ogre::Font *mpFont;
+ Ogre::MaterialPtr mpMaterial;
+ Ogre::MaterialPtr mpBackgroundMaterial;
+
+ Ogre::SceneNode *mNode;
+ };
+}
+
+#endif //__OgreBulletCollisionsDebugContact_H__
+
Added: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp (rev 0)
+++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp 2007-10-18 05:11:08 UTC (rev 436)
@@ -0,0 +1,237 @@
+/***************************************************************************
+
+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 "Debug/OgreBulletCollisionsDebugDrawer.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+DebugDrawer::DebugDrawer() :
+ DebugLines(),
+ btIDebugDraw(),
+ mDebugMode(0)
+{
+}
+//------------------------------------------------------------------------------------------------
+DebugDrawer::~DebugDrawer()
+{
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::reportErrorWarning(const char* warningString)
+{
+ Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(warningString);
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawAabb(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DrawAabb;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DrawAabb;
+}
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawAabb () const {return (mDebugMode & btIDebugDraw::DBG_DrawAabb) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawWireframe () const {return (mDebugMode & btIDebugDraw::DBG_DrawWireframe) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawFeaturesText () const {return (mDebugMode & btIDebugDraw::DBG_DrawFeaturesText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawContactPoints () const {return (mDebugMode & btIDebugDraw::DBG_DrawContactPoints) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesNoDeactivation () const {return (mDebugMode & btIDebugDraw::DBG_NoDeactivation) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesNoHelpText () const {return (mDebugMode & btIDebugDraw::DBG_NoHelpText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDrawText () const {return (mDebugMode & btIDebugDraw::DBG_DrawText) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesProfileTimings () const {return (mDebugMode & btIDebugDraw::DBG_ProfileTimings) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesEnableSatComparison () const {return (mDebugMode & btIDebugDraw::DBG_EnableSatComparison) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesDisableBulletLCP () const {return (mDebugMode & btIDebugDraw::DBG_DisableBulletLCP) != 0;};
+//------------------------------------------------------------------------------------------------
+bool DebugDrawer::doesEnableCCD () const {return (mDebugMode & btIDebugDraw::DBG_EnableCCD) != 0;};
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawWireframe(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DrawWireframe;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DrawWireframe;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawFeaturesText(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DrawFeaturesText;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DrawFeaturesText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawContactPoints(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DrawContactPoints;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DrawContactPoints;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setNoDeactivation(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_NoDeactivation;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_NoDeactivation;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setNoHelpText(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_NoHelpText;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_NoHelpText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDrawText(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DrawText;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DrawText;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setProfileTimings(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_ProfileTimings;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_ProfileTimings;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setEnableSatComparison(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_EnableSatComparison;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_EnableSatComparison;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setDisableBulletLCP (bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_DisableBulletLCP ;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_DisableBulletLCP ;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::setEnableCCD(bool enable)
+{
+ if (enable)
+ mDebugMode |= btIDebugDraw::DBG_EnableCCD;
+ else
+ mDebugMode &= ~btIDebugDraw::DBG_EnableCCD;
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
+{
+ if (mDebugMode & btIDebugDraw::DBG_DrawAabb)
+ {
+ drawAabb (BtOgreConverter::to(from), BtOgreConverter::to(to), BtOgreConverter::to (color));
+ }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
+{
+ if (mDebugMode > 0)
+ {
+ drawLine (BtOgreConverter::to(from), BtOgreConverter::to(to), BtOgreConverter::to (color));
+ }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,
+ btScalar distance,int lifeTime,const btVector3& color)
+{
+ if (mDebugMode & btIDebugDraw::DBG_DrawContactPoints)
+ {
+ //
+ }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawAabb (const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color)
+{
+ if (mDebugMode & btIDebugDraw::DBG_DrawAabb)
+ {
+ Vector3 halfExtents = (to-from)* 0.5f;
+ Vector3 center = (to+from) *0.5f;
+ int i,j;
+
+ Vector3 edgecoord(1.f,1.f,1.f),pa,pb;
+ for (i=0;i<4;i++)
+ {
+ for (j=0;j<3;j++)
+ {
+ pa = Vector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
+ edgecoord[2]*halfExtents[2]);
+ pa+=center;
+
+ int othercoord = j%3;
+ edgecoord[othercoord]*=-1.f;
+ pb = Vector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
+ edgecoord[2]*halfExtents[2]);
+ pb+=center;
+
+ drawLine(pa,pb,color);
+ }
+ edgecoord = Vector3(-1.f,-1.f,-1.f);
+ if (i<3)
+ edgecoord[i]*=-1.f;
+ }
+ }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawLine(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color)
+{
+ if (mDebugMode > 0)
+ {
+ addLine (from, to);
+ }
+}
+//------------------------------------------------------------------------------------------------
+void DebugDrawer::drawContactPoint(const Ogre::Vector3& PointOnB,const Ogre::Vector3& normalOnB,
+ Real distance,int lifeTime,const Ogre::Vector3& color)
+{
+ if (mDebugMode & btIDebugDraw::DBG_DrawContactPoints)
+ {
+
+ }
+ //...
+}
+//------------------------------------------------------------------------------------------------
+
Added: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h
===================================================================
--- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h (rev 0)
+++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h 2007-10-18 05:11:08 UTC (rev 436)
@@ -0,0 +1,88 @@
+/***************************************************************************
+
+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.
+-----------------------------------------------------------------------------
+*/
+#ifndef _OgreBulletCollisions_DebugDrawer_H_
+#define _OgreBulletCollisions_DebugDrawer_H_
+
+#include "OgreBulletCollisionsPreRequisites.h"
+
+#include "Debug/OgreBulletCollisionsDebugLines.h"
+
+namespace OgreBulletCollisions
+{
+ //------------------------------------------------------------------------------------------------
+ class DebugDrawer : public DebugLines, public btIDebugDraw
+ {
+ public:
+ DebugDrawer();
+ virtual ~DebugDrawer();
+
+
+ virtual void setDebugMode(int mode){mDebugMode = mode;};
+ virtual int getDebugMode() const { return mDebugMode;};
+
+ virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
+ virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,
+ btScalar distance,int lifeTime,const btVector3& color);
+
+ void drawAabb(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color);
+ void drawLine(const Ogre::Vector3& from,const Ogre::Vector3& to,const Ogre::Vector3& color);
+ void drawContactPoint(const Ogre::Vector3& PointOnB,const Ogre::Vector3& normalOnB,
+ Ogre::Real distance,int lifeTime,const Ogre::Vector3& color);
+
+ void setDrawAabb(bool enable);
+ void setDrawWireframe(bool enable);
+ void setDrawFeaturesText(bool enable);
+ void setDrawContactPoints(bool enable);
+ void setNoDeactivation(bool enable);
+ void setNoHelpText(bool enable);
+ void setDrawText(bool enable);
+ void setProfileTimings(bool enable);
+ void setEnableSatComparison(bool enable);
+ void setDisableBulletLCP (bool enable);
+ void setEnableCCD(bool enable);
+
+ bool doesDrawAabb () const;
+ bool doesDrawWireframe () const;
+ bool doesDrawFeaturesText () const;
+ bool doesDrawContactPoints () const;
+ bool doesNoDeactivation () const;
+ bool doesNoHelpText () const;
+ bool doesDrawText () const;
+ bool doesProfileTimings () const;
+ bool doesEnableSatComparison () const;
+ bool doesDisableBulletLCP () const;
+ bool doesEnableCCD () const;
+
+ void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color);
+
+ void reportErrorWarning(const char* warningString);
+ protected:
+ int mDebugMode;
+ };
+}
+
+#endif //_OgreBulletCollisions_DebugDrawer_H_
+
Added: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp (rev 0)
+++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp 2007-10-18 05:11:08 UTC (rev 436)
@@ -0,0 +1,162 @@
+/***************************************************************************
+
+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 "Debug/OgreBulletCollisionsDebugLines.h"
+#include "Utils/OgreBulletConverter.h"
+
+using namespace OgreBulletCollisions;
+using namespace Ogre;
+
+//------------------------------------------------------------------------------------------------
+bool DebugLines::_materials_created = false;
+//------------------------------------------------------------------------------------------------
+DebugLines::DebugLines() : SimpleRenderable()
+{
+ mRenderOp.vertexData = new Ogre::VertexData();
+ _drawn = false;
+
+ if (!_materials_created)
+ {
+ MaterialPtr red = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Disabled","OgreBulletCollisions");
+ MaterialPtr green = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Enabled","OgreBulletCollisions");
+ MaterialPtr blue = MaterialManager::getSingleton().create("OgreBulletCollisionsDebugLines/Static","OgreBulletCollisions");
+
+ red->setReceiveShadows(false);
+ red->getTechnique(0)->setLightingEnabled(true);
+ red->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);
+
+ green->setReceiveShadows(false);
+ green->getTechnique(0)->setLightingEnabled(true);
+ green->getTechnique(0)->getPass(0)->setSelfIllumination(0,1,0);
+
+ blue->setReceiveShadows(false);
+ blue->getTechnique(0)->setLightingEnabled(true);
+ blue->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
+
+ _materials_created = true;
+ }
+ setCastShadows (false);
+ this->setMaterial("OgreBulletCollisionsDebugLines/Enabled");
+}
+
+
+//------------------------------------------------------------------------------------------------
+void DebugLines::clear()
+{
+ if (_drawn)
+ {
+ _drawn = false;
+ _points.clear();
+ delete mRenderOp.vertexData;
+
+ mRenderOp.vertexData = new Ogre::VertexData();
+ }
+}
+//-----...
[truncated message content] |