forked from julapy/ofxFlashLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathofxFlashDisplayObject.h
More file actions
189 lines (138 loc) · 4.7 KB
/
Copy pathofxFlashDisplayObject.h
File metadata and controls
189 lines (138 loc) · 4.7 KB
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
/*
* ofxFlashDisplayObject.h
* emptyExample
*
* Created by lukasz karluk on 1/11/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#pragma once
#include "ofxFlashEventDispatcher.h"
#include "ofxFlashMatrix.h"
#include "ofxFlashRectangle.h"
#define BLEND_MODE_NORMAL 0
#define BLEND_MODE_LAYER 1
#define BLEND_MODE_MULTIPLY 2
#define BLEND_MODE_SCREEN 3
#define BLEND_MODE_LIGHTEN 4
#define BLEND_MODE_DARKEN 5
#define BLEND_MODE_DIFFERENCE 6
#define BLEND_MODE_ADD 7
#define BLEND_MODE_SUBTRACT 8
#define BLEND_MODE_INVERT 9
#define BLEND_MODE_ALPHA 10
#define BLEND_MODE_ERASE 11
#define BLEND_MODE_OVERLAY 12
#define BLEND_MODE_HARDLIGHT 13
class ofxFlashStage; // Forward Declarations to prevent Cyclic Dependency.
// http://www.eventhelix.com/RealtimeMantra/HeaderFileIncludePatterns.htm
class ofxFlashDisplayObject : public ofxFlashEventDispatcher
{
public:
ofxFlashDisplayObject();
~ofxFlashDisplayObject();
friend class ofxFlashStage; // friends! http://www.cplusplus.com/doc/tutorial/inheritance/
virtual void setup () {};
virtual void update () {};
virtual void draw () {};
void drawTransformedOutline ();
void drawPixelBounds ();
///////////////////////////////////////////////
//
// DISPLAY OBJECT.
// http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html
//
///////////////////////////////////////////////
const string& name ();
void name ( string value );
const string& libraryItemName ();
void libraryItemName ( string value );
const float& alpha ();
void alpha ( float value );
const float& compoundAlpha ();
const bool& visible ();
void visible ( bool value );
const float& width ();
void width ( float value );
const float& height ();
void height ( float value );
const float& x ();
void x ( float value );
const float& y ();
void y ( float value );
const float& z ();
void z ( float value );
virtual const int& mouseX (); // is overwritten by stage.
virtual const int& mouseY (); // is overwritten by stage.
const float& rotation ();
void rotation ( float value );
const float& rotationX ();
void rotationX ( float value );
const float& rotationY ();
void rotationY ( float value );
const float& rotationZ ();
void rotationZ ( float value );
const float& scaleX ();
void scaleX ( float value );
const float& scaleY ();
void scaleY ( float value );
const float& scaleZ ();
void scaleZ ( float value );
const int& blendMode ();
void blendMode ( int value );
const int& level ();
void level ( int value );
const ofxFlashMatrix& matrix ();
void matrix ( const ofxFlashMatrix& mat );
const ofxFlashMatrix& concatenatedMatrix ();
const ofxFlashRectangle& pixelBounds ();
//=============================================================
ofxFlashDisplayObject* mask; // DisplayObject in AS3.
ofxFlashDisplayObject* parent; // DisplayObjectContainer in AS3.
ofxFlashStage* stage; // Stage in AS3.
//=============================================================
ofRectangle getRect ( ofxFlashDisplayObject* targetCoordinateSpace );
ofPoint globalToLocal ( const ofPoint& point );
ofPoint globalToLocal3D ( const ofPoint& point );
bool hitTestObject ( ofxFlashDisplayObject* obj );
bool hitTestPoint ( float x, float y, bool shapeFlag = false);
ofPoint local3DToGlobal ( const ofPoint& point );
ofPoint localToGlobal ( const ofPoint& point );
// TODO :: cacheAsBitmap - maybe this can be an FBO?
// TODO :: transform :: http://livedocs.adobe.com/flex/3/langref/flash/geom/Transform.html
// TODO :: events - added, addedToStage, enterFrame, exitFrame, frameConstructed, removed, removedFromStage, render
protected:
virtual void updateOnFrame () {}; // updateOnFrame is called on every update loop by stage. any updates should go in there.
virtual void drawOnFrame () {}; // drawOnFrame is called on every draw loop by stage.
ofxFlashMatrix _matrix;
ofxFlashMatrix _concatenatedMatrix;
ofxFlashMatrix _concatenatedMatrixInv;
ofxFlashRectangle _rect;
ofPoint _rectTransformed[ 4 ];
ofxFlashRectangle _pixelBounds;
private:
void resetPixelBounds ();
void addToPixelBounds ( const ofxFlashRectangle& rect );
void transform ( const ofxFlashMatrix& mat );
string _name;
string _libraryItemName;
float _alpha;
float _compoundAlpha;
bool _visible;
float _width;
float _height;
float _x;
float _y;
float _z;
int _mouseX;
int _mouseY;
float _rotation;
float _rotationX;
float _rotationY;
float _rotationZ;
float _scaleX;
float _scaleY;
float _scaleZ;
int _blendMode;
int _level;
};