Revision ada90d33
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/library/DistortedObject.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
32 | 32 |
|
33 |
/** |
|
34 |
* Default empty constructor so that derived classes can call it |
|
35 |
*/ |
|
36 |
public DistortedObject() |
|
37 |
{ |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
42 |
/** |
|
43 |
* Copy constructor used to create a DistortedObject based on various parts of another object. |
|
44 |
* <p> |
|
45 |
* Whatever we do not clone gets created just like in the default constructor. |
|
46 |
* |
|
47 |
* @param dc Source object to create our object from |
|
48 |
* @param flags A bitmask of values specifying what to copy. |
|
49 |
* For example, CLONE_BITMAP | CLONE_MATRIX. |
|
50 |
*/ |
|
51 |
public DistortedObject(DistortedObject dc, int flags) |
|
52 |
{ |
|
53 |
initializeEffectLists(dc,flags); |
|
54 |
|
|
55 |
mID = DistortedObjectList.add(this); |
|
56 |
|
|
57 |
mSizeX = dc.mSizeX; |
|
58 |
mSizeY = dc.mSizeY; |
|
59 |
mSizeZ = dc.mSizeZ; |
|
60 |
mSize = dc.mSize; |
|
61 |
mGrid = dc.mGrid; |
|
62 |
|
|
63 |
if( (flags & Distorted.CLONE_BITMAP) != 0 ) |
|
64 |
{ |
|
65 |
mTextureDataH = dc.mTextureDataH; |
|
66 |
mBmp = dc.mBmp; |
|
67 |
mBitmapSet = dc.mBitmapSet; |
|
68 |
} |
|
69 |
else |
|
70 |
{ |
|
71 |
mTextureDataH = new int[1]; |
|
72 |
mTextureDataH[0]= 0; |
|
73 |
mBitmapSet = new boolean[1]; |
|
74 |
mBitmapSet[0] = false; |
|
75 |
mBmp = new Bitmap[1]; |
|
76 |
mBmp[0] = null; |
|
77 |
|
|
78 |
if( Distorted.isInitialized() ) resetTexture(); |
|
79 |
} |
|
80 |
} |
|
33 |
protected abstract DistortedObject deepCopy(int flags); |
|
81 | 34 |
|
82 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
83 | 36 |
|
... | ... | |
213 | 166 |
return mBmp==null ? 0 : mBmp.hashCode(); |
214 | 167 |
} |
215 | 168 |
|
169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
170 |
|
|
171 |
/** |
|
172 |
* Default empty constructor so that derived classes can call it |
|
173 |
*/ |
|
174 |
public DistortedObject() |
|
175 |
{ |
|
176 |
|
|
177 |
} |
|
178 |
|
|
179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
180 |
/** |
|
181 |
* Copy constructor used to create a DistortedObject based on various parts of another object. |
|
182 |
* <p> |
|
183 |
* Whatever we do not clone gets created just like in the default constructor. |
|
184 |
* |
|
185 |
* @param dc Source object to create our object from |
|
186 |
* @param flags A bitmask of values specifying what to copy. |
|
187 |
* For example, CLONE_BITMAP | CLONE_MATRIX. |
|
188 |
*/ |
|
189 |
public DistortedObject(DistortedObject dc, int flags) |
|
190 |
{ |
|
191 |
initializeEffectLists(dc,flags); |
|
192 |
|
|
193 |
mID = DistortedObjectList.add(this); |
|
194 |
|
|
195 |
mSizeX = dc.mSizeX; |
|
196 |
mSizeY = dc.mSizeY; |
|
197 |
mSizeZ = dc.mSizeZ; |
|
198 |
mSize = dc.mSize; |
|
199 |
mGrid = dc.mGrid; |
|
200 |
|
|
201 |
if( (flags & Distorted.CLONE_BITMAP) != 0 ) |
|
202 |
{ |
|
203 |
mTextureDataH = dc.mTextureDataH; |
|
204 |
mBmp = dc.mBmp; |
|
205 |
mBitmapSet = dc.mBitmapSet; |
|
206 |
} |
|
207 |
else |
|
208 |
{ |
|
209 |
mTextureDataH = new int[1]; |
|
210 |
mTextureDataH[0]= 0; |
|
211 |
mBitmapSet = new boolean[1]; |
|
212 |
mBitmapSet[0] = false; |
|
213 |
mBmp = new Bitmap[1]; |
|
214 |
mBmp[0] = null; |
|
215 |
|
|
216 |
if( Distorted.isInitialized() ) resetTexture(); |
|
217 |
} |
|
218 |
} |
|
219 |
|
|
216 | 220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
217 | 221 |
/** |
218 | 222 |
* Draw the DistortedObject to the location specified by current Matrix effects. |
Also available in: Unified diff
Make deep copying DistortedObjects (needed in DistortedNode) standard.