|
From: <cn...@us...> - 2010-04-08 03:48:50
|
Revision: 689
http://hgengine.svn.sourceforge.net/hgengine/?rev=689&view=rev
Author: cnlohr
Date: 2010-04-08 03:48:44 +0000 (Thu, 08 Apr 2010)
Log Message:
-----------
whoops forgot this stuff
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Added Paths:
-----------
Mercury2/src/MercuryTransform.cpp
Mercury2/src/MercuryTransform.h
Mercury2/src/MercuryTween.cpp
Mercury2/src/MercuryTween.h
Mercury2/src/VariableRegister.h
Added: Mercury2/src/MercuryTransform.cpp
===================================================================
--- Mercury2/src/MercuryTransform.cpp (rev 0)
+++ Mercury2/src/MercuryTransform.cpp 2010-04-08 03:48:44 UTC (rev 689)
@@ -0,0 +1,57 @@
+#include <MercuryTransform.h>
+
+MercuryTransform::MercuryTransform() : m_bDirty( true )
+{
+ Scale[0] = Scale[1] = Scale[2] = 1;
+}
+
+void MercuryTransform::SetTween( const MercuryTransform & left, const MercuryTransform & right, float fPercent )
+{
+ Position = left.Position * (1-fPercent) + right.Position * fPercent;
+ Scale = left.Scale * (1-fPercent) + right.Scale * fPercent;
+ Rotation = SLERP( left.Rotation, right.Rotation, fPercent );
+ Dirty();
+}
+
+MercuryMatrix & MercuryTransform::GetMatrix()
+{
+ if( m_bDirty )
+ {
+ m_Matrix = MercuryMatrix::Identity();
+ m_Matrix.Translate( Position[0], Position[1], Position[2] );
+ m_Matrix.Rotate( Rotation );
+ m_Matrix.Scale( Scale[0], Scale[1], Scale[2] );
+ m_bDirty = 0;
+ }
+ return m_Matrix;
+}
+
+
+/*
+ * Copyright (c) 2010 Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
Added: Mercury2/src/MercuryTransform.h
===================================================================
--- Mercury2/src/MercuryTransform.h (rev 0)
+++ Mercury2/src/MercuryTransform.h 2010-04-08 03:48:44 UTC (rev 689)
@@ -0,0 +1,60 @@
+#ifndef _MERCURYTRANSFORM_H
+#define _MERCURYTRANSFORM_H
+
+#include <MercuryMatrix.h>
+
+class MercuryTransform
+{
+public:
+ MercuryTransform();
+
+ void SetTween( const MercuryTransform & left, const MercuryTransform & right, float fPercent );
+
+ MercuryMatrix & GetMatrix();
+ inline void Dirty() { m_bDirty = true; }
+ inline bool IsDirty() { return m_bDirty; }
+ MQuaternion Rotation;
+ MercuryVertex Position;
+ MercuryVertex Scale;
+private:
+ MercuryMatrix m_Matrix;
+ bool m_bDirty;
+};
+
+inline void SetTween( MercuryTransform & ActOn, const MercuryTransform & left, const MercuryTransform & right, float fPercent )
+{
+ ActOn.SetTween( left, right, fPercent );
+}
+
+
+#endif
+
+
+/*
+ * Copyright (c) 2010 Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
Added: Mercury2/src/MercuryTween.cpp
===================================================================
--- Mercury2/src/MercuryTween.cpp (rev 0)
+++ Mercury2/src/MercuryTween.cpp 2010-04-08 03:48:44 UTC (rev 689)
@@ -0,0 +1,33 @@
+#include <MercuryTween.h>
+
+//This file is just to make sure MercuryTween compiles OK.
+
+
+/*
+ * Copyright (c) 2010 Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
Added: Mercury2/src/MercuryTween.h
===================================================================
--- Mercury2/src/MercuryTween.h (rev 0)
+++ Mercury2/src/MercuryTween.h 2010-04-08 03:48:44 UTC (rev 689)
@@ -0,0 +1,125 @@
+#ifndef _MERCURYTWEEN_H
+#define _MERCURYTWEEN_H
+
+#include <deque>
+#include "MercuryUtil.h"
+
+typedef float (*TweenFunction)( float, float );
+
+template< typename T >
+class MercuryTweenState
+{
+public:
+ T Target;
+
+ TweenFunction Function;
+ float FunctionP;
+
+ float Time;
+};
+
+template< typename T >
+class MercuryTween
+{
+public:
+ MercuryTween() : Current( 0 ), m_fInOnThisTween( 0 ){ }
+ T * Current;
+
+ void Attach( T * val )
+ {
+ Current = val;
+ m_Last = *Current;
+ }
+
+ void Update( float fDelta )
+ {
+ if( !Current || !m_FutureTweens.size() )
+ return;
+
+ //The following few lines are incredibly convoluted. I do not suggest trying to figure it out.
+ m_fInOnThisTween += fDelta;
+
+ while( m_FutureTweens.size() && m_fInOnThisTween > m_FutureTweens.front().Time )
+ {
+ m_Last = *Current;
+ *Current = m_FutureTweens.front().Target;
+ m_fInOnThisTween -= m_FutureTweens.front().Time;
+ m_FutureTweens.pop_front();
+ }
+
+ if( !m_FutureTweens.size() )
+ {
+ m_fInOnThisTween = 0;
+ m_Last = *Current;
+ return;
+ }
+
+ MercuryTweenState<T> & ts = m_FutureTweens.front();
+
+ SetTween( *Current, m_Last, ts.Target, ts.Function( m_fInOnThisTween/ts.Time, ts.FunctionP ) );
+ }
+
+ void Finish()
+ {
+ Current = m_FutureTweens.back().Target;
+ m_FutureTweens.clear();
+ m_fInOnThisTween = 0;
+ }
+
+ void Stop()
+ {
+ m_FutureTweens.clear();
+ m_fInOnThisTween = 0;
+ }
+
+ void AddTween( MercuryTweenState< T > s )
+ {
+ m_FutureTweens.push_back( s );
+ }
+
+ void AddTween( MString & sTweenSet )
+ {
+ MVector < MString > out;
+ SplitStrings( sTweenSet, out, ";\n", " \t", 2, 2 );
+// for( unsigned i = 0
+ }
+
+private:
+ float m_fInOnThisTween;
+ T m_Last;
+ std::deque< MercuryTweenState< T > > m_FutureTweens;
+};
+
+
+
+#endif
+
+
+/*
+ * Copyright (c) 2010 Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2010-04-05 06:12:33 UTC (rev 688)
+++ Mercury2/src/MercuryVBO.cpp 2010-04-08 03:48:44 UTC (rev 689)
@@ -10,7 +10,7 @@
extern bool SHOWAXISES;
MercuryVBO::MercuryVBO( const MString & key, bool bInstanced, bool useVertexColor )
- :MercuryAsset( key, bInstanced ), m_initiated(false), m_useVertexColor(useVertexColor)
+ :MercuryAsset( key, bInstanced ), m_initiated(false), m_useVertexColor(useVertexColor), m_iIndexCountOverride( -1 )
{
m_bufferIDs[0] = m_bufferIDs[1] = m_bufferIDs[2] = 0;
m_bDirtyIndices = m_bDirtyVertices = m_bDirtyVertexColor = false;
@@ -59,7 +59,11 @@
GLCALL( glEnableClientState( GL_NORMAL_ARRAY ) );
GLCALL( glNormalPointer(GL_FLOAT, STRIDE*sizeof(float), BUFFER_OFFSET(sizeof(float)*2)) );
- GLCALL( glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
+ unsigned long iElemsToDraw = (m_iIndexCountOverride!=-1)?m_iIndexCountOverride:(m_indexData.Length()-1);
+//printf( "%d (%d,%d)\n", iElemsToDraw,m_iIndexCountOverride,m_indexData.Length()-1 );
+ GLCALL( glDrawRangeElements( GL_TRIANGLES, 0, iElemsToDraw,
+ iElemsToDraw+1, GL_UNSIGNED_SHORT, NULL) );
+
IncrementBatches();
if (m_boundingVolume && SHOWBOUNDINGVOLUME) m_boundingVolume->Render();
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2010-04-05 06:12:33 UTC (rev 688)
+++ Mercury2/src/MercuryVBO.h 2010-04-08 03:48:44 UTC (rev 689)
@@ -45,12 +45,15 @@
inline static const void* GetLastRendered() { return m_lastVBOrendered; }
inline static void IncrementBatches() { ++m_vboBatches; }
+ inline void SetIndexCountOverride( int iCount ) { m_iIndexCountOverride = iCount; }
GENRTTI( MercuryVBO );
protected:
virtual bool CheckForNewer() { return false; }
virtual void Reload() {};
private:
+
+ unsigned long m_iIndexCountOverride;
virtual void InitVBO();
static void* m_lastVBOrendered;
Added: Mercury2/src/VariableRegister.h
===================================================================
--- Mercury2/src/VariableRegister.h (rev 0)
+++ Mercury2/src/VariableRegister.h 2010-04-08 03:48:44 UTC (rev 689)
@@ -0,0 +1,74 @@
+#ifndef _VARIABLE_REGISTER_H
+#define _VARIABLE_REGISTER_H
+
+class VariableReceiver
+{
+public:
+ void VariableDelegate( const MString & sChangedVariable, const MString & sChangedValue );
+};
+
+typedef void (VariableReceiver::*VariableDelegate)( const MString & sChangedVariable, const MString & sChangedValue );
+
+///Variable Register
+/**This is a tool that can be used by programmers and the like to control global variables.
+ It is quite useful in situations where you want to be able to change variables without
+ use of code, and be able to catch changes. */
+class VariablesRegister
+{
+public:
+ void RegisterListener( const MString & sVariable, VariableDelegate d );
+ const MString & GetVariable( const MString & var ) { MString * s = m_mVariables->Get( var ); return s?*s:""; }
+ static MercuryMessageManager& GetInstance();
+private:
+ MHash< MString > m_mVariables;
+
+ struct Sender
+ {
+ VariableDelegate * d;
+
+ };
+ MHash< VariableDelegate > m_mDelegates;
+ MHash<
+};
+
+
+
+static InstanceCounter<VariablesRegister> MMcounter("VariablesRegister");
+
+#define VARIABLES VariablesRegister::GetInstance()
+
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2008 by Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|