-
Notifications
You must be signed in to change notification settings - Fork 1
/
hittarget.h
232 lines (190 loc) · 8.67 KB
/
hittarget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// 3dprimitive.h: interface for the 3dprimitive class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#if !defined(AFX_HITTARGET_H__A67DE998_7D97_4E03_BE91_55BFD3A48DB6__INCLUDED_)
#define AFX_HITTARGET_H__A67DE998_7D97_4E03_BE91_55BFD3A48DB6__INCLUDED_
#include "resource.h"
#include <set>
// Indices for RotAndTra:
// RotX = 0
// RotY = 1
// RotZ = 2
// TraX = 3
// TraY = 4
// TraZ = 5
// ObjRotX = 6
// ObjRotY = 7
// ObjRotZ = 8
class HitTargetData
{
public:
Vertex3Ds m_vPosition;
Vertex3Ds m_vSize;
float m_rotZ;
char m_szImage[MAXTOKEN];
TargetType m_targetType;
char m_szMaterial[32];
char m_szPhysicsMaterial[32];
TimerDataRoot m_tdr;
float m_threshold; // speed at which ball needs to hit to register a hit
float m_elasticity;
float m_elasticityFalloff;
float m_friction;
float m_scatter;
float m_dropSpeed;
U32 m_time_msec;
int m_RaiseDelay;
float m_depthBias; // for determining depth sorting
float m_fDisableLightingTop; // was bool, now 0..1
float m_fDisableLightingBelow; // 0..1
bool m_fVisible;
bool m_fUseHitEvent;
bool m_fCollidable;
bool m_fReflectionEnabled;
bool m_legacy;
bool m_isDropped;
bool m_fOverwritePhysics;
};
class HitTarget :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IHitTarget, &IID_IHitTarget, &LIBID_VPinballLib>,
//public CComObjectRoot,
public CComCoClass<HitTarget, &CLSID_HitTarget>,
public EventProxy<HitTarget, &DIID_IHitTargetEvents>,
public IConnectionPointContainerImpl<HitTarget>,
public IProvideClassInfo2Impl<&CLSID_HitTarget, &DIID_IHitTargetEvents, &LIBID_VPinballLib>,
public ISelect,
public IEditable,
public Hitable,
public IScriptable,
public IFireEvents,
public IPerPropertyBrowsing // Ability to fill in dropdown in property browser
{
public:
static const float DROP_TARGET_LIMIT;
HitTarget();
virtual ~HitTarget();
BEGIN_COM_MAP(HitTarget)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHitTarget)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IPerPropertyBrowsing)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(HitTarget)
CONNECTION_POINT_ENTRY(DIID_IHitTargetEvents)
END_CONNECTION_POINT_MAP()
STANDARD_EDITABLE_DECLARES(HitTarget, eItemHitTarget, TARGET, 1)
DECLARE_REGISTRY_RESOURCEID(IDR_HITTARGET)
STDMETHOD(get_Material)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Material)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Visible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Visible)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_X)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_X)(/*[in]*/ float newVal);
STDMETHOD(get_Y)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Y)(/*[in]*/ float newVal);
STDMETHOD(get_Z)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Z)(/*[in]*/ float newVal);
STDMETHOD(get_ScaleX)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_ScaleX)(/*[in]*/ float newVal);
STDMETHOD(get_ScaleY)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_ScaleY)(/*[in]*/ float newVal);
STDMETHOD(get_ScaleZ)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_ScaleZ)(/*[in]*/ float newVal);
STDMETHOD(get_Orientation)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Orientation)(/*[in]*/ float newVal);
STDMETHOD(get_Image)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Image)(/*[in]*/ BSTR newVal);
STDMETHOD(get_HasHitEvent)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_HasHitEvent)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Threshold)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Threshold)(/*[in]*/ float newVal);
STDMETHOD(get_Collidable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Collidable)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Elasticity)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Elasticity)(/*[in]*/ float newVal);
STDMETHOD(get_ElasticityFalloff)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_ElasticityFalloff)(/*[in]*/ float newVal);
STDMETHOD(get_Friction)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Friction)(/*[in]*/ float newVal);
STDMETHOD(get_Scatter)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Scatter)(/*[in]*/ float newVal);
STDMETHOD(get_DepthBias)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_DepthBias)(/*[in]*/ float newVal);
STDMETHOD(get_DropSpeed)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_DropSpeed)(/*[in]*/ float newVal);
STDMETHOD(get_DisableLighting)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_DisableLighting)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_BlendDisableLighting)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_BlendDisableLighting)(/*[in]*/ float newVal);
STDMETHOD(get_BlendDisableLightingFromBelow)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_BlendDisableLightingFromBelow)(/*[in]*/ float newVal);
STDMETHOD(get_ReflectionEnabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_ReflectionEnabled)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_IsDropped)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_IsDropped)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_LegacyMode)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_LegacyMode)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_DrawStyle)(/*[out, retval]*/ TargetType *pVal);
STDMETHOD(put_DrawStyle)(/*[in]*/ TargetType newVal);
STDMETHOD(get_RaiseDelay)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_RaiseDelay)(/*[in]*/ long newVal);
STDMETHOD(get_PhysicsMaterial)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_PhysicsMaterial)(/*[in]*/ BSTR newVal);
STDMETHOD(get_OverwritePhysics)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_OverwritePhysics)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_HitThreshold)(/*[out, retval]*/ float *pVal);
virtual void MoveOffset(const float dx, const float dy);
virtual void SetObjectPos();
// Multi-object manipulation
virtual Vertex2D GetCenter() const;
virtual void PutCenter(const Vertex2D& pv);
//STDMETHOD(get_Name)(BSTR *pVal) {return E_FAIL;}
//virtual HRESULT InitVBA(BOOL fNew, int id, WCHAR *wzName);
virtual void WriteRegDefaults();
virtual void GetDialogPanes(vector<PropertyPane*> &pvproppane);
virtual bool IsTransparent() const;
virtual float GetDepth(const Vertex3Ds& viewDir) const;
virtual unsigned long long GetMaterialID() const { return m_ptable->GetMaterial(m_d.m_szMaterial)->hash(); }
virtual unsigned long long GetImageID() const { return (unsigned long long)(m_ptable->GetImage(m_d.m_szImage)); }
virtual ItemTypeEnum HitableGetItemType() const { return eItemHitTarget; }
virtual void UpdatePropertyPanes();
virtual void SetDefaultPhysics(bool fromMouseClick);
virtual void ExportMesh(FILE *f);
void GenerateMesh(std::vector<Vertex3D_NoTex2> &buf);
void TransformVertices();
void SetMeshType(const TargetType type);
static INT_PTR CALLBACK ObjImportProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
PinTable *m_ptable;
HitTargetData m_d;
const Vertex3D_NoTex2 *m_vertices; // pointer just to the existing hittargets hardcoded in arrays
const WORD *m_indices; // dto.
unsigned int m_numVertices;
unsigned int m_numIndices;
bool m_hitEvent;
private: // private member functions
void UpdateEditorView();
void UpdateAnimation();
bool BrowseFor3DMeshFile();
void RenderObject();
void UpdateTarget();
void SetupHitObject(vector<HitObject*> &pvho, HitObject * obj, const bool setHitObject = true);
void AddHitEdge(vector<HitObject*> &pvho, std::set< std::pair<unsigned, unsigned> >& addedEdges, const unsigned i, const unsigned j, const Vertex3Ds &vi, const Vertex3Ds &vj, const bool setHitObject = true);
PropertyPane *m_propVisual;
PropertyPane *m_propPosition;
PropertyPane *m_propPhysics;
std::vector<HitObject*> m_vhoCollidable; // Objects to that may be collide selectable
VertexBuffer *vertexBuffer;
IndexBuffer *indexBuffer;
// Vertices for editor display & hit shape
std::vector<Vertex3Ds> vertices;
std::vector<Vertex3D_NoTex2> transformedVertices;
U32 m_timeStamp;
float m_moveAnimationOffset;
bool m_moveAnimation;
bool m_moveDown;
};
#endif // !defined(AFX_HITTARGET_H__A67DE998_7D97_4E03_BE91_55BFD3A48DB6__INCLUDED_)