2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 ////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/shock/shkcmobj.cpp,v 1.3 1999/05/30 20:30:57 JON Exp $
26 // Include these absolutely last
30 DEFINE_LG_GUID(IID_ICameraObjects
, 0x243);
33 public cCTDelegating
<ICameraObjects
>,
34 public cCTAggregateMemberControl
<kCTU_Default
>
37 cCameraObjects(IUnknown
* pOuter
)
39 MI_INIT_AGGREGATION_1(pOuter
, ICameraObjects
, kPriorityNormal
, NULL
);
42 STDMETHOD(Frame
)(tSimTime deltaTime
);
45 void UpdatePosition(ObjID objID
);
48 ////////////////////////////////////////
50 void cCameraObjects::UpdatePosition(ObjID objID
)
52 cCameraObj
*pCameraObj
;
60 g_CameraObjProperty
->Get(objID
, &pCameraObj
);
61 Assert_(pCameraObj
!= NULL
);
63 // Get base location/facing
64 CameraGetLocation(PlayerCamera(), &camPos
, &camFacing
);
65 // turn player facing into matrix
66 mx_ang2mat(&m1
, &camFacing
);
69 mx_mat_mul_vec(&offset
, &m1
, &pCameraObj
->m_offset
);
70 mx_add_vec(&loc
, &camPos
, &offset
);
72 if ((!pCameraObj
->m_lockang
[1]) && (pCameraObj
->m_lockang
[2]))
75 mx_rot_z_mat(&m2
, &m1
, -camFacing
.tz
+pCameraObj
->m_angle
.tz
);
76 mx_mat2ang(&facing
, &m2
);
80 facing
.tx
= pCameraObj
->m_angle
.tx
;
81 if (!pCameraObj
->m_lockang
[0])
82 facing
.tx
+= camFacing
.tx
;
84 facing
.ty
= pCameraObj
->m_angle
.ty
;
85 if (!pCameraObj
->m_lockang
[1])
86 facing
.ty
+= camFacing
.ty
;
88 facing
.tz
= pCameraObj
->m_angle
.tz
;
89 if (!pCameraObj
->m_lockang
[2])
90 facing
.tz
+= camFacing
.tz
;
94 // update actual obj pos
95 ObjPosUpdate(objID
, &loc
, &facing
);
98 ////////////////////////////////////////
100 STDMETHODIMP
cCameraObjects::Frame(tSimTime timeDelta
)
102 sPropertyObjIter iter
;
105 g_CameraObjProperty
->IterStart(&iter
);
106 while (g_CameraObjProperty
->IterNext(&iter
, &objID
))
107 UpdatePosition(objID
);
108 g_CameraObjProperty
->IterStop(&iter
);
112 ////////////////////////////////////////
114 void ShockCameraObjectsCreate(void)
116 AutoAppIPtr(Unknown
);
117 new cCameraObjects(pUnknown
);