Revision: 782
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=782&view=rev
Author: andy_miller
Date: 2008-10-30 03:21:08 +0000 (Thu, 30 Oct 2008)
Log Message:
-----------
Thirdparty updates
Modified Paths:
--------------
trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp
trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h
trunk/python-ogre/ThirdParty/opensteer/Camera.cpp
trunk/python-ogre/ThirdParty/opensteer/Clock.cpp
trunk/python-ogre/ThirdParty/opensteer/Color.cpp
trunk/python-ogre/ThirdParty/opensteer/Obstacle.cpp
trunk/python-ogre/ThirdParty/opensteer/OldPathway.cpp
trunk/python-ogre/ThirdParty/opensteer/Path.cpp
trunk/python-ogre/ThirdParty/opensteer/Pathway.cpp
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPath.cpp
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPathwaySegmentRadii.cpp
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPathwaySingleRadius.cpp
trunk/python-ogre/ThirdParty/opensteer/SegmentedPath.cpp
trunk/python-ogre/ThirdParty/opensteer/SegmentedPathway.cpp
trunk/python-ogre/ThirdParty/opensteer/SimpleVehicle.cpp
trunk/python-ogre/ThirdParty/opensteer/Vec3.cpp
trunk/python-ogre/ThirdParty/opensteer/Vec3Utilities.cpp
trunk/python-ogre/ThirdParty/opensteer/lq.c
Added Paths:
-----------
trunk/python-ogre/ThirdParty/opensteer/AbstractVehicle.h
trunk/python-ogre/ThirdParty/opensteer/Annotation.h
trunk/python-ogre/ThirdParty/opensteer/Camera.h
trunk/python-ogre/ThirdParty/opensteer/Clock.h
trunk/python-ogre/ThirdParty/opensteer/Color.h
trunk/python-ogre/ThirdParty/opensteer/LocalSpace.h
trunk/python-ogre/ThirdParty/opensteer/Obstacle.h
trunk/python-ogre/ThirdParty/opensteer/OldPathway.h
trunk/python-ogre/ThirdParty/opensteer/OpenSteer/
trunk/python-ogre/ThirdParty/opensteer/Path.h
trunk/python-ogre/ThirdParty/opensteer/Pathway.h
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPath.h
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPathwaySegmentRadii.h
trunk/python-ogre/ThirdParty/opensteer/PolylineSegmentedPathwaySingleRadius.h
trunk/python-ogre/ThirdParty/opensteer/Proximity.h
trunk/python-ogre/ThirdParty/opensteer/QueryPathAlike.h
trunk/python-ogre/ThirdParty/opensteer/QueryPathAlikeBaseDataExtractionPolicies.h
trunk/python-ogre/ThirdParty/opensteer/QueryPathAlikeMappings.h
trunk/python-ogre/ThirdParty/opensteer/QueryPathAlikeUtilities.h
trunk/python-ogre/ThirdParty/opensteer/SegmentedPath.h
trunk/python-ogre/ThirdParty/opensteer/SegmentedPathAlikeUtilities.h
trunk/python-ogre/ThirdParty/opensteer/SegmentedPathway.h
trunk/python-ogre/ThirdParty/opensteer/SharedPointer.h
trunk/python-ogre/ThirdParty/opensteer/SimpleVehicle.h
trunk/python-ogre/ThirdParty/opensteer/StandardTypes.h
trunk/python-ogre/ThirdParty/opensteer/SteerLibrary.h
trunk/python-ogre/ThirdParty/opensteer/UnusedParameter.h
trunk/python-ogre/ThirdParty/opensteer/Utilities.h
trunk/python-ogre/ThirdParty/opensteer/Vec3.h
trunk/python-ogre/ThirdParty/opensteer/Vec3Utilities.h
trunk/python-ogre/ThirdParty/opensteer/lq.h
Removed Paths:
-------------
trunk/python-ogre/ThirdParty/opensteer/OpenSteer/
Modified: trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp 2008-10-30 03:03:17 UTC (rev 781)
+++ trunk/python-ogre/ThirdParty/caelum/CaelumSystem.cpp 2008-10-30 03:21:08 UTC (rev 782)
@@ -378,6 +378,7 @@
bool CaelumSystem::frameStarted (const Ogre::FrameEvent &e) {
if (mCleanup) {
// Delayed destruction.
+ Ogre::LogManager::getSingleton ().logMessage ("Caelum: Cleanup set, exiting framestarted.");
mOgreRoot->removeFrameListener (this);
delete this;
return true;
@@ -443,18 +444,18 @@
fogColour * mSceneFogColourMultiplier,
fogDensity * mSceneFogDensityMultiplier);
}
-
+
// Update ground fog.
if (getGroundFog ()) {
getGroundFog ()->setColour (fogColour * mGroundFogColourMultiplier);
getGroundFog ()->setDensity (fogDensity * mGroundFogDensityMultiplier);
}
-
+
// Update sun
if (getSun ()) {
mSun->update (sunDir, sunLightColour, sunSphereColour);
}
-
+
// Update moon.
if (getMoon ()) {
mMoon->update (
@@ -474,7 +475,7 @@
if (getPrecipitationController ()) {
getPrecipitationController ()->update (secondDiff, fogColour);
}
-
+
// Update screen space fog
if (getDepthComposer ()) {
getDepthComposer ()->update ();
@@ -483,7 +484,7 @@
getDepthComposer ()->setGroundFogColour (fogColour * mGroundFogColourMultiplier);
getDepthComposer ()->setGroundFogDensity (fogDensity * mGroundFogDensityMultiplier);
}
-
+
// Update ambient lighting.
if (getManageAmbientLight ()) {
Ogre::ColourValue ambient = Ogre::ColourValue::Black;
@@ -499,7 +500,7 @@
ambient.a = std::max(ambient.a, mMinimumAmbientLight.a);
mSceneMgr->setAmbientLight (ambient);
}
-
+
if (getSun() && getMoon ()) {
Ogre::Real moonBrightness = moonLightColour.r + moonLightColour.g + moonLightColour.b + moonLightColour.a;
Ogre::Real sunBrightness = sunLightColour.r + sunLightColour.g + sunLightColour.b + sunLightColour.a;
Modified: trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h
===================================================================
--- trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h 2008-10-30 03:03:17 UTC (rev 781)
+++ trunk/python-ogre/ThirdParty/ogreal/OgreALPrereqs.h 2008-10-30 03:21:08 UTC (rev 782)
@@ -40,9 +40,9 @@
namespace OgreAL{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
- # include "al.h"
- # include "alc.h"
- # include "xram.h"
+ # include "AL/al.h"
+ # include "AL/alc.h"
+// # include "xram.h"
// # if OGRE_COMPILER == OGRE_COMPILER_MSVC
// # ifdef OGREAL_EXPORT
// # define OgreAL_Export __declspec(dllexport)
@@ -55,20 +55,20 @@
#elif OGRE_COMPILER == OGRE_COMPILER_GNUC
# include "AL/al.h"
# include "AL/alc.h"
- # if defined(OGREAL_EXPORT) && OGRE_COMP_VER >= 400
- # define OgreAL_Export __attribute__ ((visibility("default")))
- # else
+// # if defined(OGREAL_EXPORT) && OGRE_COMP_VER >= 400
+// # define OgreAL_Export __attribute__ ((visibility("default")))
+// # else
# define OgreAL_Export
# endif
// fake EAX/X-RAM
typedef ALenum (*EAXGetBufferMode)(ALuint buffer, ALint *pReserved);
typedef ALboolean (*EAXSetBufferMode)(ALsizei n, ALuint *buffers, ALint value);
- #else // Other Compilers
- # include "al.h"
- # include "alc.h"
- # include "xram.h"
- # define OgreAL_Export
- #endif
+// #else // Other Compilers
+// # include "al.h"
+// # include "alc.h"
+// # include "xram.h"
+// # define OgreAL_Export
+// #endif
#ifndef OGREAL_THREADED
# define OGREAL_THREADED 0
Added: trunk/python-ogre/ThirdParty/opensteer/AbstractVehicle.h
===================================================================
--- trunk/python-ogre/ThirdParty/opensteer/AbstractVehicle.h (rev 0)
+++ trunk/python-ogre/ThirdParty/opensteer/AbstractVehicle.h 2008-10-30 03:21:08 UTC (rev 782)
@@ -0,0 +1,107 @@
+// ----------------------------------------------------------------------------
+//
+//
+// OpenSteer -- Steering Behaviors for Autonomous Characters
+//
+// Copyright (c) 2002-2005, Sony Computer Entertainment America
+// Original author: Craig Reynolds <cra...@pl...>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+//
+// ----------------------------------------------------------------------------
+//
+//
+// AbstractVehicle: pure virtual base class for generic steerable vehicles
+//
+// 10-04-04 bk: put everything into the OpenSteer namespace
+// 01-30-03 cwr: created
+//
+//
+// ----------------------------------------------------------------------------
+
+#ifndef OPENSTEER_ABSTRACTVEHICLE_H
+#define OPENSTEER_ABSTRACTVEHICLE_H
+
+
+#include "LocalSpace.h"
+
+
+// STL vector containers
+#include <vector>
+
+
+// ----------------------------------------------------------------------------
+
+namespace OpenSteer {
+
+ class AbstractVehicle : public AbstractLocalSpace
+ {
+ public:
+ virtual ~AbstractVehicle() { /* Nothing to do. */ }
+
+ // mass (defaults to unity so acceleration=force)
+ virtual float mass (void) const = 0;
+ virtual float setMass (float) = 0;
+
+ // size of bounding sphere, for obstacle avoidance, etc.
+ virtual float radius (void) const = 0;
+ virtual float setRadius (float) = 0;
+
+ // velocity of vehicle
+ virtual Vec3 velocity (void) const = 0;
+
+ // speed of vehicle (may be faster than taking magnitude of velocity)
+ virtual float speed (void) const = 0;
+ virtual float setSpeed (float) = 0;
+
+ // groups of (pointers to) abstract vehicles, and iterators over them
+ typedef std::vector<AbstractVehicle*> group;
+ typedef group::const_iterator iterator;
+
+ // predict position of this vehicle at some time in the future
+ // (assumes velocity remains constant)
+ virtual Vec3 predictFuturePosition (const float predictionTime) const = 0;
+
+ // ----------------------------------------------------------------------
+ // XXX this vehicle-model-specific functionality functionality seems out
+ // XXX of place on the abstract base class, but for now it is expedient
+
+ // the maximum steering force this vehicle can apply
+ virtual float maxForce (void) const = 0;
+ virtual float setMaxForce (float) = 0;
+
+ // the maximum speed this vehicle is allowed to move
+ virtual float maxSpeed (void) const = 0;
+ virtual float setMaxSpeed (float) = 0;
+
+ // dp - added to support heterogeneous flocks
+ virtual void update(const float currentTime, const float elapsedTime) = 0;
+ };
+
+
+ // more convenient short names for AbstractVehicle group and iterator
+ typedef AbstractVehicle::group AVGroup;
+ typedef AbstractVehicle::iterator AVIterator;
+
+} // namespace OpenSteer
+
+
+// ----------------------------------------------------------------------------
+#endif // OPENSTEER_ABSTRACTVEHICLE_H
Added: trunk/python-ogre/ThirdParty/opensteer/Annotation.h
===================================================================
--- trunk/python-ogre/ThirdParty/opensteer/Annotation.h (rev 0)
+++ trunk/python-ogre/ThirdParty/opensteer/Annotation.h 2008-10-30 03:21:08 UTC (rev 782)
@@ -0,0 +1,449 @@
+// ----------------------------------------------------------------------------
+//
+//
+// OpenSteer -- Steering Behaviors for Autonomous Characters
+//
+// Copyright (c) 2002-2005, Sony Computer Entertainment America
+// Original author: Craig Reynolds <cra...@pl...>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+//
+// ----------------------------------------------------------------------------
+//
+//
+// AnnotationMixin
+//
+// This mixin (class with templated superclass) adds OpenSteerDemo-based
+// graphical annotation functionality to a given base class, which is
+// typically something that supports the AbstractVehicle interface.
+//
+// 10-04-04 bk: put everything into the OpenSteer namespace
+// 04-01-03 cwr: made into a mixin
+// 07-01-02 cwr: created (as Annotation.h)
+//
+//
+// ----------------------------------------------------------------------------
+
+
+#ifndef OPENSTEER_ANNOTATION_H
+#define OPENSTEER_ANNOTATION_H
+
+#ifndef NOT_OPENSTEERDEMO // only when building OpenSteerDemo
+#include "Draw.h"
+#endif // NOT_OPENSTEERDEMO
+#include "Vec3.h"
+#include "Color.h"
+
+// ----------------------------------------------------------------------------
+
+
+namespace OpenSteer {
+
+ extern bool enableAnnotation;
+ extern bool drawPhaseActive;
+
+ // graphical annotation: master on/off switch
+ inline bool annotationIsOn (void) {return enableAnnotation;}
+ inline void setAnnotationOn (void) {enableAnnotation = true;}
+ inline void setAnnotationOff (void) {enableAnnotation = false;}
+ inline bool toggleAnnotationState (void) {return (enableAnnotation = !enableAnnotation);}
+
+ template <class Super>
+ class AnnotationMixin : public Super
+ {
+ public:
+
+ // constructor
+ AnnotationMixin ();
+
+ // destructor
+ virtual ~AnnotationMixin ();
+
+ // ------------------------------------------------------------------------
+ // trails / streamers
+ //
+ // these routines support visualization of a vehicle's recent path
+ //
+ // XXX conceivable trail/streamer should be a separate class,
+ // XXX Annotation would "has-a" one (or more))
+
+ // record a position for the current time, called once per update
+ void recordTrailVertex (const float currentTime, const Vec3& position);
+
+ // draw the trail as a dotted line, fading away with age
+ void drawTrail (void) {drawTrail (grayColor (0.7f), gWhite);}
+ void drawTrail (const Color& trailColor, const Color& tickColor);
+
+ // set trail parameters: the amount of time it represents and the
+ // number of samples along its length. re-allocates internal buffers.
+ void setTrailParameters (const float duration, const int vertexCount);
+
+ // forget trail history: used to prevent long streaks due to teleportation
+ void clearTrailHistory (void);
+
+ // ------------------------------------------------------------------------
+ // drawing of lines, circles and (filled) disks to annotate steering
+ // behaviors. When called during OpenSteerDemo's simulation update phase,
+ // these functions call a "deferred draw" routine which buffer the
+ // arguments for use during the redraw phase.
+ //
+ // note: "circle" means unfilled
+ // "disk" means filled
+ // "XZ" means on a plane parallel to the X and Z axes (perp to Y)
+ // "3d" means the circle is perpendicular to the given "axis"
+ // "segments" is the number of line segments used to draw the circle
+
+ // draw an opaque colored line segment between two locations in space
+ void annotationLine (const Vec3& startPoint,
+ const Vec3& endPoint,
+ const Color& color) const;
+
+ // draw a circle on the XZ plane
+ void annotationXZCircle (const float radius,
+ const Vec3& center,
+ const Color& color,
+ const int segments) const
+ {
+ annotationXZCircleOrDisk (radius, center, color, segments, false);
+ }
+
+
+ // draw a disk on the XZ plane
+ void annotationXZDisk (const float radius,
+ const Vec3& center,
+ const Color& color,
+ const int segments) const
+ {
+ annotationXZCircleOrDisk (radius, center, color, segments, true);
+ }
+
+
+ // draw a circle perpendicular to the given axis
+ void annotation3dCircle (const float radius,
+ const Vec3& center,
+ const Vec3& axis,
+ const Color& color,
+ const int segments) const
+ {
+ annotation3dCircleOrDisk (radius, center, axis, color, segments, false);
+ }
+
+
+ // draw a disk perpendicular to the given axis
+ void annotation3dDisk (const float radius,
+ const Vec3& center,
+ const Vec3& axis,
+ const Color& color,
+ const int segments) const
+ {
+ annotation3dCircleOrDisk (radius, center, axis, color, segments, true);
+ }
+
+ //
+
+ // ------------------------------------------------------------------------
+ // support for annotation circles
+
+ void annotationXZCircleOrDisk (const float radius,
+ const Vec3& center,
+ const Color& color,
+ const int segments,
+ const bool filled) const
+ {
+ annotationCircleOrDisk (radius,
+ Vec3::zero,
+ center,
+ color,
+ segments,
+ filled,
+ false); // "not in3d" -> on XZ plane
+ }
+
+
+ void annotation3dCircleOrDisk (const float radius,
+ const Vec3& center,
+ const Vec3& axis,
+ const Color& color,
+ const int segments,
+ const bool filled) const
+ {
+ annotationCircleOrDisk (radius,
+ axis,
+ center,
+ color,
+ segments,
+ filled,
+ true); // "in3d"
+ }
+
+ void annotationCircleOrDisk (const float radius,
+ const Vec3& axis,
+ const Vec3& center,
+ const Color& color,
+ const int segments,
+ const bool filled,
+ const bool in3d) const;
+
+ // ------------------------------------------------------------------------
+ private:
+
+ // trails
+ int trailVertexCount; // number of vertices in array (ring buffer)
+ int trailIndex; // array index of most recently recorded point
+ float trailDuration; // duration (in seconds) of entire trail
+ float trailSampleInterval; // desired interval between taking samples
+ float trailLastSampleTime; // global time when lat sample was taken
+ int trailDottedPhase; // dotted line: draw segment or not
+ Vec3 curPosition; // last reported position of vehicle
+ Vec3* trailVertices; // array (ring) of recent points along trail
+ char* trailFlags; // array (ring) of flag bits for trail points
+ };
+
+} // namespace OpenSteer
+
+
+
+// ----------------------------------------------------------------------------
+// Constructor and destructor
+
+
+template<class Super>
+OpenSteer::AnnotationMixin<Super>::AnnotationMixin (void)
+{
+ trailVertices = NULL;
+ trailFlags = NULL;
+
+ // xxx I wonder if it makes more sense to NOT do this here, see if the
+ // xxx vehicle class calls it to set custom parameters, and if not, set
+ // xxx these default parameters on first call to a "trail" function. The
+ // xxx issue is whether it is a problem to allocate default-sized arrays
+ // xxx then to free them and allocate new ones
+ setTrailParameters (5, 100); // 5 seconds with 100 points along the trail
+}
+
+
+template<class Super>
+OpenSteer::AnnotationMixin<Super>::~AnnotationMixin (void)
+{
+ delete[] trailVertices;
+ delete[] trailFlags;
+}
+
+
+// ----------------------------------------------------------------------------
+// set trail parameters: the amount of time it represents and the number of
+// samples along its length. re-allocates internal buffers.
+
+
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::setTrailParameters (const float duration,
+ const int vertexCount)
+{
+ // record new parameters
+ trailDuration = duration;
+ trailVertexCount = vertexCount;
+
+ // reset other internal trail state
+ trailIndex = 0;
+ trailLastSampleTime = 0;
+ trailSampleInterval = trailDuration / trailVertexCount;
+ trailDottedPhase = 1;
+
+ // prepare trailVertices array: free old one if needed, allocate new one
+ delete[] trailVertices;
+ trailVertices = new Vec3[trailVertexCount];
+
+ // prepare trailFlags array: free old one if needed, allocate new one
+ delete[] trailFlags;
+ trailFlags = new char[trailVertexCount];
+
+ // initializing all flags to zero means "do not draw this segment"
+ for (int i = 0; i < trailVertexCount; i++) trailFlags[i] = 0;
+}
+
+
+// ----------------------------------------------------------------------------
+// forget trail history: used to prevent long streaks due to teleportation
+//
+// XXX perhaps this coudl be made automatic: triggered when the change in
+// XXX position is well out of the range of the vehicles top velocity
+
+
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::clearTrailHistory (void)
+{
+ // brute force implementation, reset everything
+ setTrailParameters (trailDuration, trailVertexCount);
+}
+
+
+// ----------------------------------------------------------------------------
+// record a position for the current time, called once per update
+
+
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::recordTrailVertex (const float currentTime,
+ const Vec3& position)
+{
+ const float timeSinceLastTrailSample = currentTime - trailLastSampleTime;
+ if (timeSinceLastTrailSample > trailSampleInterval)
+ {
+ trailIndex = (trailIndex + 1) % trailVertexCount;
+ trailVertices [trailIndex] = position;
+ trailDottedPhase = (trailDottedPhase + 1) % 2;
+ const int tick = (floorXXX (currentTime) >
+ floorXXX (trailLastSampleTime));
+ trailFlags [trailIndex] = trailDottedPhase | (tick ? '\2' : '\0');
+ trailLastSampleTime = currentTime;
+ }
+ curPosition = position;
+}
+
+
+// ----------------------------------------------------------------------------
+// draw the trail as a dotted line, fading away with age
+
+
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::drawTrail (const Color& trailColor,
+ const Color& tickColor)
+{
+ if (enableAnnotation)
+ {
+ int index = trailIndex;
+ for (int j = 0; j < trailVertexCount; j++)
+ {
+ // index of the next vertex (mod around ring buffer)
+ const int next = (index + 1) % trailVertexCount;
+
+ // "tick mark": every second, draw a segment in a different color
+ const int tick = ((trailFlags [index] & 2) ||
+ (trailFlags [next] & 2));
+ const Color color = tick ? tickColor : trailColor;
+
+ // draw every other segment
+ if (trailFlags [index] & 1)
+ {
+ if (j == 0)
+ {
+ // draw segment from current position to first trail point
+ drawLineAlpha (curPosition,
+ trailVertices [index],
+ color,
+ 1);
+ }
+ else
+ {
+ // draw trail segments with opacity decreasing with age
+ const float minO = 0.05f; // minimum opacity
+ const float fraction = (float) j / trailVertexCount;
+ const float opacity = (fraction * (1 - minO)) + minO;
+ drawLineAlpha (trailVertices [index],
+ trailVertices [next],
+ color,
+ opacity);
+ }
+ }
+ index = next;
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// request (deferred) drawing of a line for graphical annotation
+//
+// This is called during OpenSteerDemo's simulation phase to annotate behavioral
+// or steering state. When annotation is enabled, a description of the line
+// segment is queued to be drawn during OpenSteerDemo's redraw phase.
+
+
+#ifndef NOT_OPENSTEERDEMO // only when building OpenSteerDemo
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::annotationLine (const Vec3& startPoint,
+ const Vec3& endPoint,
+ const Color& color) const
+{
+ if (enableAnnotation)
+ {
+ if (drawPhaseActive)
+ {
+ drawLine (startPoint, endPoint, color);
+ }
+ else
+ {
+ deferredDrawLine (startPoint, endPoint, color);
+ }
+ }
+}
+#else
+template<class Super> void OpenSteer::AnnotationMixin<Super>::annotationLine
+ (const Vec3&, const Vec3&, const Vec3&) const {}
+#endif // NOT_OPENSTEERDEMO
+
+
+// ----------------------------------------------------------------------------
+// request (deferred) drawing of a circle (or disk) for graphical annotation
+//
+// This is called during OpenSteerDemo's simulation phase to annotate behavioral
+// or steering state. When annotation is enabled, a description of the
+// "circle or disk" is queued to be drawn during OpenSteerDemo's redraw phase.
+
+
+#ifndef NOT_OPENSTEERDEMO // only when building OpenSteerDemo
+template<class Super>
+void
+OpenSteer::AnnotationMixin<Super>::annotationCircleOrDisk (const float radius,
+ const Vec3& axis,
+ const Vec3& center,
+ const Color& color,
+ const int segments,
+ const bool filled,
+ const bool in3d) const
+{
+ if (enableAnnotation)
+ {
+ if (drawPhaseActive)
+ {
+ drawCircleOrDisk (radius, axis, center, color,
+ segments, filled, in3d);
+ }
+ else
+ {
+ deferredDrawCircleOrDisk (radius, axis, center, color,
+ segments, filled, in3d);
+ }
+ }
+}
+#else
+template<class Super>
+void OpenSteer::AnnotationMixin<Super>::annotationCircleOrDisk
+(const float, const Vec3&, const Vec3&, const Vec3&, const int,
+ const bool, const bool) const {}
+#endif // NOT_OPENSTEERDEMO
+
+
+// ----------------------------------------------------------------------------
+#endif // OPENSTEER_ANNOTATION_H
Modified: trunk/python-ogre/ThirdParty/opensteer/Camera.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/opensteer/Camera.cpp 2008-10-30 03:03:17 UTC (rev 781)
+++ trunk/python-ogre/ThirdParty/opensteer/Camera.cpp 2008-10-30 03:21:08 UTC (rev 782)
@@ -1,433 +1,433 @@
-// ----------------------------------------------------------------------------
-//
-//
-// OpenSteer -- Steering Behaviors for Autonomous Characters
-//
-// Copyright (c) 2002-2005, Sony Computer Entertainment America
-// Original author: Craig Reynolds <cra...@pl...>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-//
-// ----------------------------------------------------------------------------
-//
-//
-// camera control for OpenSteerDemo
-//
-// a camera ("point of view") with various "aiming modes" to track a
-// moving vehicle
-//
-// 10-04-04 bk: put everything into the OpenSteer namespace
-// 06-26-02 cwr: created
-//
-//
-// ----------------------------------------------------------------------------
-
-
-#include "OpenSteer/Camera.h"
-#include "OpenSteer/Draw.h"
-
-
-// ----------------------------------------------------------------------------
-// constructor
-
-
-OpenSteer::Camera::Camera (void)
-{
- reset ();
-}
-
-
-// ----------------------------------------------------------------------------
-// reset all camera state to default values
-
-
-void
-OpenSteer::Camera::reset (void)
-{
- // reset camera's position and orientation
- resetLocalSpace ();
-
- // "look at" point, center of view
- target = Vec3::zero;
-
- // vehicle being tracked
- vehicleToTrack = NULL;
-
- // aim at predicted position of vehicleToTrack, this far into thefuture
- aimLeadTime = 1;
-
- // make first update abrupt
- smoothNextMove = false;
-
- // relative rate at which camera transitions proceed
- smoothMoveSpeed = 1.5f;
-
- // select camera aiming mode
- mode = cmFixed;
-
- // "constant distance from vehicle" camera mode parameters
- fixedDistDistance = 1;
- fixedDistVOffset = 0;
-
- // "look straight down at vehicle" camera mode parameters
- lookdownDistance = 30;
-
- // "static" camera mode parameters
- fixedPosition.set (75, 75, 75);
- fixedTarget = Vec3::zero;
- fixedUp = Vec3::up;
-
- // "fixed local offset" camera mode parameters
- fixedLocalOffset.set (5, 5, -5);
-
- // "offset POV" camera mode parameters
- povOffset.set (0, 1, -3);
-}
-
-
-// ----------------------------------------------------------------------------
-// called once per frame to update camera state according to currently
-// selected mode and per-mode parameters. Works in position/target/up
-// ("look at") space.
-//
-// parameter names commented out to prevent compiler warning from "-W"
-
-
-void
-OpenSteer::Camera::update (const float /*currentTime*/,
- const float elapsedTime,
- const bool simulationPaused)
-{
- // vehicle being tracked (just a reference with a more concise name)
- const AbstractVehicle& v = *vehicleToTrack;
- const bool noVehicle = vehicleToTrack == NULL;
-
- // new position/target/up, set in switch below, defaults to current
- Vec3 newPosition = position();
- Vec3 newTarget = target;
- Vec3 newUp = up();
-
-
- // prediction time to compensate for lag caused by smoothing moves
- const float antiLagTime = simulationPaused ? 0 : 1 / smoothMoveSpeed;
-
- // aim at a predicted future position of the target vehicle
- const float predictionTime = aimLeadTime + antiLagTime;
-
- // set new position/target/up according to camera aim mode
- switch (mode)
- {
- case cmFixed:
- newPosition = fixedPosition;
- newTarget = fixedTarget;
- newUp = fixedUp;
- break;
-
- case cmFixedDistanceOffset:
- if (noVehicle) break;
- newUp = Vec3::up; // xxx maybe this should be v.up ?
- newTarget = v.predictFuturePosition (predictionTime);
- newPosition = constDistHelper (elapsedTime);
- break;
-
- case cmStraightDown:
- if (noVehicle) break;
- newUp = v.forward();
- newTarget = v.predictFuturePosition (predictionTime);
- newPosition = newTarget;
- newPosition.y += lookdownDistance;
- break;
-
- case cmFixedLocalOffset:
- if (noVehicle) break;
- newUp = v.up();
- newTarget = v.predictFuturePosition (predictionTime);
- newPosition = v.globalizePosition (fixedLocalOffset);
- break;
-
- case cmOffsetPOV:
- {
- if (noVehicle) break;
- newUp = v.up();
- const Vec3 futurePosition = v.predictFuturePosition (antiLagTime);
- const Vec3 globalOffset = v.globalizeDirection (povOffset);
- newPosition = futurePosition + globalOffset;
- // XXX hack to improve smoothing between modes (no effect on aim)
- const float L = 10;
- newTarget = newPosition + (v.forward() * L);
- break;
- }
- default:
- break;
- }
-
- // blend from current position/target/up towards new values
- smoothCameraMove (newPosition, newTarget, newUp, elapsedTime);
-
- // set camera in draw module
- drawCameraLookAt (position(), target, up());
-}
-
-
-// ----------------------------------------------------------------------------
-// Smoothly move camera: blend (at a rate controlled by smoothMoveSpeed)
-// from current camera state toward newly determined camera state.
-//
-// The flag smoothNextMove can be set (with doNotSmoothNextMove()) to
-// make next update (say at simulation initialization time).
-
-
-void
-OpenSteer::Camera::smoothCameraMove (const Vec3& newPosition,
- const Vec3& newTarget,
- const Vec3& newUp,
- const float elapsedTime)
-{
- if (smoothNextMove)
- {
- const float smoothRate = elapsedTime * smoothMoveSpeed;
-
- Vec3 tempPosition = position();
- Vec3 tempUp = up();
- blendIntoAccumulator (smoothRate, newPosition, tempPosition);
- blendIntoAccumulator (smoothRate, newTarget, target);
- blendIntoAccumulator (smoothRate, newUp, tempUp);
- setPosition (tempPosition);
- setUp (tempUp);
-
- // xxx not sure if these are needed, seems like a good idea
- // xxx (also if either up or oldUP are zero, use the other?)
- // xxx (even better: force up to be perp to target-position axis))
- if (up() == Vec3::zero)
- setUp (Vec3::up);
- else
- setUp (up().normalize ());
- }
- else
- {
- smoothNextMove = true;
-
- setPosition (newPosition);
- target = newTarget;
- setUp (newUp);
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// computes a new camera position which follows "target" at distant of
-// "dragTargetDistance"
-//
-// parameter names commented out to prevent compiler warning from "-W"
-
-
-OpenSteer::Vec3
-OpenSteer::Camera::constDistHelper (const float /*elapsedTime*/)
-{
- // is the "global up"/"vertical" offset constraint enabled? (it forces
- // the camera's global-up (Y) cordinate to be a above/below the target
- // vehicle by a given offset.)
- const bool constrainUp = (fixedDistVOffset != 0);
-
- // vector offset from target to current camera position
- const Vec3 adjustedPosition (position().x,
- (constrainUp) ? target.y : position().y,
- position().z);
- const Vec3 offset = adjustedPosition - target;
-
- // current distance between them
- const float distance = offset.length();
-
- // move camera only when geometry is well-defined (avoid degenerate case)
- if (distance == 0)
- {
- return position();
- }
- else
- {
- // unit vector along original offset
- const Vec3 unitOffset = offset / distance;
-
- // new offset of length XXX
- const float xxxDistance = sqrtXXX (square (fixedDistDistance) -
- square (fixedDistVOffset));
- const Vec3 newOffset = unitOffset * xxxDistance;
-
- // return new camera position: adjust distance to target
- return target + newOffset + Vec3 (0, fixedDistVOffset, 0);
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// select next camera mode, used by OpenSteerDemo
-
-
-void
-OpenSteer::Camera::selectNextMode (void)
-{
- mode = successorMode (mode);
- if (mode >= cmEndMode) mode = successorMode (cmStartMode);
-}
-
-
-// ----------------------------------------------------------------------------
-// cycles through the various camera modes
-
-
-OpenSteer::Camera::cameraMode
-OpenSteer::Camera::successorMode (const cameraMode cm) const
-{
- return (cameraMode)(((int)cm) + 1);
-}
-
-
-// ----------------------------------------------------------------------------
-// string naming current camera mode, used by OpenSteerDemo
-
-
-char*
-OpenSteer::Camera::modeName (void)
-{
- switch (mode)
- {
- case cmFixed: return "static"; break;
- case cmFixedDistanceOffset: return "fixed distance offset"; break;
- case cmFixedLocalOffset: return "fixed local offset"; break;
- case cmOffsetPOV: return "offset POV"; break;
- case cmStraightDown: return "straight down"; break;
- default: return "?";
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// adjust the offest vector of the current camera mode based on a
-// "mouse adjustment vector" from OpenSteerDemo (xxx experiment 10-17-02)
-
-
-void
-OpenSteer::Camera::mouseAdjustOffset (const Vec3& adjustment)
-{
- // vehicle being tracked (just a reference with a more concise name)
- const AbstractVehicle& v = *vehicleToTrack;
-
- switch (mode)
- {
- case cmFixed:
- {
- const Vec3 offset = fixedPosition - fixedTarget;
- const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
- fixedPosition = fixedTarget + adjusted;
- break;
- }
- case cmFixedDistanceOffset:
- {
- // XXX this is the oddball case, adjusting "position" instead
- // XXX of mode parameters, hence no smoothing during adjustment
- // XXX Plus the fixedDistVOffset feature complicates things
- const Vec3 offset = position() - target;
- const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
- // XXX --------------------------------------------------
-// position = target + adjusted;
-// fixedDistDistance = adjusted.length();
-// fixedDistVOffset = position.y - target.y;
- // XXX --------------------------------------------------
-// const float s = smoothMoveSpeed * (1.0f/40f);
-// const Vec3 newPosition = target + adjusted;
-// position = interpolate (s, position, newPosition);
-// fixedDistDistance = interpolate (s, fixedDistDistance, adjusted.length());
-// fixedDistVOffset = interpolate (s, fixedDistVOffset, position.y - target.y);
- // XXX --------------------------------------------------
-// position = target + adjusted;
- setPosition (target + adjusted);
- fixedDistDistance = adjusted.length();
-// fixedDistVOffset = position.y - target.y;
- fixedDistVOffset = position().y - target.y;
- // XXX --------------------------------------------------
- break;
- }
- case cmStraightDown:
- {
- const Vec3 offset (0, 0, lookdownDistance);
- const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
- lookdownDistance = adjusted.z;
- break;
- }
- case cmFixedLocalOffset:
- {
- const Vec3 offset = v.globalizeDirection (fixedLocalOffset);
- const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
- fixedLocalOffset = v.localizeDirection (adjusted);
- break;
- }
- case cmOffsetPOV:
- {
- // XXX this might work better as a translation control, it is
- // XXX non-obvious using a polar adjustment when the view
- // XXX center is not at the camera aim target
- const Vec3 offset = v.globalizeDirection (povOffset);
- const Vec3 adjusted = mouseAdjustOrtho (adjustment, offset);
- povOffset = v.localizeDirection (adjusted);
- break;
- }
- default:
- break;
- }
-}
-
-
-// ----------------------------------------------------------------------------
-
-
-OpenSteer::Vec3
-OpenSteer::Camera::mouseAdjust2 (const bool polar,
- const Vec3& adjustment,
- const Vec3& offsetToAdjust)
-{
- // value to be returned
- Vec3 result = offsetToAdjust;
-
- // using the camera's side/up axes (essentially: screen space) move the
- // offset vector sideways according to adjustment.x and vertically
- // according to adjustment.y, constrain the offset vector's length to
- // stay the same, hence the offset's "tip" stays on the surface of a
- // sphere.
- const float oldLength = result.length ();
- const float rate = polar ? oldLength : 1;
- result += xxxls().side() * (adjustment.x * rate);
- result += xxxls().up() * (adjustment.y * rate);
- if (polar)
- {
- const float newLength = result.length ();
- result *= oldLength / newLength;
- }
-
- // change the length of the offset vector according to adjustment.z
- if (polar)
- result *= (1 + adjustment.z);
- else
- result += xxxls().forward() * adjustment.z;
-
- return result;
-}
-
-
-// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+//
+//
+// OpenSteer -- Steering Behaviors for Autonomous Characters
+//
+// Copyright (c) 2002-2005, Sony Computer Entertainment America
+// Original author: Craig Reynolds <cra...@pl...>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+//
+// ----------------------------------------------------------------------------
+//
+//
+// camera control for OpenSteerDemo
+//
+// a camera ("point of view") with various "aiming modes" to track a
+// moving vehicle
+//
+// 10-04-04 bk: put everything into the OpenSteer namespace
+// 06-26-02 cwr: created
+//
+//
+// ----------------------------------------------------------------------------
+
+
+#include "Camera.h"
+#include "Draw.h"
+
+
+// ----------------------------------------------------------------------------
+// constructor
+
+
+OpenSteer::Camera::Camera (void)
+{
+ reset ();
+}
+
+
+// ----------------------------------------------------------------------------
+// reset all camera state to default values
+
+
+void
+OpenSteer::Camera::reset (void)
+{
+ // reset camera's position and orientation
+ resetLocalSpace ();
+
+ // "look at" point, center of view
+ target = Vec3::zero;
+
+ // vehicle being tracked
+ vehicleToTrack = NULL;
+
+ // aim at predicted position of vehicleToTrack, this far into thefuture
+ aimLeadTime = 1;
+
+ // make first update abrupt
+ smoothNextMove = false;
+
+ // relative rate at which camera transitions proceed
+ smoothMoveSpeed = 1.5f;
+
+ // select camera aiming mode
+ mode = cmFixed;
+
+ // "constant distance from vehicle" camera mode parameters
+ fixedDistDistance = 1;
+ fixedDistVOffset = 0;
+
+ // "look straight down at vehicle" camera mode parameters
+ lookdownDistance = 30;
+
+ // "static" camera mode parameters
+ fixedPosition.set (75, 75, 75);
+ fixedTarget = Vec3::zero;
+ fixedUp = Vec3::up;
+
+ // "fixed local offset" camera mode parameters
+ fixedLocalOffset.set (5, 5, -5);
+
+ // "offset POV" camera mode parameters
+ povOffset.set (0, 1, -3);
+}
+
+
+// ----------------------------------------------------------------------------
+// called once per frame to update camera state according to currently
+// selected mode and per-mode parameters. Works in position/target/up
+// ("look at") space.
+//
+// parameter names commented out to prevent compiler warning from "-W"
+
+
+void
+OpenSteer::Camera::update (const float /*currentTime*/,
+ const float elapsedTime,
+ const bool simulationPaused)
+{
+ // vehicle being tracked (just a reference with a more concise name)
+ const AbstractVehicle& v = *vehicleToTrack;
+ const bool noVehicle = vehicleToTrack == NULL;
+
+ // new position/target/up, set in switch below, defaults to current
+ Vec3 newPosition = position();
+ Vec3 newTarget = target;
+ Vec3 newUp = up();
+
+
+ // prediction time to compensate for lag caused by smoothing moves
+ const float antiLagTime = simulationPaused ? 0 : 1 / smoothMoveSpeed;
+
+ // aim at a predicted future position of the target vehicle
+ const float predictionTime = aimLeadTime + antiLagTime;
+
+ // set new position/target/up according to camera aim mode
+ switch (mode)
+ {
+ case cmFixed:
+ newPosition = fixedPosition;
+ newTarget = fixedTarget;
+ newUp = fixedUp;
+ break;
+
+ case cmFixedDistanceOffset:
+ if (noVehicle) break;
+ newUp = Vec3::up; // xxx maybe this should be v.up ?
+ newTarget = v.predictFuturePosition (predictionTime);
+ newPosition = constDistHelper (elapsedTime);
+ break;
+
+ case cmStraightDown:
+ if (noVehicle) break;
+ newUp = v.forward();
+ newTarget = v.predictFuturePosition (predictionTime);
+ newPosition = newTarget;
+ newPosition.y += lookdownDistance;
+ break;
+
+ case cmFixedLocalOffset:
+ if (noVehicle) break;
+ newUp = v.up();
+ newTarget = v.predictFuturePosition (predictionTime);
+ newPosition = v.globalizePosition (fixedLocalOffset);
+ break;
+
+ case cmOffsetPOV:
+ {
+ if (noVehicle) break;
+ newUp = v.up();
+ const Vec3 futurePosition = v.predictFuturePosition (antiLagTime);
+ const Vec3 globalOffset = v.globalizeDirection (povOffset);
+ newPosition = futurePosition + globalOffset;
+ // XXX hack to improve smoothing between modes (no effect on aim)
+ const float L = 10;
+ newTarget = newPosition + (v.forward() * L);
+ break;
+ }
+ default:
+ break;
+ }
+
+ // blend from current position/target/up towards new values
+ smoothCameraMove (newPosition, newTarget, newUp, elapsedTime);
+
+ // set camera in draw module
+ drawCameraLookAt (position(), target, up());
+}
+
+
+// ----------------------------------------------------------------------------
+// Smoothly move camera: blend (at a rate controlled by smoothMoveSpeed)
+// from current camera state toward newly determined camera state.
+//
+// The flag smoothNextMove can be set (with doNotSmoothNextMove()) to
+// make next update (say at simulation initialization time).
+
+
+void
+OpenSteer::Camera::smoothCameraMove (const Vec3& newPosition,
+ const Vec3& newTarget,
+ const Vec3& newUp,
+ const float elapsedTime)
+{
+ if (smoothNextMove)
+ {
+ const float smoothRate = elapsedTime * smoothMoveSpeed;
+
+ Vec3 tempPosition = position();
+ Vec3 tempUp = up();
+ blendIntoAccumulator (smoothRate, newPosition, tempPosition);
+ blendIntoAccumulator (smoothRate, newTarget, target);
+ blendIntoAccumulator (smoothRate, newUp, tempUp);
+ setPosition (tempPosition);
+ setUp (tempUp);
+
+ // xxx not sure if these are needed, seems like a good idea
+ // xxx (also if either up or oldUP are zero, use the other?)
+ // xxx (even better: force up to be perp to target-position axis))
+ if (up() == Vec3::zero)
+ setUp (Vec3::up);
+ else
+ setUp (up().normalize ());
+ }
+ else
+ {
+ smoothNextMove = true;
+
+ setPosition (newPosition);
+ target = newTarget;
+ setUp (newUp);
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// computes a new camera position which follows "target" at distant of
+// "dragTargetDistance"
+//
+// parameter names commented out to prevent compiler warning from "-W"
+
+
+OpenSteer::Vec3
+OpenSteer::Camera::constDistHelper (const float /*elapsedTime*/)
+{
+ // is the "global up"/"vertical" offset constraint enabled? (it forces
+ // the camera's global-up (Y) cordinate to be a above/below the target
+ // vehicle by a given offset.)
+ const bool constrainUp = (fixedDistVOffset != 0);
+
+ // vector offset from target to current camera position
+ const Vec3 adjustedPosition (position().x,
+ (constrainUp) ? target.y : position().y,
+ position().z);
+ const Vec3 offset = adjustedPosition - target;
+
+ // current distance between them
+ const float distance = offset.length();
+
+ // move camera only when geometry is well-defined (avoid degenerate case)
+ if (distance == 0)
+ {
+ return position();
+ }
+ else
+ {
+ // unit vector along original offset
+ const Vec3 unitOffset = offset / distance;
+
+ // new offset of length XXX
+ const float xxxDistance = sqrtXXX (square (fixedDistDistance) -
+ square (fixedDistVOffset));
+ const Vec3 newOffset = unitOffset * xxxDistance;
+
+ // return new camera position: adjust distance to target
+ return target + newOffset + Vec3 (0, fixedDistVOffset, 0);
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// select next camera mode, used by OpenSteerDemo
+
+
+void
+OpenSteer::Camera::selectNextMode (void)
+{
+ mode = successorMode (mode);
+ if (mode >= cmEndMode) mode = successorMode (cmStartMode);
+}
+
+
+// ----------------------------------------------------------------------------
+// cycles through the various camera modes
+
+
+OpenSteer::Camera::cameraMode
+OpenSteer::Camera::successorMode (const cameraMode cm) const
+{
+ return (cameraMode)(((int)cm) + 1);
+}
+
+
+// ----------------------------------------------------------------------------
+// string naming current camera mode, used by OpenSteerDemo
+
+
+char*
+OpenSteer::Camera::modeName (void)
+{
+ switch (mode)
+ {
+ case cmFixed: return "static"; break;
+ case cmFixedDistanceOffset: return "fixed distance offset"; break;
+ case cmFixedLocalOffset: return "fixed local offset"; break;
+ case cmOffsetPOV: return "offset POV"; break;
+ case cmStraightDown: return "straight down"; break;
+ default: return "?";
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// adjust the offest vector of the current camera mode based on a
+// "mouse adjustment vector" from OpenSteerDemo (xxx experiment 10-17-02)
+
+
+void
+OpenSteer::Camera::mouseAdjustOffset (const Vec3& adjustment)
+{
+ // vehicle being tracked (just a reference with a more concise name)
+ const AbstractVehicle& v = *vehicleToTrack;
+
+ switch (mode)
+ {
+ case cmFixed:
+ {
+ const Vec3 offset = fixedPosition - fixedTarget;
+ const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
+ fixedPosition = fixedTarget + adjusted;
+ break;
+ }
+ case cmFixedDistanceOffset:
+ {
+ // XXX this is the oddball case, adjusting "position" instead
+ // XXX of mode parameters, hence no smoothing during adjustment
+ // XXX Plus the fixedDistVOffset feature complicates things
+ const Vec3 offset = position() - target;
+ const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
+ // XXX --------------------------------------------------
+// position = target + adjusted;
+// fixedDistDistance = adjusted.length();
+// fixedDistVOffset = position.y - target.y;
+ // XXX --------------------------------------------------
+// const float s = smoothMoveSpeed * (1.0f/40f);
+// const Vec3 newPosition = target + adjusted;
+// position = interpolate (s, position, newPosition);
+// fixedDistDistance = interpolate (s, fixedDistDistance, adjusted.length());
+// fixedDistVOffset = interpolate (s, fixedDistVOffset, position.y - target.y);
+ // XXX --------------------------------------------------
+// position = target + adjusted;
+ setPosition (target + adjusted);
+ fixedDistDistance = adjusted.length();
+// fixedDistVOffset = position.y - target.y;
+ fixedDistVOffset = position().y - target.y;
+ // XXX --------------------------------------------------
+ break;
+ }
+ case cmStraightDown:
+ {
+ const Vec3 offset (0, 0, lookdownDistance);
+ const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
+ lookdownDistance = adjusted.z;
+ break;
+ }
+ case cmFixedLocalOffset:
+ {
+ const Vec3 offset = v.globalizeDirection (fixedLocalOffset);
+ const Vec3 adjusted = mouseAdjustPolar (adjustment, offset);
+ fixedLocalOffset = v.localizeDirection (adjusted);
+ break;
+ }
+ case cmOffsetPOV:
+ {
+ // XXX this might work better as a translation control, it is
+ // XXX non-obvious using a polar adjustment when the view
+ // XXX center is not at the camera aim target
+ const Vec3 offset = v.globalizeDirection (povOffset);
+ const Vec3 adjusted = mouseAdjustOrtho (adjustment, offset);
+ povOffset = v.localizeDirection (adjusted);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+
+
+OpenSteer::Vec3
+OpenSteer::Camera::mouseAdjust2 (const bool polar,
+ const Vec3& adjustment,
+ const Vec3& offsetToAdjust)
+{
+ // value to be returned
+ Vec3 result = offsetToAdjust;
+
+ // using the camera's side/up axes (essentially: screen space) move the
+ // offset vector sideways according to adjustment.x and vertically
+ // according to adjustment.y, constrain the offset vector's length to
+ // stay the same, hence the offset's "tip" stays on the surface of a
+ // sphere.
+ const float oldLength = result.length ();
+ const float rate = polar ? oldLength : 1;
+ result += xxxls().side() * (adjustment.x * rate);
+ result += xxxls().up() * (adjustment.y * rate);
+ if (polar)
+ {
+ const float newLength = result.length ();
+ result *= oldLength / newLength;
+ }
+
+ // change the length of the offset vector according to adjustment.z
+ if (polar)
+ result *= (1 + adjustment.z);
+ else
+ result += xxxls().forward() * adjustment.z;
+
+ return result;
+}
+
+
+// ----------------------------------------------------------------------------
Added: trunk/python-ogre/ThirdParty/opensteer/Camera.h
===================================================================
--- trunk/python-ogre/ThirdParty/opensteer/Camera.h (rev 0)
+++ trunk/python-ogre/ThirdParty/opensteer/Camera.h 2008-10-30 03:21:08 UTC (rev 782)
@@ -0,0 +1,184 @@
+// ----------------------------------------------------------------------------
+//
+//
+// OpenSteer -- Steering Behaviors for Autonomous Characters
+//
+// Copyright (c) 2002-2005, Sony Computer Entertainment America
+// Original author: Craig Reynolds <cra...@pl...>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of thi...
[truncated message content] |