mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-28 08:39:34 +00:00
Baseline working openvr code
This commit is contained in:
parent
e239d106f5
commit
ba91478fad
23 changed files with 1463 additions and 457 deletions
|
|
@ -393,44 +393,6 @@ void Camera::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId, Mat
|
|||
}
|
||||
}
|
||||
|
||||
DisplayPose Camera::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
|
||||
{
|
||||
// NOTE: this is intended to be similar to updateMove
|
||||
DisplayPose outPose;
|
||||
outPose.orientation = EulerF(0,0,0);
|
||||
outPose.position = inPose.position;
|
||||
|
||||
// Pitch
|
||||
outPose.orientation.x = (inPose.orientation.x - mLastAbsolutePitch);
|
||||
|
||||
// Constrain the range of mRot.x
|
||||
while (outPose.orientation.x < -M_PI_F)
|
||||
outPose.orientation.x += M_2PI_F;
|
||||
while (outPose.orientation.x > M_PI_F)
|
||||
outPose.orientation.x -= M_2PI_F;
|
||||
|
||||
// Yaw
|
||||
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
|
||||
|
||||
// Constrain the range of mRot.z
|
||||
while (outPose.orientation.z < -M_PI_F)
|
||||
outPose.orientation.z += M_2PI_F;
|
||||
while (outPose.orientation.z > M_PI_F)
|
||||
outPose.orientation.z -= M_2PI_F;
|
||||
|
||||
// Bank
|
||||
if (mDataBlock->cameraCanBank)
|
||||
{
|
||||
outPose.orientation.y = (inPose.orientation.y - mLastAbsoluteRoll);
|
||||
}
|
||||
|
||||
// Constrain the range of mRot.y
|
||||
while (outPose.orientation.y > M_PI_F)
|
||||
outPose.orientation.y -= M_2PI_F;
|
||||
|
||||
return outPose;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
F32 Camera::getCameraFov()
|
||||
|
|
|
|||
|
|
@ -237,7 +237,6 @@ class Camera: public ShapeBase
|
|||
virtual void interpolateTick( F32 delta);
|
||||
virtual void getCameraTransform( F32* pos,MatrixF* mat );
|
||||
virtual void getEyeCameraTransform( IDisplayDevice *display, U32 eyeId, MatrixF *outMat );
|
||||
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
|
||||
|
||||
virtual void writePacketData( GameConnection* conn, BitStream* stream );
|
||||
virtual void readPacketData( GameConnection* conn, BitStream* stream );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "T3D/gameBase/extended/extendedMove.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "math/mathIO.h"
|
||||
#include "math/mAngAxis.h"
|
||||
#include "core/module.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/strings/stringFunctions.h"
|
||||
|
|
@ -268,7 +269,7 @@ void ExtendedMove::clamp()
|
|||
crotX[i] = CLAMPROT(rotX[i]);
|
||||
crotY[i] = CLAMPROT(rotY[i]);
|
||||
crotZ[i] = CLAMPROT(rotZ[i]);
|
||||
crotW[i] = CLAMPROT(rotW[i]);
|
||||
crotW[i] = CLAMPROT(rotW[i] / M_2PI_F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +294,7 @@ void ExtendedMove::unclamp()
|
|||
rotX[i] = UNCLAMPROT(crotX[i]);
|
||||
rotY[i] = UNCLAMPROT(crotY[i]);
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]) * M_2PI_F;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ bool ExtendedMoveList::getNextExtMove( ExtendedMove &curMove )
|
|||
else
|
||||
{
|
||||
//Rotation is passed in as an Angle Axis in degrees. We need to convert this into a Quat.
|
||||
QuatF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
|
||||
curMove.rotX[i] = q.x;
|
||||
curMove.rotY[i] = q.y;
|
||||
curMove.rotZ[i] = q.z;
|
||||
curMove.rotW[i] = q.w;
|
||||
AngAxisF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
|
||||
curMove.rotX[i] = q.axis.x;
|
||||
curMove.rotY[i] = q.axis.y;
|
||||
curMove.rotZ[i] = q.axis.z;
|
||||
curMove.rotW[i] = q.angle;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ bool GameProcessCameraQuery(CameraQuery *query)
|
|||
query->eyeOffset[1] = Point3F::Zero;
|
||||
query->hasFovPort = false;
|
||||
query->hasStereoTargets = false;
|
||||
query->displayDevice = NULL;
|
||||
|
||||
F32 cameraFov = 0.0f;
|
||||
bool fovSet = false;
|
||||
|
|
@ -364,6 +365,9 @@ bool GameProcessCameraQuery(CameraQuery *query)
|
|||
if(!gEditingMission && connection->hasDisplayDevice())
|
||||
{
|
||||
IDisplayDevice* display = connection->getDisplayDevice();
|
||||
|
||||
query->displayDevice = display;
|
||||
|
||||
// Note: all eye values are invalid until this is called
|
||||
display->setDrawCanvas(query->drawCanvas);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
#include "T3D/decal/decalManager.h"
|
||||
#include "T3D/decal/decalData.h"
|
||||
#include "materials/baseMatInstance.h"
|
||||
#include "math/mathUtils.h"
|
||||
|
||||
#ifdef TORQUE_EXTENDED_MOVE
|
||||
#include "T3D/gameBase/extended/extendedMove.h"
|
||||
|
|
@ -2489,6 +2490,8 @@ void Player::allowAllPoses()
|
|||
mAllowSwimming = true;
|
||||
}
|
||||
|
||||
AngAxisF gPlayerMoveRot;
|
||||
|
||||
void Player::updateMove(const Move* move)
|
||||
{
|
||||
delta.move = *move;
|
||||
|
|
@ -2531,6 +2534,7 @@ void Player::updateMove(const Move* move)
|
|||
delta.headVec = mHead;
|
||||
|
||||
bool doStandardMove = true;
|
||||
bool absoluteDelta = false;
|
||||
GameConnection* con = getControllingClient();
|
||||
|
||||
#ifdef TORQUE_EXTENDED_MOVE
|
||||
|
|
@ -2618,6 +2622,27 @@ void Player::updateMove(const Move* move)
|
|||
while (mHead.y > M_PI_F)
|
||||
mHead.y -= M_2PI_F;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Orient the player so we are looking towards the required position, ignoring any banking
|
||||
AngAxisF moveRot(Point3F(emove->rotX[emoveIndex], emove->rotY[emoveIndex], emove->rotZ[emoveIndex]), emove->rotW[emoveIndex]);
|
||||
MatrixF trans(1);
|
||||
moveRot.setMatrix(&trans);
|
||||
|
||||
Point3F vecForward(0, 1, 0);
|
||||
Point3F orient;
|
||||
EulerF rot;
|
||||
trans.mulV(vecForward);
|
||||
|
||||
F32 yawAng;
|
||||
F32 pitchAng;
|
||||
MathUtils::getAnglesFromVector(vecForward, yawAng, pitchAng);
|
||||
mRot.z = yawAng;
|
||||
mHead = EulerF(0);
|
||||
mHead.x = -pitchAng;
|
||||
|
||||
absoluteDelta = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2666,6 +2691,13 @@ void Player::updateMove(const Move* move)
|
|||
|
||||
delta.head = mHead;
|
||||
delta.headVec -= mHead;
|
||||
|
||||
if (absoluteDelta)
|
||||
{
|
||||
delta.headVec = Point3F(0, 0, 0);
|
||||
delta.rotVec = Point3F(0, 0, 0);
|
||||
}
|
||||
|
||||
for(U32 i=0; i<3; ++i)
|
||||
{
|
||||
if (delta.headVec[i] > M_PI_F)
|
||||
|
|
@ -5589,58 +5621,6 @@ void Player::getMuzzleTransform(U32 imageSlot,MatrixF* mat)
|
|||
*mat = nmat;
|
||||
}
|
||||
|
||||
DisplayPose Player::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
|
||||
{
|
||||
// NOTE: this is intended to be similar to updateMove
|
||||
DisplayPose outPose;
|
||||
outPose.orientation = getRenderTransform().toEuler();
|
||||
outPose.position = inPose.position;
|
||||
|
||||
if (con && con->getControlSchemeAbsoluteRotation())
|
||||
{
|
||||
// Pitch
|
||||
outPose.orientation.x = (inPose.orientation.x - mLastAbsolutePitch);
|
||||
|
||||
// Constrain the range of mRot.x
|
||||
while (outPose.orientation.x < -M_PI_F)
|
||||
outPose.orientation.x += M_2PI_F;
|
||||
while (outPose.orientation.x > M_PI_F)
|
||||
outPose.orientation.x -= M_2PI_F;
|
||||
|
||||
// Yaw
|
||||
|
||||
// Rotate (heading) head or body?
|
||||
if ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson()))
|
||||
{
|
||||
// Rotate head
|
||||
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rotate body
|
||||
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
|
||||
}
|
||||
|
||||
// Constrain the range of mRot.z
|
||||
while (outPose.orientation.z < 0.0f)
|
||||
outPose.orientation.z += M_2PI_F;
|
||||
while (outPose.orientation.z > M_2PI_F)
|
||||
outPose.orientation.z -= M_2PI_F;
|
||||
|
||||
// Bank
|
||||
if (mDataBlock->cameraCanBank)
|
||||
{
|
||||
outPose.orientation.y = (inPose.orientation.y - mLastAbsoluteRoll);
|
||||
}
|
||||
|
||||
// Constrain the range of mRot.y
|
||||
while (outPose.orientation.y > M_PI_F)
|
||||
outPose.orientation.y -= M_2PI_F;
|
||||
}
|
||||
|
||||
return outPose;
|
||||
}
|
||||
|
||||
void Player::getRenderMuzzleTransform(U32 imageSlot,MatrixF* mat)
|
||||
{
|
||||
disableHeadZCalc();
|
||||
|
|
|
|||
|
|
@ -686,7 +686,6 @@ public:
|
|||
void getEyeBaseTransform(MatrixF* mat, bool includeBank);
|
||||
void getRenderEyeTransform(MatrixF* mat);
|
||||
void getRenderEyeBaseTransform(MatrixF* mat, bool includeBank);
|
||||
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
|
||||
void getCameraParameters(F32 *min, F32 *max, Point3F *offset, MatrixF *rot);
|
||||
void getMuzzleTransform(U32 imageSlot,MatrixF* mat);
|
||||
void getRenderMuzzleTransform(U32 imageSlot,MatrixF* mat);
|
||||
|
|
|
|||
|
|
@ -1992,9 +1992,8 @@ void ShapeBase::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId,
|
|||
Point3F eyePos;
|
||||
Point3F rotEyePos;
|
||||
|
||||
DisplayPose inPose;
|
||||
displayDevice->getFrameEyePose(&inPose, eyeId);
|
||||
DisplayPose newPose = calcCameraDeltaPose(displayDevice->getCurrentConnection(), inPose);
|
||||
DisplayPose newPose;
|
||||
displayDevice->getFrameEyePose(&newPose, eyeId);
|
||||
|
||||
// Ok, basically we just need to add on newPose to the camera transform
|
||||
// NOTE: currently we dont support third-person camera in this mode
|
||||
|
|
@ -2004,57 +2003,15 @@ void ShapeBase::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId,
|
|||
|
||||
QuatF baserot = cameraTransform;
|
||||
QuatF qrot = QuatF(newPose.orientation);
|
||||
QuatF concatRot;
|
||||
concatRot.mul(baserot, qrot);
|
||||
concatRot.setMatrix(&temp);
|
||||
temp.setPosition(cameraTransform.getPosition() + concatRot.mulP(newPose.position, &rotEyePos));
|
||||
//QuatF concatRot;
|
||||
//concatRot.mul(baserot, qrot);
|
||||
qrot.setMatrix(&temp);
|
||||
|
||||
temp.setPosition(cameraTransform.getPosition() + qrot.mulP(newPose.position, &rotEyePos));
|
||||
|
||||
*outMat = temp;
|
||||
}
|
||||
|
||||
DisplayPose ShapeBase::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
|
||||
{
|
||||
// NOTE: this is intended to be similar to updateMove
|
||||
// WARNING: does not take into account any move values
|
||||
|
||||
DisplayPose outPose;
|
||||
outPose.orientation = getRenderTransform().toEuler();
|
||||
outPose.position = inPose.position;
|
||||
|
||||
if (con && con->getControlSchemeAbsoluteRotation())
|
||||
{
|
||||
// Pitch
|
||||
outPose.orientation.x = inPose.orientation.x;
|
||||
|
||||
// Constrain the range of mRot.x
|
||||
while (outPose.orientation.x < -M_PI_F)
|
||||
outPose.orientation.x += M_2PI_F;
|
||||
while (outPose.orientation.x > M_PI_F)
|
||||
outPose.orientation.x -= M_2PI_F;
|
||||
|
||||
// Yaw
|
||||
outPose.orientation.z = inPose.orientation.z;
|
||||
|
||||
// Constrain the range of mRot.z
|
||||
while (outPose.orientation.z < -M_PI_F)
|
||||
outPose.orientation.z += M_2PI_F;
|
||||
while (outPose.orientation.z > M_PI_F)
|
||||
outPose.orientation.z -= M_2PI_F;
|
||||
|
||||
// Bank
|
||||
if (mDataBlock->cameraCanBank)
|
||||
{
|
||||
outPose.orientation.y = inPose.orientation.y;
|
||||
}
|
||||
|
||||
// Constrain the range of mRot.y
|
||||
while (outPose.orientation.y > M_PI_F)
|
||||
outPose.orientation.y -= M_2PI_F;
|
||||
}
|
||||
|
||||
return outPose;
|
||||
}
|
||||
|
||||
void ShapeBase::getCameraParameters(F32 *min,F32* max,Point3F* off,MatrixF* rot)
|
||||
{
|
||||
*min = mDataBlock->cameraMinDist;
|
||||
|
|
|
|||
|
|
@ -1588,9 +1588,6 @@ public:
|
|||
/// orient and position values of the display device.
|
||||
virtual void getEyeCameraTransform( IDisplayDevice *display, U32 eyeId, MatrixF *outMat );
|
||||
|
||||
/// Calculates a delta camera angle and view position based on inPose
|
||||
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
|
||||
|
||||
/// Gets the index of a node inside a mounted image given the name
|
||||
/// @param imageSlot Image slot
|
||||
/// @param nodeName Node name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue