38 |
38 |
|
39 |
39 |
private MeshObject mMesh;
|
40 |
40 |
private DistortedEffects mEffects;
|
41 |
|
private DistortedTexture mTexture;
|
|
41 |
private DistortedRenderable mRenderable;
|
42 |
42 |
private NodeData mData;
|
43 |
43 |
|
44 |
44 |
private DistortedTree mParent;
|
... | ... | |
94 |
94 |
{
|
95 |
95 |
ArrayList<Long> ret = new ArrayList<>();
|
96 |
96 |
|
97 |
|
ret.add( mTexture.getID() );
|
|
97 |
ret.add( mRenderable.getID() );
|
98 |
98 |
DistortedTree node;
|
99 |
99 |
|
100 |
100 |
for(int i=0; i<mNumChildren[0]; i++)
|
... | ... | |
125 |
125 |
if( newList.size()>1 )
|
126 |
126 |
{
|
127 |
127 |
if( mData.mFBO ==null )
|
128 |
|
mData.mFBO = new DistortedFramebuffer(mTexture.getWidth(), mTexture.getHeight());
|
|
128 |
mData.mFBO = new DistortedFramebuffer(mRenderable.getWidth(), mRenderable.getHeight());
|
129 |
129 |
}
|
130 |
130 |
else
|
131 |
131 |
{
|
... | ... | |
200 |
200 |
|
201 |
201 |
void drawRecursive(long currTime, DistortedFramebuffer df)
|
202 |
202 |
{
|
203 |
|
mTexture.create();
|
204 |
|
float halfX = mTexture.getWidth()/2.0f;
|
205 |
|
float halfY = mTexture.getHeight()/2.0f;
|
|
203 |
mRenderable.create();
|
|
204 |
float halfX = mRenderable.getWidth()/2.0f;
|
|
205 |
float halfY = mRenderable.getHeight()/2.0f;
|
206 |
206 |
|
207 |
207 |
if( mNumChildren[0]<=0 )
|
208 |
208 |
{
|
209 |
|
mTexture.setAsInput();
|
|
209 |
mRenderable.setAsInput();
|
210 |
210 |
}
|
211 |
211 |
else
|
212 |
212 |
{
|
... | ... | |
219 |
219 |
GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
220 |
220 |
GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
|
221 |
221 |
|
222 |
|
if( mTexture.setAsInput() )
|
|
222 |
if( mRenderable.setAsInput() )
|
223 |
223 |
DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO);
|
224 |
224 |
|
225 |
225 |
synchronized(this)
|
... | ... | |
245 |
245 |
/**
|
246 |
246 |
* Constructs new Node of the Tree.
|
247 |
247 |
*
|
248 |
|
* @param texture DistortedTexture to put into the new Node.
|
|
248 |
* @param renderable DistortedRenderable to put into the new Node.
|
249 |
249 |
* @param effects DistortedEffects to put into the new Node.
|
250 |
250 |
* @param mesh MeshObject to put into the new Node.
|
251 |
251 |
*/
|
252 |
|
public DistortedTree(DistortedTexture texture, DistortedEffects effects, MeshObject mesh)
|
|
252 |
public DistortedTree(DistortedRenderable renderable, DistortedEffects effects, MeshObject mesh)
|
253 |
253 |
{
|
254 |
|
mTexture= texture;
|
255 |
|
mEffects= effects;
|
256 |
|
mMesh = mesh;
|
257 |
|
mParent = null;
|
258 |
|
mChildren = null;
|
259 |
|
mNumChildren = new int[1];
|
260 |
|
mNumChildren[0] = 0;
|
|
254 |
mRenderable = renderable;
|
|
255 |
mEffects = effects;
|
|
256 |
mMesh = mesh;
|
|
257 |
mParent = null;
|
|
258 |
mChildren = null;
|
|
259 |
mNumChildren = new int[1];
|
|
260 |
mNumChildren[0]= 0;
|
261 |
261 |
|
262 |
262 |
ArrayList<Long> list = new ArrayList<>();
|
263 |
|
list.add(mTexture.getID());
|
|
263 |
list.add(mRenderable.getID());
|
264 |
264 |
|
265 |
265 |
mData = mMapNodeID.get(list);
|
266 |
266 |
|
... | ... | |
281 |
281 |
*
|
282 |
282 |
* @param node The DistortedTree to copy data from.
|
283 |
283 |
* @param flags bit field composed of a subset of the following:
|
284 |
|
* {@link Distorted#CLONE_BITMAP}, {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
|
|
284 |
* {@link Distorted#CLONE_RENDERABLE}, {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
|
285 |
285 |
* {@link Distorted#CLONE_FRAGMENT} and {@link Distorted#CLONE_CHILDREN}.
|
286 |
|
* For example flags = CLONE_BITMAP | CLONE_CHILDREN.
|
|
286 |
* For example flags = CLONE_RENDERABLE | CLONE_CHILDREN.
|
287 |
287 |
*/
|
288 |
288 |
public DistortedTree(DistortedTree node, int flags)
|
289 |
289 |
{
|
... | ... | |
291 |
291 |
mEffects= new DistortedEffects(node.mEffects,flags);
|
292 |
292 |
mMesh = node.mMesh;
|
293 |
293 |
|
294 |
|
if( (flags & Distorted.CLONE_BITMAP) != 0 )
|
|
294 |
if( (flags & Distorted.CLONE_RENDERABLE) != 0 )
|
295 |
295 |
{
|
296 |
|
mTexture = node.mTexture;
|
|
296 |
mRenderable = node.mRenderable;
|
297 |
297 |
}
|
298 |
298 |
else
|
299 |
299 |
{
|
300 |
|
mTexture = new DistortedTexture(node.mTexture.getWidth(), node.mTexture.getHeight());
|
|
300 |
int w = node.mRenderable.getWidth();
|
|
301 |
int h = node.mRenderable.getHeight();
|
|
302 |
|
|
303 |
if( node.mRenderable instanceof DistortedTexture )
|
|
304 |
{
|
|
305 |
mRenderable = new DistortedTexture(w,h);
|
|
306 |
}
|
|
307 |
else if( node.mRenderable instanceof DistortedFramebuffer )
|
|
308 |
{
|
|
309 |
boolean hasDepth = ((DistortedFramebuffer) node.mRenderable).hasDepth();
|
|
310 |
mRenderable = new DistortedFramebuffer(w,h,hasDepth);
|
|
311 |
}
|
301 |
312 |
}
|
302 |
313 |
if( (flags & Distorted.CLONE_CHILDREN) != 0 )
|
303 |
314 |
{
|
... | ... | |
349 |
360 |
/**
|
350 |
361 |
* Adds a new child to the last position in the list of our Node's children.
|
351 |
362 |
*
|
352 |
|
* @param texture DistortedTexture to initialize our child Node with.
|
|
363 |
* @param renderable DistortedRenderable to initialize our child Node with.
|
353 |
364 |
* @param effects DistortedEffects to initialize our child Node with.
|
354 |
365 |
* @param mesh MeshObject to initialize our child Node with.
|
355 |
366 |
* @return the newly constructed child Node, or null if we couldn't allocate resources.
|
356 |
367 |
*/
|
357 |
|
public synchronized DistortedTree attach(DistortedTexture texture, DistortedEffects effects, MeshObject mesh)
|
|
368 |
public synchronized DistortedTree attach(DistortedRenderable renderable, DistortedEffects effects, MeshObject mesh)
|
358 |
369 |
{
|
359 |
370 |
ArrayList<Long> prev = generateIDList();
|
360 |
371 |
|
361 |
372 |
if( mChildren==null ) mChildren = new ArrayList<>(2);
|
362 |
|
DistortedTree node = new DistortedTree(texture,effects,mesh);
|
|
373 |
DistortedTree node = new DistortedTree(renderable,effects,mesh);
|
363 |
374 |
node.mParent = this;
|
364 |
375 |
mChildren.add(node);
|
365 |
376 |
mNumChildren[0]++;
|
... | ... | |
463 |
474 |
|
464 |
475 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
465 |
476 |
/**
|
466 |
|
* Returns the DistortedTexture object that's in the Node.
|
|
477 |
* Returns the DistortedRenderable object that's in the Node.
|
467 |
478 |
*
|
468 |
|
* @return The DistortedTexture contained in the Node.
|
|
479 |
* @return The DistortedRenderable contained in the Node.
|
469 |
480 |
*/
|
470 |
|
public DistortedTexture getTexture()
|
|
481 |
public DistortedRenderable getRenderable()
|
471 |
482 |
{
|
472 |
|
return mTexture;
|
|
483 |
return mRenderable;
|
473 |
484 |
}
|
474 |
485 |
|
475 |
486 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Introduce Renderable to the Tree.