|
From: <axl...@us...> - 2009-05-31 00:54:23
|
Revision: 282
http://hgengine.svn.sourceforge.net/hgengine/?rev=282&view=rev
Author: axlecrusher
Date: 2009-05-31 00:54:15 +0000 (Sun, 31 May 2009)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Mercury2/src/Camera.h
Mercury2/src/Viewport.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 00:53:17 UTC (rev 281)
+++ Mercury2/src/Camera.cpp 2009-05-31 00:54:15 UTC (rev 282)
@@ -8,6 +8,8 @@
:TransformNode()
{
REGISTER_FOR_MESSAGE( INPUTEVENT_MOUSE );
+
+ REGISTER_FOR_MESSAGE( INPUTEVENT_KEYBOARD );
}
void CameraNode::ComputeMatrix()
@@ -16,8 +18,10 @@
MercuryMatrix local;
-// local.RotateXYZ( m_rotation*-1 );
-// m_rotation.
+ m_lookAt = m_rotation * MQuaternion(0,0,0,1) * m_rotation.reciprocal();
+// m_lookAt.
+ m_lookAt.ToVertex().Print();
+
AngleMatrix( m_rotation.ToVertex()*-1, local);
local.Translate( m_position*-1 );
@@ -30,25 +34,56 @@
{
MouseInput* m = (MouseInput*)data;
+// MercuryVertex r;
+// MQuaternion rot, d(0,0,1,0);
+
MQuaternion r = m_rotation;
r[0] += m->dy/30.0f;
r[1] += m->dx/30.0f;
+// r = r.normalize();
+// r = r * m_lookAt * r.reciprocal();
+// r = r.normalize();
+// r += m_rotation;
+
+// r.ToVertex().Print();
+// r += m_rotation;
+// r[3] = 1;
+// rot.SetEuler( r );
SetRotation(r);
}
+ if (message == INPUTEVENT_KEYBOARD)
+ {
+ MQuaternion r = m_rotation;
+
+ KeyboardInput* k = (KeyboardInput*)data;
+ switch(k->key)
+ {
+ case 25:
+ r[0] += 1*k->isDown;
+ break;
+ case 39:
+ r[0] -= 1*k->isDown;
+ break;
+ }
+ SetRotation(r);
+ }
}
void CameraNode::Update(float dTime)
{
- MercuryVector p = GetPosition();
-
+ MercuryVector p;// = GetPosition();
+/*
if ( KeyboardInput::IsKeyDown(25) ) p[2] -= dTime*2;
if ( KeyboardInput::IsKeyDown(38) ) p[0] -= dTime*2;
if ( KeyboardInput::IsKeyDown(39) ) p[2] += dTime*2;
if ( KeyboardInput::IsKeyDown(40) ) p[0] += dTime*2;
+
+ p *= m_lookAt.ToVertex();
+ p += GetPosition();
+ SetPosition( p );
+ */
- SetPosition( p );
-
TransformNode::Update( dTime );
}
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2009-05-31 00:53:17 UTC (rev 281)
+++ Mercury2/src/Camera.h 2009-05-31 00:54:15 UTC (rev 282)
@@ -2,6 +2,7 @@
#define CAMERA_H
#include <TransformNode.h>
+#include <MQuaternion.h>
class CameraNode : public TransformNode
{
@@ -13,6 +14,7 @@
GENRTTI(CameraNode);
private:
+ MQuaternion m_lookAt;
};
#endif
Modified: Mercury2/src/Viewport.cpp
===================================================================
--- Mercury2/src/Viewport.cpp 2009-05-31 00:53:17 UTC (rev 281)
+++ Mercury2/src/Viewport.cpp 2009-05-31 00:54:15 UTC (rev 282)
@@ -30,8 +30,8 @@
glMatrixMode(GL_MODELVIEW);
//compute the position of the eye
- EYE = MercuryVertex(0,0,0,1);
- EYE = matrix * EYE;
+// EYE = MercuryVertex(0,0,0,1); //wrong
+// EYE = matrix * EYE;
VIEWMATRIX = matrix;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|