Revision 3ef3364d
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedTexture.java | ||
---|---|---|
34 | 34 |
private static long mNextID =0; |
35 | 35 |
private static HashMap<Long,DistortedTexture> mTextures = new HashMap<>(); |
36 | 36 |
|
37 |
private int mSizeX, mSizeY, mSizeZ; // in screen space
|
|
38 |
float mHalfX, mHalfY, mHalfZ; // halves of the above
|
|
37 |
private int mSizeX, mSizeY; // in screen space
|
|
38 |
float mHalfX, mHalfY; // halves of the above
|
|
39 | 39 |
|
40 | 40 |
private long mID; |
41 | 41 |
private long mBitmapID=0; |
... | ... | |
138 | 138 |
/** |
139 | 139 |
* Create empty texture of given dimensions. |
140 | 140 |
*/ |
141 |
public DistortedTexture(int width, int height, int depth)
|
|
141 |
public DistortedTexture(int width, int height) |
|
142 | 142 |
{ |
143 |
mSizeX= width ; mHalfX = mSizeX/2.0f; |
|
144 |
mSizeY= height; mHalfY = mSizeY/2.0f; |
|
145 |
mSizeZ= depth ; mHalfZ = mSizeZ/2.0f; |
|
146 |
|
|
147 | 143 |
mID = mNextID++; |
148 | 144 |
mTextures.put(mID,this); |
149 | 145 |
|
146 |
mSizeX= width ; mHalfX = mSizeX/2.0f; |
|
147 |
mSizeY= height; mHalfY = mSizeY/2.0f; |
|
148 |
|
|
150 | 149 |
mTextureDataH = new int[1]; |
151 | 150 |
mTextureDataH[0]= 0; |
152 | 151 |
mBmp = new Bitmap[1]; |
... | ... | |
174 | 173 |
mID = mNextID++; |
175 | 174 |
mTextures.put(mID,this); |
176 | 175 |
|
177 |
mSizeX = dt.mSizeX; |
|
178 |
mSizeY = dt.mSizeY; |
|
179 |
mSizeZ = dt.mSizeZ; |
|
180 |
mHalfX = dt.mHalfX; |
|
181 |
mHalfY = dt.mHalfY; |
|
182 |
mHalfZ = dt.mHalfZ; |
|
176 |
mSizeX= dt.mSizeX ; mHalfX = mSizeX/2.0f; |
|
177 |
mSizeY= dt.mSizeY ; mHalfY = mSizeY/2.0f; |
|
183 | 178 |
|
184 | 179 |
if( (flags & Distorted.CLONE_BITMAP) != 0 ) |
185 | 180 |
{ |
... | ... | |
261 | 256 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
262 | 257 |
/** |
263 | 258 |
* Returns the depth of the DistortedObject. |
259 |
* <p> |
|
260 |
* Admittedly quite a strange method. Why do we need to pass a Grid to it? Because one cannot determine |
|
261 |
* 'depth' of a texture when rendered based only on the texture itself, that depends on the Grid it is |
|
262 |
* rendered with. |
|
264 | 263 |
* |
265 | 264 |
* @return depth of the Object, in pixels. |
266 | 265 |
*/ |
267 |
public int getDepth() |
|
266 |
public int getDepth(GridObject grid)
|
|
268 | 267 |
{ |
269 |
return mSizeZ;
|
|
268 |
return grid==null ? 0 : (int)(mSizeX*grid.zFactor);
|
|
270 | 269 |
} |
271 |
|
|
272 | 270 |
} |
Also available in: Unified diff
Hide the 'depth' of a DistortedTexture inside the library, so users do not get exposed to this weirdness.