-
Notifications
You must be signed in to change notification settings - Fork 1
/
bumper.h
218 lines (187 loc) · 7.74 KB
/
bumper.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
// Bumper.h: Definition of the Bumper class
//
//////////////////////////////////////////////////////////////////////
#pragma once
#if !defined(AFX_BUMPER_H__9A202FF0_7FAE_49BF_AA4C_C01C692E6DD9__INCLUDED_)
#define AFX_BUMPER_H__9A202FF0_7FAE_49BF_AA4C_C01C692E6DD9__INCLUDED_
#include "resource.h" // main symbols
class BumperData
{
public:
Vertex2D m_vCenter;
float m_radius;
float m_threshold; // speed at which ball needs to hit to register a hit
float m_force; // force the bumper kicks back with
float m_scatter;
float m_heightScale;
float m_orientation;
float m_ringSpeed;
float m_ringDropOffset;
U32 m_time_msec;
TimerDataRoot m_tdr;
char m_szCapMaterial[32];
char m_szBaseMaterial[32];
char m_szSkirtMaterial[32];
char m_szRingMaterial[32];
char m_szSurface[MAXTOKEN];
bool m_fCapVisible;
bool m_fBaseVisible;
bool m_fRingVisible;
bool m_fSkirtVisible;
bool m_fReflectionEnabled;
bool m_fHitEvent;
bool m_fCollidable;
};
/////////////////////////////////////////////////////////////////////////////
// Bumper
class Bumper :
//public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IBumper, &IID_IBumper, &LIBID_VPinballLib>,
//public ISupportErrorInfo,
public CComObjectRoot,
public CComCoClass<Bumper, &CLSID_Bumper>,
public EventProxy<Bumper, &DIID_IBumperEvents>,
public IConnectionPointContainerImpl<Bumper>,
public IProvideClassInfo2Impl<&CLSID_Bumper, &DIID_IBumperEvents, &LIBID_VPinballLib>,
public ISelect,
public IEditable,
public Hitable,
public IScriptable,
public IFireEvents,
public IPerPropertyBrowsing // Ability to fill in dropdown in property browser
//public EditableImpl<Bumper>
{
public:
Bumper();
~Bumper();
BEGIN_COM_MAP(Bumper)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IBumper)
//COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IPerPropertyBrowsing)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
//DECLARE_NOT_AGGREGATABLE(Bumper)
// Remove the comment from the line above if you don't want your object to
// support aggregation.
STANDARD_EDITABLE_DECLARES(Bumper, eItemBumper, BUMPER, 1)
BEGIN_CONNECTION_POINT_MAP(Bumper)
CONNECTION_POINT_ENTRY(DIID_IBumperEvents)
END_CONNECTION_POINT_MAP()
DECLARE_REGISTRY_RESOURCEID(IDR_BUMPER)
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
virtual void MoveOffset(const float dx, const float dy);
virtual void SetObjectPos();
virtual void GetDialogPanes(vector<PropertyPane*> &pvproppane);
// Multi-object manipulation
virtual Vertex2D GetCenter() const;
virtual void PutCenter(const Vertex2D& pv);
virtual void UpdatePropertyPanes();
virtual void SetDefaultPhysics(bool fromMouseClick);
virtual void ExportMesh(FILE *f);
virtual void RenderBlueprint(Sur *psur, const bool solid);
virtual unsigned long long GetMaterialID() const
{
if (!m_d.m_fBaseVisible && m_d.m_fCapVisible)
return m_ptable->GetMaterial(m_d.m_szCapMaterial)->hash();
else
return 64 - 3; //!! some constant number
}
virtual unsigned long long GetImageID() const
{
if (!m_d.m_fBaseVisible && m_d.m_fCapVisible)
return (unsigned long long)&m_capTexture; //!! meh
else
return NULL;
}
virtual ItemTypeEnum HitableGetItemType() const { return eItemBumper; }
virtual void WriteRegDefaults();
BumperData m_d;
BumperHitCircle *m_pbumperhitcircle;
private:
void RenderBase(const Material * const baseMaterial);
void RenderCap(const Material * const capMaterial);
void RenderSocket(const Material * const baseMaterial);
void UpdateRing();
void UpdateSkirt(const bool doCalculation);
void GenerateBaseMesh(Vertex3D_NoTex2 *buf);
void GenerateSocketMesh(Vertex3D_NoTex2 *buf);
void GenerateRingMesh(Vertex3D_NoTex2 *buf);
void GenerateCapMesh(Vertex3D_NoTex2 *buf);
PinTable *m_ptable;
VertexBuffer *m_baseVertexBuffer;
IndexBuffer *m_baseIndexBuffer;
VertexBuffer *m_socketVertexBuffer;
IndexBuffer *m_socketIndexBuffer;
VertexBuffer *m_ringVertexBuffer;
IndexBuffer *m_ringIndexBuffer;
VertexBuffer *m_capVertexBuffer;
IndexBuffer *m_capIndexBuffer;
Matrix3D m_fullMatrix;
Vertex3D_NoTex2 *m_ringVertices;
Texture m_ringTexture;
Texture m_skirtTexture;
Texture m_baseTexture;
Texture m_capTexture;
Material m_ringMaterial;
PropertyPane *m_propVisual;
float m_baseHeight;
float m_skirtCounter;
bool m_doSkirtAnimation;
bool m_enableSkirtAnimation;
bool m_ringDown;
bool m_ringAnimate;
// IBumper
public:
STDMETHOD(get_BaseMaterial)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_BaseMaterial)(/*[in]*/ BSTR newVal);
STDMETHOD(get_SkirtMaterial)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_SkirtMaterial)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Surface)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Surface)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Y)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Y)(/*[in]*/ float newVal);
STDMETHOD(get_X)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_X)(/*[in]*/ float newVal);
STDMETHOD(get_CapMaterial)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_CapMaterial)(/*[in]*/ BSTR newVal);
STDMETHOD(get_RingMaterial)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_RingMaterial)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Threshold)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Threshold)(/*[in]*/ float newVal);
STDMETHOD(get_Force)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Force)(/*[in]*/ float newVal);
STDMETHOD(get_HeightScale)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_HeightScale)(/*[in]*/ float newVal);
STDMETHOD(get_RingSpeed)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_RingSpeed)(/*[in]*/ float newVal);
STDMETHOD(get_Orientation)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Orientation)(/*[in]*/ float newVal);
STDMETHOD(get_RingDropOffset)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_RingDropOffset)(/*[in]*/ float newVal);
STDMETHOD(get_Radius)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Radius)(/*[in]*/ float newVal);
STDMETHOD(get_HasHitEvent)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_HasHitEvent)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Collidable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Collidable)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_CapVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_CapVisible)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_BaseVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_BaseVisible)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_RingVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_RingVisible)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_SkirtVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_SkirtVisible)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_ReflectionEnabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_ReflectionEnabled)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Scatter)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Scatter)(/*[in]*/ float newVal);
STDMETHOD(get_EnableSkirtAnimation)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_EnableSkirtAnimation)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(PlayHit)();
};
#endif // !defined(AFX_BUMPER_H__9A202FF0_7FAE_49BF_AA4C_C01C692E6DD9__INCLUDED_)