-
Notifications
You must be signed in to change notification settings - Fork 1
/
kicker.h
179 lines (150 loc) · 6.57 KB
/
kicker.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
// Kicker.h: Definition of the Kicker class
//
//////////////////////////////////////////////////////////////////////
#pragma once
#if !defined(AFX_KICKER_H__3A9F3FC4_605A_43AD_A430_830279CFE059__INCLUDED_)
#define AFX_KICKER_H__3A9F3FC4_605A_43AD_A430_830279CFE059__INCLUDED_
#include "resource.h" // main symbols
class KickerData
{
public:
Vertex2D m_vCenter;
float m_radius;
char m_szMaterial[32];
TimerDataRoot m_tdr;
char m_szSurface[MAXTOKEN];
KickerType m_kickertype;
float m_scatter;
float m_hitAccuracy; //kicker hit grabbing object height ... default ballsize*0.7
float m_orientation;
float m_hit_height;
bool m_fEnabled;
bool m_fFallThrough;
bool m_legacyMode;
};
class KickerHitCircle;
/////////////////////////////////////////////////////////////////////////////
// Kicker
class Kicker :
public IDispatchImpl<IKicker, &IID_IKicker, &LIBID_VPinballLib>,
//public ISupportErrorInfo,
public CComObjectRoot,
public CComCoClass<Kicker, &CLSID_Kicker>,
public EventProxy<Kicker, &DIID_IKickerEvents>,
public IConnectionPointContainerImpl<Kicker>,
public IProvideClassInfo2Impl<&CLSID_Kicker, &DIID_IKickerEvents, &LIBID_VPinballLib>,
public ISelect,
public IEditable,
public Hitable,
public IScriptable,
public IFireEvents,
public IPerPropertyBrowsing // Ability to fill in dropdown in property browser
{
public:
Kicker();
virtual ~Kicker();
BEGIN_COM_MAP(Kicker)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IKicker)
//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(Kicker)
// Remove the comment from the line above if you don't want your object to
// support aggregation.
BEGIN_CONNECTION_POINT_MAP(Kicker)
CONNECTION_POINT_ENTRY(DIID_IKickerEvents)
END_CONNECTION_POINT_MAP()
STANDARD_EDITABLE_DECLARES(Kicker, eItemKicker, KICKER, 1)
DECLARE_REGISTRY_RESOURCEID(IDR_KICKER)
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
virtual void GetDialogPanes(vector<PropertyPane*> &pvproppane);
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);
virtual void PreRenderStatic(RenderDevice* pd3dDevice);
virtual void SetDefaultPhysics(bool fromMouseClick);
virtual void ExportMesh(FILE *f);
virtual unsigned long long GetMaterialID() const { return m_ptable->GetMaterial(m_d.m_szMaterial)->hash(); }
virtual ItemTypeEnum HitableGetItemType() const { return eItemKicker; }
virtual void WriteRegDefaults();
void GenerateMesh(Vertex3D_NoTex2 *const buf);
void UpdateUnitsInfo();
KickerData m_d;
std::vector<Vertex3Ds> hitMesh;
private:
PinTable * m_ptable;
KickerHitCircle *m_phitkickercircle;
VertexBuffer *vertexBuffer;
IndexBuffer *indexBuffer;
unsigned int m_numVertices;
unsigned int m_numIndices;
Texture texture;
float m_baseHeight;
VertexBuffer *plateVertexBuffer;
IndexBuffer *plateIndexBuffer;
public:
// IKicker
STDMETHOD(get_Material)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Material)(/*[in]*/ BSTR newVal);
STDMETHOD(get_DrawStyle)(/*[out, retval]*/ KickerType *pVal);
STDMETHOD(put_DrawStyle)(/*[in]*/ KickerType newVal);
STDMETHOD(get_Enabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Enabled)(/*[in]*/ VARIANT_BOOL 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(Kick)(float angle, float speed, float inclination);
STDMETHOD(KickZ)(float angle, float speed, float inclination, float heightz);
STDMETHOD(KickXYZ)(float angle, float speed, float inclination, float x, float y, float z);
//STDMETHOD(DestroyBall)();
STDMETHOD(DestroyBall)(/*[out, retval]*/ int *pVal);
STDMETHOD(CreateBall)(IBall **pBallEx);
STDMETHOD(CreateSizedBall)(/*[in]*/float radius, /*out, retval]*/ IBall **pBallEx);
STDMETHOD(CreateSizedBallWithMass)(/*[in]*/float radius, /*[in]*/float mass, /*out, retval]*/ IBall **pBallEx);
STDMETHOD(BallCntOver)(/*[out, retval]*/ int *pVal);
STDMETHOD(get_Scatter)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Scatter)(/*[in]*/ float newVal);
STDMETHOD(get_HitAccuracy)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_HitAccuracy)(/*[in]*/ float newVal);
STDMETHOD(get_HitHeight)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_HitHeight)(/*[in]*/ float newVal);
STDMETHOD(get_Orientation)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Orientation)(/*[in]*/ float newVal);
STDMETHOD(get_Radius)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Radius)(/*[in]*/ float newVal);
STDMETHOD(get_FallThrough)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_FallThrough)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Legacy)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Legacy)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_LastCapturedBall)(/*[out, retval]*/ IBall **pVal);
};
class KickerHitCircle : public HitCircle
{
public:
KickerHitCircle(const Vertex2D& c, const float r, const float zlow, const float zhigh)
: HitCircle(c,r,zlow,zhigh)
{
m_pball = NULL;
m_lastCapturedBall = NULL;
m_pkicker = NULL;
}
virtual float HitTest(const Ball * const pball, const float dtime, CollisionEvent& coll) const;
virtual int GetType() const { return eTrigger; }
virtual void Collide(const CollisionEvent& coll) { DoCollide(coll.m_ball, coll.m_hitnormal, coll.m_hitflag, false); }
void DoChangeBallVelocity(Ball * const pball, const Vertex3Ds& hitnormal) const;
void DoCollide(Ball * const pball, const Vertex3Ds& hitnormal, const bool hitflag, const bool newBall);
Kicker *m_pkicker;
Ball *m_pball; // The ball inside this kicker
Ball *m_lastCapturedBall; // same as m_pball but this one won't be nulled only overwritten from another captured ball
};
#endif // !defined(AFX_KICKER_H__3A9F3FC4_605A_43AD_A430_830279CFE059__INCLUDED_)