Skip to content

Commit 0d0107d

Browse files
committed
unify(view): Merge View and closely related code (#1904)
1 parent a857461 commit 0d0107d

File tree

12 files changed

+544
-198
lines changed

12 files changed

+544
-198
lines changed

Generals/Code/GameEngine/Include/Common/DrawModule.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
3939
class Matrix3D;
4040
class RenderCost;
41+
class OBBoxClass;
4142

4243
// TYPES //////////////////////////////////////////////////////////////////////////////////////////
4344

@@ -154,6 +155,10 @@ class ObjectDrawInterface
154155

155156
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
156157
virtual Bool clientOnly_getRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform) const = 0;
158+
159+
// (gth) C&C3 adding these accessors to render object properties
160+
virtual Bool clientOnly_getRenderObjBoundBox(OBBoxClass * boundbox) const = 0;
161+
virtual Bool clientOnly_getRenderObjBoneTransform(const AsciiString & boneName,Matrix3D * set_tm) const = 0;
157162
/**
158163
Find the bone(s) with the given name and return their positions and/or transforms in the given arrays.
159164
We look for a bone named "boneNamePrefixQQ", where QQ is 01, 02, 03, etc, starting at the

Generals/Code/GameEngine/Include/GameClient/CommandXlat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum FilterTypes CPP_11(: Int)
7676
FT_VIEW_BW_FILTER, //filter to apply a black & white filter to the screen.
7777
FT_VIEW_MOTION_BLUR_FILTER, //filter to apply motion blur filter to screen.
7878
FT_VIEW_CROSSFADE, ///<filter to apply a cross blend between previous/current views.
79+
FT_VIEW_DEFAULT, ///<default filter mode for default filter.
7980
FT_MAX
8081
};
8182

@@ -101,7 +102,7 @@ enum FilterModes CPP_11(: Int)
101102
FM_VIEW_MB_OUT_SATURATE, // Motion blur filter out saturated blur
102103
FM_VIEW_MB_END_PAN_ALPHA, // Moton blur on screen pan (for camera tracks object mode)
103104

104-
105+
FM_VIEW_DEFAULT, //Default filter that's enabled when all others are off.
105106

106107
// NOTE: This has to be the last entry in this enum.
107108
// Add new entries before this one. jba.

Generals/Code/GameEngine/Include/GameClient/Display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class Display : public SubsystemInterface
173173
virtual void toggleLetterBox(void) = 0; ///< enabled letter-boxed display
174174
virtual void enableLetterBox(Bool enable) = 0; ///< forces letter-boxed display on/off
175175
virtual Bool isLetterBoxFading( void ) { return FALSE; } ///< returns true while letterbox fades in/out
176+
virtual Bool isLetterBoxed( void ) { return FALSE; } //WST 10/2/2002. Added query interface
176177

177178
virtual void setCinematicText( AsciiString string ) { m_cinematicText = string; }
178179
virtual void setCinematicFont( GameFont *font ) { m_cinematicFont = font; }

Generals/Code/GameEngine/Include/GameClient/View.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,23 @@ class View : public Snapshot
135135
virtual void initHeightForMap( void ) {}; ///< Init the camera height for the map at the current position.
136136
virtual void scrollBy( Coord2D *delta ); ///< Shift the view by the given delta
137137

138-
virtual void moveCameraTo(const Coord3D *o, Int frames, Int shutter, Bool orient) { lookAt( o ); }
139-
virtual void moveCameraAlongWaypointPath(Waypoint *way, Int frames, Int shutter, Bool orient) { }
138+
virtual void moveCameraTo(const Coord3D *o, Int frames, Int shutter, Bool orient, Real easeIn=0.0f, Real easeOut=0.0f) { lookAt( o ); }
139+
virtual void moveCameraAlongWaypointPath(Waypoint *way, Int frames, Int shutter, Bool orient, Real easeIn=0.0f, Real easeOut=0.0f) { }
140140
virtual Bool isCameraMovementFinished( void ) { return TRUE; }
141-
virtual void cameraModFinalZoom(Real finalZoom){}; ///< Final zoom for current camera movement.
141+
virtual void cameraModFinalZoom(Real finalZoom, Real easeIn=0.0f, Real easeOut=0.0f){}; ///< Final zoom for current camera movement.
142142
virtual void cameraModRollingAverage(Int framesToAverage){}; ///< Number of frames to average movement for current camera movement.
143143
virtual void cameraModFinalTimeMultiplier(Int finalMultiplier){}; ///< Final time multiplier for current camera movement.
144-
virtual void cameraModFinalPitch(Real finalPitch){}; ///< Final pitch for current camera movement.
144+
virtual void cameraModFinalPitch(Real finalPitch, Real easeIn=0.0f, Real easeOut=0.0f){}; ///< Final pitch for current camera movement.
145145
virtual void cameraModFreezeTime(void){ } ///< Freezes time during the next camera movement.
146146
virtual void cameraModFreezeAngle(void){ } ///< Freezes time during the next camera movement.
147147
virtual void cameraModLookToward(Coord3D *pLoc){} ///< Sets a look at point during camera movement.
148148
virtual void cameraModFinalLookToward(Coord3D *pLoc){} ///< Sets a look at point during camera movement.
149149
virtual void cameraModFinalMoveTo(Coord3D *pLoc){ }; ///< Sets a final move to.
150150

151+
// (gth) C&C3 animation controled camera feature
152+
virtual void cameraEnableSlaveMode(const AsciiString & thingtemplateName, const AsciiString & boneName) {}
153+
virtual void cameraDisableSlaveMode(void) {}
154+
virtual void Add_Camera_Shake(const Coord3D & position,float radius, float duration, float power) {}
151155
virtual FilterModes getViewFilterMode(void) {return (FilterModes)0;} ///< Turns on viewport special effect (black & white mode)
152156
virtual FilterTypes getViewFilterType(void) {return (FilterTypes)0;} ///< Turns on viewport special effect (black & white mode)
153157
virtual Bool setViewFilterMode(FilterModes filterMode) { return FALSE; } ///< Turns on viewport special effect (black & white mode)
@@ -157,16 +161,16 @@ class View : public Snapshot
157161
virtual void setFadeParameters(Int fadeFrames, Int direction) { };
158162
virtual void set3DWireFrameMode(Bool enable) { };
159163

160-
virtual void resetCamera(const Coord3D *location, Int frames) {}; ///< Move camera to location, and reset to default angle & zoom.
161-
virtual void rotateCamera(Real rotations, Int frames) {}; ///< Rotate camera about current viewpoint.
162-
virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds) {}; ///< Rotate camera to face an object, and hold on it
163-
virtual void rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds) {}; ///< Rotate camera to face a location.
164+
virtual void resetCamera(const Coord3D *location, Int frames, Real easeIn=0.0f, Real easeOut=0.0f) {}; ///< Move camera to location, and reset to default angle & zoom.
165+
virtual void rotateCamera(Real rotations, Int frames, Real easeIn=0.0f, Real easeOut=0.0f) {}; ///< Rotate camera about current viewpoint.
166+
virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds, Real easeIn=0.0f, Real easeOut=0.0f) {}; ///< Rotate camera to face an object, and hold on it
167+
virtual void rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f, Bool reverseRotation=FALSE) {}; ///< Rotate camera to face a location.
164168
virtual Bool isTimeFrozen(void){ return false;} ///< Freezes time during the next camera movement.
165169
virtual Int getTimeMultiplier(void) {return 1;}; ///< Get the time multiplier.
166170
virtual void setTimeMultiplier(Int multiple) {}; ///< Set the time multiplier.
167171
virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) {};
168-
virtual void zoomCamera( Real finalZoom, Int milliseconds ) {};
169-
virtual void pitchCamera( Real finalPitch, Int milliseconds ) {};
172+
virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {};
173+
virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {};
170174

171175
virtual void setAngle( Real angle ); ///< Rotate the view around the up axis to the given angle
172176
virtual Real getAngle( void ) { return m_angle; }

Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ class W3DModelDraw : public DrawModule, public ObjectDrawInterface
363363

364364
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
365365
virtual Bool clientOnly_getRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform) const;
366+
virtual Bool clientOnly_getRenderObjBoundBox(OBBoxClass * boundbox) const;
367+
virtual Bool clientOnly_getRenderObjBoneTransform(const AsciiString & boneName,Matrix3D * set_tm) const;
366368
virtual Int getPristineBonePositionsForConditionState(const ModelConditionFlags& condition, const char* boneNamePrefix, Int startIndex, Coord3D* positions, Matrix3D* transforms, Int maxBones) const;
367369
virtual Int getCurrentBonePositions(const char* boneNamePrefix, Int startIndex, Coord3D* positions, Matrix3D* transforms, Int maxBones) const;
368370
virtual Bool getCurrentWorldspaceClientBonePositions(const char* boneName, Matrix3D& transform) const;

Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class W3DDisplay : public Display
127127
virtual void enableLetterBox(Bool enable); ///<forces letter-boxed display on/off
128128

129129
virtual Bool isLetterBoxFading(void); ///<returns true while letterbox fades in/out
130+
virtual Bool isLetterBoxed(void);
130131

131132
virtual void clearShroud();
132133
virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting);

Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
4040
#include "Common/STLTypedefs.h"
41+
#include "GameClient/ParabolicEase.h"
4142
#include "GameClient/View.h"
4243
#include "WW3D2/camera.h"
4344

@@ -55,8 +56,6 @@ typedef struct
5556
Coord3D waypoints[MAX_WAYPOINTS+2]; // We pad first & last for interpolation.
5657
Real waySegLength[MAX_WAYPOINTS+2]; // Length of each segment;
5758
Real cameraAngle[MAX_WAYPOINTS+2]; // Camera Angle;
58-
Real cameraFXPitch[MAX_WAYPOINTS+2]; // Camera Pitch;
59-
Real cameraZoom[MAX_WAYPOINTS+2]; // Camera Zoom;
6059
Int timeMultiplier[MAX_WAYPOINTS+2]; // Time speedup factor.
6160
Real groundHeight[MAX_WAYPOINTS+1]; // Ground height.
6261
Real totalTimeMilliseconds; // Num of ms to do this movement.
@@ -67,6 +66,7 @@ typedef struct
6766
Int curSegment; // The current segment.
6867
Int curShutter; // The current shutter.
6968
Int rollingAverageFrames; // Number of frames to roll.
69+
ParabolicEase ease; // Ease in/out function.
7070
} TMoveAlongWaypointPathInfo;
7171

7272
// ------------------------------------------------------------------------------------------------
@@ -75,17 +75,23 @@ typedef struct
7575
{
7676
Int numFrames; ///< Number of frames to rotate.
7777
Int curFrame; ///< Current frame.
78-
Real angle;
79-
Real startZoom;
80-
Real endZoom;
81-
Real startPitch;
82-
Real endPitch;
8378
Int startTimeMultiplier;
8479
Int endTimeMultiplier;
85-
ObjectID targetObjectID; ///< Target if we are tracking an object instead of just rotating
86-
Coord3D targetObjectPos; ///< Target's position (so we can stay looking at that spot if he dies)
87-
Bool trackObject; ///< Are we tracking an object or just rotating?
8880
Int numHoldFrames; ///< Number of frames to hold the camera before finishing the movement
81+
ParabolicEase ease;
82+
Bool trackObject; ///< Are we tracking an object or just rotating?
83+
struct Target {
84+
ObjectID targetObjectID; ///< Target if we are tracking an object instead of just rotating
85+
Coord3D targetObjectPos; ///< Target's position (so we can stay looking at that spot if he dies)
86+
};
87+
struct Angle {
88+
Real startAngle;
89+
Real endAngle;
90+
};
91+
union {
92+
Target target;
93+
Angle angle;
94+
};
8995
} TRotateCameraInfo;
9096

9197
// ------------------------------------------------------------------------------------------------
@@ -99,6 +105,7 @@ typedef struct
99105
Real endPitch;
100106
Int startTimeMultiplier;
101107
Int endTimeMultiplier;
108+
ParabolicEase ease;
102109
} TPitchCameraInfo;
103110

104111
// ------------------------------------------------------------------------------------------------
@@ -111,6 +118,7 @@ typedef struct
111118
Real endZoom;
112119
Int startTimeMultiplier;
113120
Int endTimeMultiplier;
121+
ParabolicEase ease;
114122
} TZoomCameraInfo;
115123

116124
// ------------------------------------------------------------------------------------------------
@@ -155,28 +163,36 @@ class W3DView : public View, public SubsystemInterface
155163

156164
virtual void lookAt( const Coord3D *o ); ///< Center the view on the given coordinate
157165
virtual void initHeightForMap( void ); ///< Init the camera height for the map at the current position.
158-
virtual void moveCameraTo(const Coord3D *o, Int miliseconds, Int shutter, Bool orient);
159-
virtual void moveCameraAlongWaypointPath(Waypoint *pWay, Int frames, Int shutter, Bool orient);
166+
virtual void moveCameraTo(const Coord3D *o, Int miliseconds, Int shutter, Bool orient, Real easeIn, Real easeOut);
167+
virtual void moveCameraAlongWaypointPath(Waypoint *pWay, Int frames, Int shutter, Bool orient, Real easeIn, Real easeOut);
160168
virtual Bool isCameraMovementFinished(void);
161-
virtual void resetCamera(const Coord3D *location, Int frames); ///< Move camera to location, and reset to default angle & zoom.
162-
virtual void rotateCamera(Real rotations, Int frames); ///< Rotate camera about current viewpoint.
163-
virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds); ///< Rotate camera to face an object, and hold on it
164-
virtual void rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds); ///< Rotate camera to face a location.
169+
virtual Bool isCameraMovementAtWaypointAlongPath(void);
170+
virtual void resetCamera(const Coord3D *location, Int frames, Real easeIn, Real easeOut); ///< Move camera to location, and reset to default angle & zoom.
171+
virtual void rotateCamera(Real rotations, Int frames, Real easeIn, Real easeOut); ///< Rotate camera about current viewpoint.
172+
virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds, Real easeIn, Real easeOut); ///< Rotate camera to face an object, and hold on it
173+
virtual void rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds, Real easeIn, Real easeOut, Bool reverseRotation); ///< Rotate camera to face a location.
165174
virtual void cameraModFreezeTime(void){ m_freezeTimeForCameraMovement = true;} ///< Freezes time during the next camera movement.
166175
virtual void cameraModFreezeAngle(void); ///< Freezes time during the next camera movement.
167176
virtual Bool isTimeFrozen(void){ return m_freezeTimeForCameraMovement;} ///< Freezes time during the next camera movement.
168-
virtual void cameraModFinalZoom(Real finalZoom); ///< Final zoom for current camera movement.
177+
virtual void cameraModFinalZoom(Real finalZoom, Real easeIn, Real easeOut); ///< Final zoom for current camera movement.
169178
virtual void cameraModRollingAverage(Int framesToAverage); ///< Number of frames to average movement for current camera movement.
170179
virtual void cameraModFinalTimeMultiplier(Int finalMultiplier); ///< Final time multiplier for current camera movement.
171-
virtual void cameraModFinalPitch(Real finalPitch); ///< Final pitch for current camera movement.
180+
virtual void cameraModFinalPitch(Real finalPitch, Real easeIn, Real easeOut); ///< Final pitch for current camera movement.
172181
virtual void cameraModLookToward(Coord3D *pLoc); ///< Sets a look at point during camera movement.
173182
virtual void cameraModFinalLookToward(Coord3D *pLoc); ///< Sets a look at point during camera movement.
174183
virtual void cameraModFinalMoveTo(Coord3D *pLoc); ///< Sets a final move to.
184+
// (gth) C&C3 animation controlled camera feature
185+
virtual void cameraEnableSlaveMode(const AsciiString & thingtemplateName, const AsciiString & boneName);
186+
virtual void cameraDisableSlaveMode(void);
187+
virtual void cameraEnableRealZoomMode(void); //WST 10.18.2002
188+
virtual void cameraDisableRealZoomMode(void);
189+
190+
virtual void Add_Camera_Shake(const Coord3D & position,float radius, float duration, float power); //WST 10.18.2002
175191
virtual Int getTimeMultiplier(void) {return m_timeMultiplier;};///< Get the time multiplier.
176192
virtual void setTimeMultiplier(Int multiple) {m_timeMultiplier = multiple;}; ///< Set the time multiplier.
177193
virtual void setDefaultView(Real pitch, Real angle, Real maxHeight);
178-
virtual void zoomCamera( Real finalZoom, Int milliseconds );
179-
virtual void pitchCamera( Real finalPitch, Int milliseconds );
194+
virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn, Real easeOut );
195+
virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn, Real easeOut );
180196

181197
virtual void setHeightAboveGround(Real z);
182198
virtual void setZoom(Real z);
@@ -229,7 +245,7 @@ class W3DView : public View, public SubsystemInterface
229245
Real m_shakeAngleCos; ///< the cosine of the orientation of the oscillation
230246
Real m_shakeAngleSin; ///< the sine of the orientation of the oscillation
231247
Real m_shakeIntensity; ///< the intensity of the oscillation
232-
248+
Vector3 m_shakerAngles; //WST 11/12/2002 new multiple instance camera shaker system
233249

234250
TRotateCameraInfo m_rcInfo;
235251
Bool m_doingRotateCamera; ///< True if we are doing a camera rotate.
@@ -244,7 +260,8 @@ class W3DView : public View, public SubsystemInterface
244260
Real m_FXPitch; ///< Camera effects pitch. 0 = flat, infinite = look down, 1 = normal.
245261

246262
TMoveAlongWaypointPathInfo m_mcwpInfo; ///< Move camera along waypoint path info.
247-
Bool m_doingMoveCameraOnWaypointPath; ///< If true, moving camera along waypoint path.
263+
Bool m_doingMoveCameraOnWaypointPath; ///< If true, moving camera along waypoint path.
264+
Bool m_CameraArrivedAtWaypointOnPathFlag;
248265

249266
Bool m_freezeTimeForCameraMovement;
250267
Int m_timeMultiplier; ///< Time speedup multiplier.
@@ -274,6 +291,11 @@ class W3DView : public View, public SubsystemInterface
274291
void getAxisAlignedViewRegion(Region3D &axisAlignedRegion); ///< Find 3D Region enclosing all possible drawables.
275292
void calcDeltaScroll(Coord2D &screenDelta);
276293

294+
// (gth) C&C3 animation controlled camera feature
295+
Bool m_isCameraSlaved;
296+
Bool m_useRealZoomCam;
297+
AsciiString m_cameraSlaveObjectName;
298+
AsciiString m_cameraSlaveObjectBoneName;
277299
};
278300

279301
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,48 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState(
34583458
return posCount;
34593459
}
34603460

3461+
3462+
//-------------------------------------------------------------------------------------------------
3463+
// (gth) C&C3 Added this accessor for the bounding box of a render object in a W3DModelDraw module
3464+
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
3465+
Bool W3DModelDraw::clientOnly_getRenderObjBoundBox(OBBoxClass * boundbox) const
3466+
{
3467+
if (!m_renderObject)
3468+
return false;
3469+
3470+
AABoxClass aabox;
3471+
m_renderObject->Get_Obj_Space_Bounding_Box(aabox);
3472+
3473+
Matrix3D tm = m_renderObject->Get_Transform();
3474+
3475+
// build an OBB for this AAB,transform
3476+
OBBoxClass box0(aabox.Center,aabox.Extent);
3477+
OBBoxClass::Transform(tm,box0,boundbox);
3478+
3479+
return true;
3480+
}
3481+
3482+
3483+
//-------------------------------------------------------------------------------------------------
3484+
// (gth) C&C3 Added this accessor for a bone transform in the render object
3485+
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
3486+
Bool W3DModelDraw::clientOnly_getRenderObjBoneTransform(const AsciiString & boneName,Matrix3D * set_tm) const
3487+
{
3488+
if (!m_renderObject) {
3489+
return false;
3490+
}
3491+
3492+
int idx = m_renderObject->Get_Bone_Index(boneName.str());
3493+
if (idx == 0) {
3494+
set_tm->Make_Identity();
3495+
return false;
3496+
} else {
3497+
*set_tm = m_renderObject->Get_Bone_Transform(idx);
3498+
return true;
3499+
}
3500+
}
3501+
3502+
34613503
//-------------------------------------------------------------------------------------------------
34623504
Bool W3DModelDraw::getCurrentWorldspaceClientBonePositions(const char* boneName, Matrix3D& transform) const
34633505
{

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,12 @@ Bool W3DDisplay::isLetterBoxFading(void)
19401940
return FALSE;
19411941
}
19421942

1943+
//WST 10/2/2002 added query function. JSC Integrated 5/20/03
1944+
Bool W3DDisplay::isLetterBoxed(void)
1945+
{
1946+
return (m_letterBoxEnabled);
1947+
}
1948+
19431949
// W3DDisplay::createLightPulse ===============================================
19441950
/** Create a "light pulse" which is a dynamic light that grows, decays
19451951
* and vanishes over several frames */

0 commit comments

Comments
 (0)