[Python-ogre-commit] SF.net SVN: python-ogre: [454] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2007-10-23 06:05:11
|
Revision: 454 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=454&view=rev Author: andy_miller Date: 2007-10-22 23:05:12 -0700 (Mon, 22 Oct 2007) Log Message: ----------- QuickGUI updates New version of OgreAL (base library updated with various bug fixes) Updated Ogrebullet Modified Paths: -------------- trunk/python-ogre/ThirdParty/ogreal/OgreALOggSound.cpp trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.cpp trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisions.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsConvexCast.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsMeshToShapeConverter.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObject.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsObjectState.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsPreRequisites.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsRay.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/OgreBulletCollisionsWorld.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.h trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.h 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.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamics.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsConstraint.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsObjectState.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsPreRequisites.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsRigidBody.h trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/OgreBulletDynamicsWorld.h trunk/python-ogre/ThirdParty/quickgui/QuickGUI.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIBorder.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIComboBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUILabel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIList.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMenuLabel.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIMouseCursor.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUINStateButton.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPanel.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuad.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIQuad.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIScrollPane.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISheet.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinSet.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinSet.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITitleBar.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIWidget.h trunk/python-ogre/code_generators/quickgui/generate_code.py trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/ThirdParty/ogreal/OgreALException.cpp trunk/python-ogre/ThirdParty/ogreal/OgreALException.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIConfigScriptParser.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIConfigScriptParser.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIEffect.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIEffect.h Removed Paths: ------------- trunk/python-ogre/ThirdParty/ogreal/Makefile.am trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugDrawer.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugLines.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsBoxShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCompoundShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConeShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsConvexHullShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsCylinderShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsMultiSphereShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsSphereShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsStaticPlaneShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTriangleShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Shapes/OgreBulletCollisionsTrimeshShape.cpp trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Utils/OgreBulletCollisionsMeshToShapeConverter.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamics6DofConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsConeTwistConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsHingeConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp trunk/python-ogre/ThirdParty/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.cpp Deleted: trunk/python-ogre/ThirdParty/ogreal/Makefile.am =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/Makefile.am 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogreal/Makefile.am 2007-10-23 06:05:12 UTC (rev 454) @@ -1 +0,0 @@ -pkginclude_HEADERS = OgreAL.h OgreALListener.h OgreALOggSound.h OgreALOggSoundStream.h OgreALPrereqs.h OgreALSound.h OgreALSoundManager.h OgreALSoundStream.h OgreALWavSound.h Added: trunk/python-ogre/ThirdParty/ogreal/OgreALException.cpp =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALException.cpp (rev 0) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALException.cpp 2007-10-23 06:05:12 UTC (rev 454) @@ -0,0 +1,12 @@ +#include "OgreALException.h" +#include "OgreException.h" + +namespace OgreAL { + void check(bool condition, const int errorNumber, const Ogre::String& description, const Ogre::String& source) + { + if (!condition) + { + throw Ogre::Exception(errorNumber, description, source); + } + } +} // Namespace Added: trunk/python-ogre/ThirdParty/ogreal/OgreALException.h =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALException.h (rev 0) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALException.h 2007-10-23 06:05:12 UTC (rev 454) @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ +** This source file is part of OgreAL ** +** an OpenAL plugin for the Ogre Rendering Engine. ** +** ** +** Copyright 2006 Casey Borders ** +** ** +** OgreAL 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, or (at your option) any later ** +** version. ** +** ** +** The developer really likes screenshots and while he recognises that the ** +** fact that this is an AUDIO plugin means that the fruits of his labor will ** +** never been seen in these images he would like to kindly ask that you send ** +** screenshots of your application using his library to ** +** scr...@mo... ** +** ** +** Please bear in mind that the sending of these screenshots means that you ** +** are agreeing to allow the developer to display them in the media of his ** +** choice. They will, however, be fully credited to the person sending the ** +** email or, if you wish them to be credited differently, please state that ** +** in the body of the email. ** +** ** +** OgreAL 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 General Public License for ** +** more details. ** +** ** +** You should have received a copy of the GNU General Public License along ** +** with OgreAL; see the file LICENSE. If not, write to the ** +** Free Software Foundation, Inc., ** +** 59 Temple Place - Suite 330, ** +** Boston, MA 02111-1307, USA. ** +\*---------------------------------------------------------------------------*/ +#ifndef _OGREAL_EXCEPTION_H_ +#define _OGREAL_EXCEPTION_H_ + +#include "OgreString.h" + +namespace OgreAL { + void check(bool condition, const int errorNumber, const Ogre::String& description, const Ogre::String& source); + + #define OGREAL_CHECK(condition, errorNumber, description) check((condition), (errorNumber), (description), __FUNCTION__) +} // Namespace +#endif Modified: trunk/python-ogre/ThirdParty/ogreal/OgreALOggSound.cpp =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALOggSound.cpp 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALOggSound.cpp 2007-10-23 06:05:12 UTC (rev 454) @@ -35,6 +35,7 @@ #include "OgreALOggSound.h" #include "OgreALSoundManager.h" +#include "OgreALException.h" namespace OgreAL { OggSound::OggSound(const Ogre::String& name, const Ogre::String& soundFile, bool loop, AudioFormat format) : @@ -43,96 +44,110 @@ mVorbisInfo(0), mVorbisComment(0) { - if(!(mOggFile = fopen(soundFile.c_str(), "rb"))) + try { - throw Ogre::Exception(1, "Could not open Ogg file.", "OgreAL::OggSound::ctor"); - } + mOggFile = fopen(soundFile.c_str(), "rb"); + OGREAL_CHECK(mOggFile != 0, 1, "Could not open Ogg file."); - if(ov_open(mOggFile, &mOggStream, NULL, 0) < 0) - { - fclose(mOggFile); - throw Ogre::Exception(1, "Could not open Ogg stream.", "OgreAL::OggSound::ctor"); - } + OGREAL_CHECK(ov_open(mOggFile, &mOggStream, NULL, 0) >= 0, 1, "Could not open Ogg stream."); + mVorbisInfo = ov_info(&mOggStream, -1); - mVorbisInfo = ov_info(&mOggStream, -1); + unsigned long channels = mVorbisInfo->channels; + mFreq = mVorbisInfo->rate; + mLoop = loop; - unsigned long channels = mVorbisInfo->channels; - mFreq = mVorbisInfo->rate; - mLoop = loop; + switch(channels) + { + case 1: + mFormat = AL_FORMAT_MONO16; + // Set BufferSize to 250ms (Frequency * 2 (16bit) divided by 4 (quarter of a second)) + mBufferSize = mFreq >> 1; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 2); + break; + case 2: + mFormat = AL_FORMAT_STEREO16; + // Set BufferSize to 250ms (Frequency * 4 (16bit stereo) divided by 4 (quarter of a second)) + mBufferSize = mFreq; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 4); + break; + case 4: + mFormat = alGetEnumValue("AL_FORMAT_QUAD16"); + // Set BufferSize to 250ms (Frequency * 8 (16bit 4-channel) divided by 4 (quarter of a second)) + mBufferSize = mFreq * 2; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 8); + break; + case 6: + mFormat = alGetEnumValue("AL_FORMAT_51CHN16"); + // Set BufferSize to 250ms (Frequency * 12 (16bit 6-channel) divided by 4 (quarter of a second)) + mBufferSize = mFreq * 3; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 12); + break; + case 7: + mFormat = alGetEnumValue("AL_FORMAT_61CHN16"); + // Set BufferSize to 250ms (Frequency * 16 (16bit 7-channel) divided by 4 (quarter of a second)) + mBufferSize = mFreq * 4; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 16); + break; + case 8: + mFormat = alGetEnumValue("AL_FORMAT_71CHN16"); + // Set BufferSize to 250ms (Frequency * 20 (16bit 8-channel) divided by 4 (quarter of a second)) + mBufferSize = mFreq * 5; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 20); + break; + default: + // Couldn't determine buffer format so log the error and default to mono + Ogre::LogManager::getSingleton().logMessage("!!WARNING!! Could not determine buffer format! Defaulting to MONO"); - if(channels == 1) - { - mFormat = AL_FORMAT_MONO16; - // Set BufferSize to 250ms (Frequency * 2 (16bit) divided by 4 (quarter of a second)) - mBufferSize = mFreq >> 1; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 2); + mFormat = AL_FORMAT_MONO16; + // Set BufferSize to 250ms (Frequency * 2 (16bit) divided by 4 (quarter of a second)) + mBufferSize = mFreq >> 1; + // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... + mBufferSize -= (mBufferSize % 2); + break; + } + + alGenBuffers(1, &mBuffer); + OGREAL_CHECK(alGetError() == AL_NO_ERROR, 13, "Could not generate buffer"); + int currSection; + long size = 0; + char data[4096*8]; + std::vector<char> buffer; + do + { + size = ov_read(&mOggStream, data, sizeof(data), 0, 2, 1, &currSection); + buffer.insert(buffer.end(), data, data + size); + }while(size > 0); + + ov_clear(&mOggStream); + alBufferData(mBuffer, mFormat, &buffer[0], static_cast<ALsizei>(buffer.size()), mFreq); + OGREAL_CHECK(alGetError() == AL_NO_ERROR, 13, "Could not generate buffer"); } - else if(channels == 2) + catch(Exception e) { - mFormat = AL_FORMAT_STEREO16; - // Set BufferSize to 250ms (Frequency * 4 (16bit stereo) divided by 4 (quarter of a second)) - mBufferSize = mFreq; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 4); - } - else if(channels == 4) - { - mFormat = alGetEnumValue("AL_FORMAT_QUAD16"); - // Set BufferSize to 250ms (Frequency * 8 (16bit 4-channel) divided by 4 (quarter of a second)) - mBufferSize = mFreq * 2; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 8); - } - else if(channels == 6) - { - mFormat = alGetEnumValue("AL_FORMAT_51CHN16"); - // Set BufferSize to 250ms (Frequency * 12 (16bit 6-channel) divided by 4 (quarter of a second)) - mBufferSize = mFreq * 3; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 12); - } - else if(channels == 7) - { - mFormat = alGetEnumValue("AL_FORMAT_61CHN16"); - // Set BufferSize to 250ms (Frequency * 16 (16bit 7-channel) divided by 4 (quarter of a second)) - mBufferSize = mFreq * 4; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 16); - } - else if(channels == 8) - { - mFormat = alGetEnumValue("AL_FORMAT_71CHN16"); - // Set BufferSize to 250ms (Frequency * 20 (16bit 8-channel) divided by 4 (quarter of a second)) - mBufferSize = mFreq * 5; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 20); - } - else - { - // Couldn't determine buffer format so log the error and default to mono - Ogre::LogManager::getSingleton().logMessage("!!WARNING!! Could not determine buffer format! Defaulting to MONO"); + if (mBuffer) + { + if (alIsBuffer(mBuffer) == AL_TRUE) + { + alDeleteBuffers(1, &mBuffer); + } + } - mFormat = AL_FORMAT_MONO16; - // Set BufferSize to 250ms (Frequency * 2 (16bit) divided by 4 (quarter of a second)) - mBufferSize = mFreq >> 1; - // IMPORTANT : The Buffer Size must be an exact multiple of the BlockAlignment ... - mBufferSize -= (mBufferSize % 2); - } + if(mOggFile) + { + fclose(mOggFile); + mOggFile = 0; + } - alGenBuffers(1, &mBuffer); - int currSection; - long size = 0; - char data[4096*8]; - std::vector<char> buffer; - do - { - size = ov_read(&mOggStream, data, sizeof(data), 0, 2, 1, &currSection); - buffer.insert(buffer.end(), data, data + size); - }while(size > 0); + ov_clear(&mOggStream); - ov_clear(&mOggStream); - alBufferData(mBuffer, mFormat, &buffer[0], static_cast<ALsizei>(buffer.size()), mFreq); + throw (e); + } createAndBindSource(); } Modified: trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h 2007-10-23 06:05:12 UTC (rev 454) @@ -42,7 +42,6 @@ #if OGRE_COMPILER == OGRE_COMPILER_MSVC # include "al.h" # include "alc.h" - # include "AL/alut.h" # include "xram.h" # ifndef OgreAL_Export # ifdef OGRE_AL_EXPORT @@ -54,7 +53,6 @@ #elif OGRE_COMPILER == OGRE_COMPILER_GNUC # include "AL/al.h" # include "AL/alc.h" - # include "AL/alut.h" # if defined(OGRE_AL_EXPORT) && OGRE_COMP_VER >= 400 # define OgreAL_Export __attribute__ ((visibility("default"))) # else @@ -66,7 +64,6 @@ #else // Other Compilers # include "al.h" # include "alc.h" - # include "alut.h" # include "xram.h" # define OgreAL_Export #endif @@ -125,5 +122,22 @@ delete pair.second; } }; + + static unsigned short readByte16(const unsigned char buffer[2]) + { + #if(OGRE_ENDIAN == OGRE_ENDIAN_BIG) + return (buffer[0] << 8) + buffer[1]; + #else + return (buffer[1] << 8) + buffer[0]; + #endif + } + static unsigned long readByte32(const unsigned char buffer[4]) + { + #if(OGRE_ENDIAN == OGRE_ENDIAN_BIG) + return (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]; + #else + return (buffer[3] << 24) + (buffer[2] << 16) + (buffer[1] << 8) + buffer[0]; + #endif + } } #endif Modified: trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.cpp =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.cpp 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.cpp 2007-10-23 06:05:12 UTC (rev 454) @@ -35,25 +35,151 @@ #include "OgreALWavSound.h" #include "OgreALSoundManager.h" +#include "OgreALException.h" namespace OgreAL { WavSound::WavSound(const Ogre::String& name, const Ogre::String& soundFile, bool loop, AudioFormat format) : - Sound(name, soundFile) + Sound(name, soundFile), + mWavFile(0) { - alGenBuffers(1, &mBuffer); - checkError(__FUNCTION__); + const unsigned int BUFFER_SIZE = 32768; // 32 KB buffers + size_t bytes; + std::vector <char> data; - ALbyte* filename = reinterpret_cast<ALbyte*>(const_cast<char*>(soundFile.c_str())); - alutLoadWAVFile(filename, &mFormat, &mData, &mSize, &mFreq, &mLoop); + // Local resources + char *array = NULL; - // Use a different buffer format? - const FormatData *formatData = SoundManager::getSingleton().retrieveFormatData(format); - if(formatData) - mFormat = formatData->formatEnum; + // Main process + try + { + // Open for binary reading + mWavFile = fopen(soundFile.c_str(), "rb"); + OGREAL_CHECK(mWavFile != 0, 13, "Could not load wav from " + soundFile); - alBufferData(mBuffer, mFormat, mData, mSize, mFreq); - alutUnloadWAV(mFormat, mData, mSize, mFreq); + // buffers + char magic[5]; + magic[4] = '\0'; + unsigned char buffer32[4]; + unsigned char buffer16[2]; + // check magic + OGREAL_CHECK(fread(magic,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + OGREAL_CHECK(std::string(magic) == "RIFF", 13, "Wrong wav file format. This file is not a .wav file (no RIFF magic): "+ soundFile ); + + // skip 4 bytes (file size) + fseek(mWavFile,4,SEEK_CUR); + + // check file format + OGREAL_CHECK(fread(magic,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + OGREAL_CHECK(std::string(magic) == "WAVE", 13, "Wrong wav file format. This file is not a .wav file (no WAVE format): "+ soundFile ); + + // check 'fmt ' sub chunk (1) + OGREAL_CHECK(fread(magic,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + OGREAL_CHECK(std::string(magic) == "fmt ", 13, "Wrong wav file format. This file is not a .wav file (no 'fmt ' subchunk): "+ soundFile ); + + // read (1)'s size + OGREAL_CHECK(fread(buffer32,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned long subChunk1Size = readByte32(buffer32); + OGREAL_CHECK(subChunk1Size >= 16, 13, "Wrong wav file format. This file is not a .wav file ('fmt ' chunk too small, truncated file?): "+ soundFile ); + + // check PCM audio format + OGREAL_CHECK(fread(buffer16,2,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned short audioFormat = readByte16(buffer16); + OGREAL_CHECK(audioFormat == 1, 13, "Wrong wav file format. This file is not a .wav file (audio format is not PCM): "+ soundFile ); + + // read number of channels + OGREAL_CHECK(fread(buffer16,2,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned short channels = readByte16(buffer16); + + // read frequency (sample rate) + OGREAL_CHECK(fread(buffer32,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned long frequency = readByte32(buffer32); + + // skip 6 bytes (Byte rate (4), Block align (2)) + fseek(mWavFile,6,SEEK_CUR); + + // read bits per sample + OGREAL_CHECK(fread(buffer16,2,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned short bps = readByte16(buffer16); + + if (channels == 1) + mFormat = (bps == 8) ? AL_FORMAT_MONO8 : AL_FORMAT_MONO16; + else + mFormat = (bps == 8) ? AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16; + + // check 'data' sub chunk (2) + OGREAL_CHECK(fread(magic,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + OGREAL_CHECK(std::string(magic) == "data" || std::string(magic) == "fact", 13, "Wrong wav file format. This file is not a .wav file (no data subchunk): "+ soundFile ); + + // fact is an option section we don't need to worry about + if(std::string(magic) == "fact") + { + fseek(mWavFile,8,SEEK_CUR); + } + + OGREAL_CHECK(fread(buffer32,4,1,mWavFile) == 1, 13, "Cannot read wav file "+ soundFile ); + unsigned long subChunk2Size = readByte32(buffer32); + + // The frequency of the sampling rate + mFreq = frequency; + OGREAL_CHECK(sizeof(mFreq) == sizeof(frequency), 13, "freq and frequency different sizes"); + + array = new char[BUFFER_SIZE]; + + while (data.size() != subChunk2Size) + { + // Read up to a buffer's worth of decoded sound data + bytes = fread(array, 1, BUFFER_SIZE, mWavFile); + + if (bytes <= 0) + break; + + if (data.size() + bytes > subChunk2Size) + bytes = subChunk2Size - data.size(); + + // Append to end of buffer + data.insert(data.end(), array, array + bytes); + } + + delete []array; + array = NULL; + + fclose(mWavFile); + mWavFile = 0; + + alGenBuffers(1, &mBuffer); + OGREAL_CHECK(alGetError() == AL_NO_ERROR, 13, "Could not generate buffer"); + OGREAL_CHECK(AL_NONE != mBuffer, 13, "Could not generate buffer"); + + alBufferData(mBuffer, mFormat, &data[0], Size(data.size()), mFreq); + OGREAL_CHECK(alGetError() == AL_NO_ERROR, 13, "Could not load buffer data"); + + //return buffer; + } + catch(Exception e) + { + if (mBuffer) + { + if (alIsBuffer(mBuffer) == AL_TRUE) + { + alDeleteBuffers(1, &mBuffer); + } + } + + if (array) + { + delete []array; + } + + if(mWavFile) + { + fclose(mWavFile); + mWavFile = 0; + } + + throw (e); + } + mLoop = loop?AL_TRUE:AL_FALSE; createAndBindSource(); Modified: trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.h =================================================================== --- trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.h 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.h 2007-10-23 06:05:12 UTC (rev 454) @@ -78,6 +78,9 @@ ALvoid* mData; friend class SoundFactory; + + private: + FILE* mWavFile; }; } // Namespace #endif Deleted: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp =================================================================== --- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.cpp 2007-10-23 06:05:12 UTC (rev 454) @@ -1,650 +0,0 @@ -/*************************************************************************** - -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); - } - } -} Modified: trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h =================================================================== --- trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h 2007-10-23 00:32:24 UTC (rev 453) +++ trunk/python-ogre/ThirdParty/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugContact.h 2007-10-23 06:05:12 UTC (rev 454) @@ -1,177 +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; - ... [truncated message content] |