ProfileViewer: Fixed char* vs wchar_t*.
Quaternion: Removed operator- since it doesn't seem geometrically sensible for rotation-quaternions. Added ToAxisAngle but don't actually use it anywhere. GameView: Changed unit-view to look slightly more correct. This was SVN commit r3201.
This commit is contained in:
parent
300ff4578b
commit
a5d1968a8c
@ -353,15 +353,16 @@ void CGameView::Update(float DeltaTime)
|
||||
|
||||
if (m_UnitView)
|
||||
{
|
||||
CQuaternion ToRotate = m_UnitViewProp->m_Rotation - m_Camera.m_Orientation.GetRotation();
|
||||
ToRotate.m_V.Y += m_UnitView->m_orientation;
|
||||
m_Camera.m_Orientation.Rotate(ToRotate);
|
||||
CVector3D CamTrans = m_Camera.m_Orientation.GetTranslation();
|
||||
CVector3D ToMove = m_UnitView->m_position + m_UnitViewProp->m_Position - CamTrans;
|
||||
//Used to fix incorrect positioning
|
||||
//ToMove.Y += 3.5f;
|
||||
m_Camera.m_Orientation.Translate(ToMove);
|
||||
|
||||
// CQuaternion ToRotate = m_UnitViewProp->m_Rotation - m_Camera.m_Orientation.GetRotation();
|
||||
// ToRotate.m_V.Y += m_UnitView->m_orientation;
|
||||
// m_Camera.m_Orientation.Rotate(ToRotate);
|
||||
// CVector3D CamTrans = m_Camera.m_Orientation.GetTranslation();
|
||||
// CVector3D ToMove = m_UnitView->m_position + m_UnitViewProp->m_Position - CamTrans;
|
||||
// //Used to fix incorrect positioning
|
||||
// //ToMove.Y += 3.5f;
|
||||
// m_Camera.m_Orientation.Translate(ToMove);
|
||||
m_Camera.m_Orientation.SetYRotation(m_UnitView->m_orientation);
|
||||
m_Camera.m_Orientation.Translate(m_UnitViewProp->GetTransform().GetTranslation());
|
||||
|
||||
/*if( !m_UnitView->m_orderQueue.empty())
|
||||
{
|
||||
@ -644,7 +645,7 @@ void CGameView::Update(float DeltaTime)
|
||||
m_Camera.UpdateFrustum ();
|
||||
}
|
||||
|
||||
void CGameView::ToUnitView(CEntity* target, SPropPoint* prop)
|
||||
void CGameView::ToUnitView(CEntity* target, CModel* prop)
|
||||
{
|
||||
if( !target )
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ class CTerrain;
|
||||
class CUnitManager;
|
||||
class CProjectileManager;
|
||||
class CModel;
|
||||
class CEntity;
|
||||
|
||||
class CGameView: public CJSObject<CGameView>
|
||||
{
|
||||
@ -51,7 +52,7 @@ class CGameView: public CJSObject<CGameView>
|
||||
CVector3D m_CameraPivot;
|
||||
|
||||
CEntity* m_UnitView;
|
||||
SPropPoint* m_UnitViewProp;
|
||||
CModel* m_UnitViewProp;
|
||||
CEntity* m_UnitAttach;
|
||||
//float m_CameraZoom;
|
||||
std::vector<CVector3D> m_CameraTargets;
|
||||
@ -120,7 +121,7 @@ public:
|
||||
void PopCameraTarget();
|
||||
|
||||
//First person camera attachment (through the eyes of the unit)
|
||||
void ToUnitView(CEntity* target, SPropPoint* prop);
|
||||
void ToUnitView(CEntity* target, CModel* prop);
|
||||
//Keep view the same but follow the unit
|
||||
void AttachToUnit(CEntity* target) { m_UnitAttach = target; }
|
||||
|
||||
|
@ -35,15 +35,7 @@ CQuaternion CQuaternion::operator + (const CQuaternion &quat) const
|
||||
|
||||
return Temp;
|
||||
}
|
||||
CQuaternion CQuaternion::operator - (const CQuaternion &quat) const
|
||||
{
|
||||
CQuaternion Temp;
|
||||
|
||||
Temp.m_W = m_W - quat.m_W;
|
||||
Temp.m_V = m_V - quat.m_V;
|
||||
|
||||
return Temp;
|
||||
}
|
||||
//quaternion addition/assignment
|
||||
CQuaternion &CQuaternion::operator += (const CQuaternion &quat)
|
||||
{
|
||||
@ -190,9 +182,9 @@ void CQuaternion::Slerp(const CQuaternion& from,const CQuaternion& to, float rat
|
||||
scale1 = sinf(ratio * omega) / sinom;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// "from" and "to" quaternions are very close
|
||||
// ... so we can do a linear interpolation
|
||||
// ... so we can do a linear interpolation
|
||||
scale0 = 1.0f - ratio;
|
||||
scale1 = ratio;
|
||||
}
|
||||
@ -206,15 +198,29 @@ void CQuaternion::Slerp(const CQuaternion& from,const CQuaternion& to, float rat
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FromAxisAngle: create a quaternion from axis/angle representation of a rotation
|
||||
void CQuaternion::FromAxisAngle(const CVector3D& axis,float angle)
|
||||
void CQuaternion::FromAxisAngle(const CVector3D& axis, float angle)
|
||||
{
|
||||
float sinHalfTheta=(float) sin(angle/2);
|
||||
float cosHalfTheta=(float) cos(angle/2);
|
||||
float sinHalfTheta=(float) sin(angle/2);
|
||||
float cosHalfTheta=(float) cos(angle/2);
|
||||
|
||||
m_V.X=axis.X*sinHalfTheta;
|
||||
m_V.Y=axis.Y*sinHalfTheta;
|
||||
m_V.Z=axis.Z*sinHalfTheta;
|
||||
m_W=cosHalfTheta;
|
||||
m_V.X=axis.X*sinHalfTheta;
|
||||
m_V.Y=axis.Y*sinHalfTheta;
|
||||
m_V.Z=axis.Z*sinHalfTheta;
|
||||
m_W=cosHalfTheta;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ToAxisAngle: convert the quaternion to axis/angle representation of a rotation
|
||||
void CQuaternion::ToAxisAngle(CVector3D& axis, float& angle)
|
||||
{
|
||||
CQuaternion q = *this;
|
||||
q.Normalize();
|
||||
angle = acosf(q.m_W) * 2.f;
|
||||
float sin_a = sqrtf(1.f - q.m_W * q.m_W);
|
||||
if (fabsf(sin_a) < 0.0005f) sin_a = 1.f;
|
||||
axis.X = q.m_V.X / sin_a;
|
||||
axis.Y = q.m_V.Y / sin_a;
|
||||
axis.Z = q.m_V.Z / sin_a;
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +230,7 @@ void CQuaternion::Normalize()
|
||||
{
|
||||
float lensqrd=SQR(m_V.X)+SQR(m_V.Y)+SQR(m_V.Z)+SQR(m_W);
|
||||
if (lensqrd>0) {
|
||||
float invlen=1.0f/float(sqrt(lensqrd));
|
||||
float invlen=1.0f/sqrtf(lensqrd);
|
||||
m_V*=invlen;
|
||||
m_W*=invlen;
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ public:
|
||||
|
||||
//quaternion addition
|
||||
CQuaternion operator + (const CQuaternion &quat) const;
|
||||
CQuaternion operator - (const CQuaternion &quat) const;
|
||||
//quaternion addition/assignment
|
||||
CQuaternion &operator += (const CQuaternion &quat);
|
||||
|
||||
|
||||
//quaternion multiplication
|
||||
CQuaternion operator * (const CQuaternion &quat) const;
|
||||
@ -41,10 +39,13 @@ public:
|
||||
void ToMatrix(CMatrix3D& result) const;
|
||||
|
||||
//sphere interpolation
|
||||
void Slerp(const CQuaternion& from,const CQuaternion& to, float ratio);
|
||||
void Slerp(const CQuaternion& from, const CQuaternion& to, float ratio);
|
||||
|
||||
// create a quaternion from axis/angle representation of a rotation
|
||||
void FromAxisAngle(const CVector3D& axis,float angle);
|
||||
void FromAxisAngle(const CVector3D& axis, float angle);
|
||||
|
||||
// convert the quaternion to axis/angle representation of a rotation
|
||||
void ToAxisAngle(CVector3D& axis, float& angle);
|
||||
|
||||
// normalize this quaternion
|
||||
void Normalize();
|
||||
|
@ -871,8 +871,8 @@ InReaction interactInputHandler( const SDL_Event* ev )
|
||||
if( g_Selection.m_selected.size() )
|
||||
pView->SetCameraTarget( g_Selection.getSelectionPosition() );
|
||||
break;
|
||||
|
||||
case HOTKEY_CAMERA_UNIT_VIEW:
|
||||
|
||||
case HOTKEY_CAMERA_UNIT_VIEW:
|
||||
{
|
||||
if ( pView->IsAttached() )
|
||||
break; //Should only exit unit view through unit view hotkey
|
||||
@ -884,20 +884,20 @@ InReaction interactInputHandler( const SDL_Event* ev )
|
||||
}
|
||||
if ( g_Selection.m_selected.empty() )
|
||||
break;
|
||||
|
||||
|
||||
std::vector<CModel::Prop>& Props = g_Selection.m_selected.front()->m_actor->GetModel()->GetProps();
|
||||
|
||||
for (unsigned int x=0; x<Props.size(); x++)
|
||||
{
|
||||
for (size_t x=0; x<Props.size(); x++)
|
||||
{
|
||||
if( Props[x].m_Point->m_Name == "head" )
|
||||
{
|
||||
pView->ToUnitView( g_Selection.m_selected.front(), Props[x].m_Point);
|
||||
pView->ToUnitView( g_Selection.m_selected.front(), Props[x].m_Model);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HOTKEY_CAMERA_UNIT_ATTACH:
|
||||
case HOTKEY_CAMERA_UNIT_ATTACH:
|
||||
{
|
||||
if ( pView->IsUnitView() )
|
||||
break; //Should only exit unit view through unit view hotkey
|
||||
@ -910,9 +910,10 @@ InReaction interactInputHandler( const SDL_Event* ev )
|
||||
if ( g_Selection.m_selected.empty() )
|
||||
break;
|
||||
|
||||
pView->AttachToUnit( g_Selection.m_selected.front() );
|
||||
pView->AttachToUnit( g_Selection.m_selected.front() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
if( ( ev->user.code >= HOTKEY_SELECTION_GROUP_0 ) && ( ev->user.code <= HOTKEY_SELECTION_GROUP_19 ) )
|
||||
{
|
||||
@ -943,7 +944,7 @@ InReaction interactInputHandler( const SDL_Event* ev )
|
||||
}
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
|
||||
|
||||
return( IN_PASS );
|
||||
}
|
||||
return( IN_HANDLED );
|
||||
|
@ -56,13 +56,13 @@ AbstractProfileTable::~AbstractProfileTable()
|
||||
// AbstractProfileTable got deleted, make sure we have no dangling pointers
|
||||
void CProfileViewerInternals::TableIsDeleted(AbstractProfileTable* table)
|
||||
{
|
||||
for(int idx = rootTables.size()-1; idx >= 0; --idx)
|
||||
for(int idx = (int)rootTables.size()-1; idx >= 0; --idx)
|
||||
{
|
||||
if (rootTables[idx] == table)
|
||||
rootTables.erase(rootTables.begin() + idx);
|
||||
}
|
||||
|
||||
for(int idx = 0; (uint)idx < path.size(); ++idx)
|
||||
for(size_t idx = 0; idx < path.size(); ++idx)
|
||||
{
|
||||
if (path[idx] != table)
|
||||
continue;
|
||||
@ -164,7 +164,7 @@ void CProfileViewer::RenderProfile()
|
||||
glColor3ub(255, 255, 255);
|
||||
|
||||
glPushMatrix();
|
||||
glwprintf(L"%s", table->GetTitle().c_str());
|
||||
glwprintf(L"%hs", table->GetTitle().c_str());
|
||||
glPopMatrix();
|
||||
glTranslatef( 20.0f, 20.0f, 0.0f );
|
||||
|
||||
@ -172,7 +172,7 @@ void CProfileViewer::RenderProfile()
|
||||
for(uint col = 0; col < columns.size(); ++col)
|
||||
{
|
||||
glPushMatrix();
|
||||
glwprintf(L"%s", columns[col].title.c_str());
|
||||
glwprintf(L"%hs", columns[col].title.c_str());
|
||||
glPopMatrix();
|
||||
glTranslatef(columns[col].width, 0, 0);
|
||||
}
|
||||
@ -203,7 +203,7 @@ void CProfileViewer::RenderProfile()
|
||||
for(uint col = 0; col < columns.size(); ++col)
|
||||
{
|
||||
glPushMatrix();
|
||||
glwprintf(L"%s", table->GetCellText(row, col).c_str());
|
||||
glwprintf(L"%hs", table->GetCellText(row, col).c_str());
|
||||
glPopMatrix();
|
||||
glTranslatef(columns[col].width, 0, 0);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ CEventAttack::CEventAttack( CEntity* target ) : CScriptEvent( L"attack", EVENT_A
|
||||
}
|
||||
CEventHeal::CEventHeal( CEntity* target ) : CScriptEvent( L"heal", EVENT_HEAL, true)
|
||||
{
|
||||
m_target=target;
|
||||
m_target = target;
|
||||
AddLocalProperty( L"target", &m_target );
|
||||
}
|
||||
CEventGather::CEventGather( CEntity* target ) : CScriptEvent( L"gather", EVENT_GATHER, true )
|
||||
|
Loading…
Reference in New Issue
Block a user