Revision 3ef3364d
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/library/DistortedEffectQueues.java | ||
---|---|---|
92 | 92 |
|
93 | 93 |
GLES20.glViewport(0, 0, df.mWidth, df.mHeight); |
94 | 94 |
|
95 |
float halfZ = tex.mHalfX*grid.zFactor; |
|
96 |
|
|
95 | 97 |
mM.compute(currTime); |
96 |
mM.send(df,tex.mHalfX,tex.mHalfY,tex.mHalfZ);
|
|
98 |
mM.send(df,tex.mHalfX,tex.mHalfY,halfZ);
|
|
97 | 99 |
|
98 | 100 |
mV.compute(currTime); |
99 |
mV.send(tex.mHalfX,tex.mHalfY,tex.mHalfZ);
|
|
101 |
mV.send(tex.mHalfX,tex.mHalfY,halfZ);
|
|
100 | 102 |
|
101 | 103 |
mF.compute(currTime); |
102 | 104 |
mF.send(tex.mHalfX,tex.mHalfY); |
... | ... | |
110 | 112 |
{ |
111 | 113 |
GLES20.glViewport(0, 0, df.mWidth, df.mHeight); |
112 | 114 |
|
113 |
mM.sendZero(df,tex.mHalfX,tex.mHalfY,tex.mHalfZ);
|
|
115 |
mM.sendZero(df,tex.mHalfX,tex.mHalfY,tex.mHalfX*grid.zFactor);
|
|
114 | 116 |
mV.sendZero(); |
115 | 117 |
mF.sendZero(); |
116 | 118 |
|
... | ... | |
751 | 753 |
/** |
752 | 754 |
* Directional, sinusoidal wave effect. |
753 | 755 |
* |
754 |
* @param wave see {@link DistortedObject#wave(Data5D,Data3D)}
|
|
756 |
* @param wave see {@link DistortedEffectQueues#wave(Data5D,Data3D)}
|
|
755 | 757 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
756 | 758 |
* @param region Region that masks the Effect. |
757 | 759 |
* @return ID of the effect added, or -1 if we failed to add one. |
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 |
} |
src/main/java/org/distorted/library/GridCubes.java | ||
---|---|---|
766 | 766 |
*/ |
767 | 767 |
public GridCubes(int cols, String desc, boolean frontOnly) |
768 | 768 |
{ |
769 |
super(frontOnly ? 0.0f:1.0f/cols); |
|
769 | 770 |
prepareDataStructures(cols,desc,frontOnly); |
770 | 771 |
build(frontOnly); |
771 | 772 |
} |
... | ... | |
780 | 781 |
*/ |
781 | 782 |
public GridCubes(int cols, int rows, boolean frontOnly) |
782 | 783 |
{ |
784 |
super(frontOnly ? 0.0f:1.0f/cols); |
|
783 | 785 |
prepareDataStructures(cols,rows,frontOnly); |
784 | 786 |
build(frontOnly); |
785 | 787 |
} |
src/main/java/org/distorted/library/GridFlat.java | ||
---|---|---|
163 | 163 |
*/ |
164 | 164 |
public GridFlat(int cols, int rows) |
165 | 165 |
{ |
166 |
super(0.0f); |
|
166 | 167 |
computeNumberOfVertices(cols,rows); |
167 | 168 |
|
168 | 169 |
float[] positionData= new float[POSITION_DATA_SIZE*dataLength]; |
src/main/java/org/distorted/library/GridObject.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
protected int dataLength; |
36 | 36 |
protected FloatBuffer mGridPositions,mGridNormals,mGridTexture; |
37 |
|
|
37 |
|
|
38 |
final float zFactor; // strange workaround the fact that we need to somehow store the 'depth' |
|
39 |
// of the Grid. Used in DistortedEffectQueues. See DistortedTexture.getDepth(). |
|
40 |
|
|
38 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 |
|
|
42 |
|
|
43 |
GridObject(float factor) |
|
44 |
{ |
|
45 |
zFactor = factor; |
|
46 |
} |
|
47 |
|
|
48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
|
|
40 | 50 |
void draw() |
41 | 51 |
{ |
42 | 52 |
GLES20.glVertexAttribPointer(Distorted.mPositionH , POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mGridPositions); |
Also available in: Unified diff
Hide the 'depth' of a DistortedTexture inside the library, so users do not get exposed to this weirdness.