mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Game cam and eye banking, control schemes
- ShapeBaseData has two new properties. cameraCanBank indicates that the game object may bank its eye/camera, if supported by the object. mountedImagesBank indicates that mounted images should bank with the eye/camera in first person view. Both default to false. - Player supports 1st person eye and 3rd person camera banking when making use of the new ExtendedMove class. - Camera class supports banking when making use of the new ExtendedMove class. - GameConnection now has an idea of a control scheme. This determines how game objects should respond to input events. A control scheme may be set by either the server or client. Current control schemes are: -- Absolute rotation (likely though the ExtendedMove class) -- Add relative yaw (from mouse or gamepad) to absolute rotation. -- Add relative pitch (from mouse or gamepad) to absolute rotation. - Player class supports the new control schemes when using the ExtendedMove class. - Camera class supports the new control scheme when using the ExtendedMove class.
This commit is contained in:
parent
2805ec81c8
commit
660250cccf
10 changed files with 570 additions and 127 deletions
|
|
@ -219,6 +219,13 @@ GameConnection::GameConnection()
|
|||
// first person
|
||||
mFirstPerson = true;
|
||||
mUpdateFirstPerson = false;
|
||||
|
||||
// Control scheme
|
||||
mUpdateControlScheme = false;
|
||||
mAbsoluteRotation = false;
|
||||
mAddYawToAbsRot = false;
|
||||
mAddPitchToAbsRot = false;
|
||||
|
||||
clearDisplayDevice();
|
||||
}
|
||||
|
||||
|
|
@ -743,7 +750,15 @@ void GameConnection::setFirstPerson(bool firstPerson)
|
|||
mUpdateFirstPerson = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void GameConnection::setControlSchemeParameters(bool absoluteRotation, bool addYawToAbsRot, bool addPitchToAbsRot)
|
||||
{
|
||||
mAbsoluteRotation = absoluteRotation;
|
||||
mAddYawToAbsRot = addYawToAbsRot;
|
||||
mAddPitchToAbsRot = addPitchToAbsRot;
|
||||
mUpdateControlScheme = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -826,6 +841,11 @@ void GameConnection::writeDemoStartBlock(ResizeBitStream *stream)
|
|||
stream->write(mCameraPos);
|
||||
stream->write(mCameraSpeed);
|
||||
|
||||
// Control scheme
|
||||
stream->write(mAbsoluteRotation);
|
||||
stream->write(mAddYawToAbsRot);
|
||||
stream->write(mAddPitchToAbsRot);
|
||||
|
||||
stream->writeString(Con::getVariable("$Client::MissionFile"));
|
||||
|
||||
mMoveList->writeDemoStartBlock(stream);
|
||||
|
|
@ -902,6 +922,11 @@ bool GameConnection::readDemoStartBlock(BitStream *stream)
|
|||
stream->read(&mCameraPos);
|
||||
stream->read(&mCameraSpeed);
|
||||
|
||||
// Control scheme
|
||||
stream->read(&mAbsoluteRotation);
|
||||
stream->read(&mAddYawToAbsRot);
|
||||
stream->read(&mAddPitchToAbsRot);
|
||||
|
||||
char buf[256];
|
||||
stream->readString(buf);
|
||||
Con::setVariable("$Client::MissionFile",buf);
|
||||
|
|
@ -1078,6 +1103,16 @@ void GameConnection::readPacket(BitStream *bstream)
|
|||
else
|
||||
setCameraObject(0);
|
||||
|
||||
// server changed control scheme
|
||||
if(bstream->readFlag())
|
||||
{
|
||||
bool absoluteRotation = bstream->readFlag();
|
||||
bool addYawToAbsRot = bstream->readFlag();
|
||||
bool addPitchToAbsRot = bstream->readFlag();
|
||||
setControlSchemeParameters(absoluteRotation, addYawToAbsRot, addPitchToAbsRot);
|
||||
mUpdateControlScheme = false;
|
||||
}
|
||||
|
||||
// server changed first person
|
||||
if(bstream->readFlag())
|
||||
{
|
||||
|
|
@ -1108,6 +1143,16 @@ void GameConnection::readPacket(BitStream *bstream)
|
|||
if (bstream->readFlag())
|
||||
mControlForceMismatch = true;
|
||||
|
||||
// client changed control scheme
|
||||
if(bstream->readFlag())
|
||||
{
|
||||
bool absoluteRotation = bstream->readFlag();
|
||||
bool addYawToAbsRot = bstream->readFlag();
|
||||
bool addPitchToAbsRot = bstream->readFlag();
|
||||
setControlSchemeParameters(absoluteRotation, addYawToAbsRot, addPitchToAbsRot);
|
||||
mUpdateControlScheme = false;
|
||||
}
|
||||
|
||||
// client changed first person
|
||||
if(bstream->readFlag())
|
||||
{
|
||||
|
|
@ -1170,6 +1215,15 @@ void GameConnection::writePacket(BitStream *bstream, PacketNotify *note)
|
|||
}
|
||||
bstream->writeFlag(forceUpdate);
|
||||
|
||||
// Control scheme changed?
|
||||
if(bstream->writeFlag(mUpdateControlScheme))
|
||||
{
|
||||
bstream->writeFlag(mAbsoluteRotation);
|
||||
bstream->writeFlag(mAddYawToAbsRot);
|
||||
bstream->writeFlag(mAddPitchToAbsRot);
|
||||
mUpdateControlScheme = false;
|
||||
}
|
||||
|
||||
// first person changed?
|
||||
if(bstream->writeFlag(mUpdateFirstPerson))
|
||||
{
|
||||
|
|
@ -1258,6 +1312,15 @@ void GameConnection::writePacket(BitStream *bstream, PacketNotify *note)
|
|||
else
|
||||
bstream->writeFlag( false );
|
||||
|
||||
// Control scheme changed?
|
||||
if(bstream->writeFlag(mUpdateControlScheme))
|
||||
{
|
||||
bstream->writeFlag(mAbsoluteRotation);
|
||||
bstream->writeFlag(mAddYawToAbsRot);
|
||||
bstream->writeFlag(mAddPitchToAbsRot);
|
||||
mUpdateControlScheme = false;
|
||||
}
|
||||
|
||||
// first person changed?
|
||||
if(bstream->writeFlag(mUpdateFirstPerson))
|
||||
{
|
||||
|
|
@ -2115,3 +2178,21 @@ DefineEngineMethod( GameConnection, setFirstPerson, void, (bool firstPerson),,
|
|||
{
|
||||
object->setFirstPerson(firstPerson);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, setControlSchemeParameters, void, (bool absoluteRotation, bool addYawToAbsRot, bool addPitchToAbsRot),,
|
||||
"@brief Set the control scheme that may be used by a connection's control object.\n\n"
|
||||
|
||||
"@param absoluteRotation Use absolute rotation values from client, likely through ExtendedMove.\n"
|
||||
"@param addYawToAbsRot Add relative yaw control to the absolute rotation calculation. Only useful when absoluteRotation is true.\n\n" )
|
||||
{
|
||||
object->setControlSchemeParameters(absoluteRotation, addYawToAbsRot, addPitchToAbsRot);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, getControlSchemeAbsoluteRotation, bool, (),,
|
||||
"@brief Get the connection's control scheme absolute rotation property.\n\n"
|
||||
|
||||
"@return True if the connection's control object should use an absolute rotation control scheme.\n\n"
|
||||
"@see GameConnection::setControlSchemeParameters()\n\n")
|
||||
{
|
||||
return object->getControlSchemeAbsoluteRotation();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue