Project

General

Profile

Download (17.3 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedNode.java @ 07037b8a

1 d333eb6b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 6a06a912 Leszek Koltunski
package org.distorted.library;
21
22
import java.util.ArrayList;
23
import java.util.HashMap;
24
25 194ab46f Leszek Koltunski
import android.opengl.GLES30;
26 6a06a912 Leszek Koltunski
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
/**
29 a09ada4c Leszek Koltunski
 * Class which represents a Node in a Tree of (InputSurface,Mesh,Effects) triplets.
30 c204c69d leszek
 * <p>
31 a09ada4c Leszek Koltunski
 * Having organized such sets into a Tree, we can then render any Node to any OutputSurface.
32 7b8086eb Leszek Koltunski
 * That recursively renders the set held in the Node and all its children.
33 c204c69d leszek
 * <p>
34
 * The class takes special care to only render identical sub-trees once. Each Node holds a reference
35
 * to sub-class 'NodeData'. Two identical sub-trees attached at different points of the main tree
36
 * will point to the same NodeData; only the first of this is rendered (when mData.numRendered==0).
37 6a06a912 Leszek Koltunski
 */
38 c204c69d leszek
public class DistortedNode implements DistortedAttacheable
39 6a06a912 Leszek Koltunski
  {
40 bd3da5b2 Leszek Koltunski
  private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
41
  private static long mNextNodeID =0;
42
43 05403bba Leszek Koltunski
  private MeshObject mMesh;
44 07d8ef09 Leszek Koltunski
  private DistortedEffects mEffects;
45 c5369f1b leszek
  private DistortedInputSurface mSurface;
46 6a06a912 Leszek Koltunski
  private NodeData mData;
47 bd3da5b2 Leszek Koltunski
48 a09ada4c Leszek Koltunski
  private ArrayList<DistortedNode> mChildren;
49 6a06a912 Leszek Koltunski
  private int[] mNumChildren;  // ==mChildren.length(), but we only create mChildren if the first one gets added
50
51
  private class NodeData
52
    {
53 bd3da5b2 Leszek Koltunski
    long ID;
54 6a06a912 Leszek Koltunski
    int numPointingNodes;
55 7691a39f leszek
    int numRender;
56 af27df87 leszek
    ArrayList<Long> key;
57 8c327653 Leszek Koltunski
    DistortedFramebuffer mFBO;
58 6a06a912 Leszek Koltunski
59 af27df87 leszek
    NodeData(long id, ArrayList<Long> k)
60 6a06a912 Leszek Koltunski
      {
61 bd3da5b2 Leszek Koltunski
      ID              = id;
62 af27df87 leszek
      key             = k;
63 bd3da5b2 Leszek Koltunski
      numPointingNodes= 1;
64 7691a39f leszek
      numRender       =-1;
65 8c327653 Leszek Koltunski
      mFBO            = null;
66 6a06a912 Leszek Koltunski
      }
67 bd3da5b2 Leszek Koltunski
    }
68 6a06a912 Leszek Koltunski
 
69 436899f2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71 7b8086eb Leszek Koltunski
  static synchronized void onDestroy()
72 436899f2 Leszek Koltunski
    {
73
    mNextNodeID = 0;
74
    mMapNodeID.clear();
75
    }
76
77 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
78
79
  private ArrayList<Long> generateIDList()
80
    {
81 9361b337 Leszek Koltunski
    ArrayList<Long> ret = new ArrayList<>();
82 6a06a912 Leszek Koltunski
     
83 c5369f1b leszek
    ret.add( mSurface.getID() );
84 7691a39f leszek
85
    if( mNumChildren[0]==0 )
86
      {
87
      ret.add(-mEffects.getID());
88
      }
89
90 a09ada4c Leszek Koltunski
    DistortedNode node;
91 6a06a912 Leszek Koltunski
   
92
    for(int i=0; i<mNumChildren[0]; i++)
93
      {
94
      node = mChildren.get(i);
95
      ret.add(node.mData.ID);
96
      }
97
   
98
    return ret;
99
    }
100
101 fee0865c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
102
// Debug - print all the Node IDs
103 c204c69d leszek
104 af27df87 leszek
  @SuppressWarnings("unused")
105 fee0865c Leszek Koltunski
  void debug(int depth)
106
    {
107
    String tmp="";
108
    int i;
109
110
    for(i=0; i<depth; i++) tmp +="   ";
111 07037b8a leszek
    tmp += ("NodeID="+mData.ID+" nodes pointing: "+mData.numPointingNodes+" surfaceID="+
112
            mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID()));
113 fee0865c Leszek Koltunski
114 1942537e Leszek Koltunski
    android.util.Log.e("NODE", tmp);
115 fee0865c Leszek Koltunski
116
    for(i=0; i<mNumChildren[0]; i++)
117
      mChildren.get(i).debug(depth+1);
118
    }
119
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
// Debug - print contents of the HashMap
122
123 af27df87 leszek
  @SuppressWarnings("unused")
124 fee0865c Leszek Koltunski
  static void debugMap()
125
    {
126
    NodeData tmp;
127
128
    for(ArrayList<Long> key: mMapNodeID.keySet())
129
      {
130
      tmp = mMapNodeID.get(key);
131 c204c69d leszek
      android.util.Log.e("NODE", "NodeID: "+tmp.ID+" <-- "+key);
132
      }
133
    }
134
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136
137
  void treeIsomorphism()
138
    {
139
    for(int i=0; i<mNumChildren[0]; i++)
140
      {
141
      mChildren.get(i).treeIsomorphism();
142
      }
143
144
    ArrayList<Long> newList = generateIDList();
145
    NodeData newData = mMapNodeID.get(newList);
146
147
    if( newData==null )
148
      {
149 07037b8a leszek
      android.util.Log.d("NODE", "list "+newList+" not found!! node surfaceID="+mSurface.getID());
150
151 af27df87 leszek
      newData = new NodeData(++mNextNodeID,newList);
152 c204c69d leszek
      mMapNodeID.put(newList,newData);
153
      }
154
    else if( newData.ID != mData.ID )
155
      {
156 07037b8a leszek
      android.util.Log.d("NODE", "list "+newList+" found!! node surfaceID="+mSurface.getID());
157
158 c204c69d leszek
      newData.numPointingNodes++;
159
      }
160
161
    if( newData.ID != mData.ID )
162
      {
163
      boolean fboUsed = false;
164
165
      if( mNumChildren[0]>0 && newData.mFBO==null )
166
        {
167
        if( mData.mFBO!=null )
168
          {
169 07037b8a leszek
          if( mData.numPointingNodes>1 )
170
            {
171
            android.util.Log.d("NODE", "creating1 new FBO of node surfaceID="+mSurface.getID());
172
            newData.mFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_TREE,mSurface.getWidth(),mSurface.getHeight());
173
            }
174
          else
175
            {
176
            android.util.Log.d("NODE", "copying over FBO of node surfaceID="+mSurface.getID());
177
            newData.mFBO = mData.mFBO;
178
            fboUsed = true;
179
            }
180 c204c69d leszek
          }
181
        else
182
          {
183 07037b8a leszek
          android.util.Log.d("NODE", "creating2 new FBO of node surfaceID="+mSurface.getID());
184 09ab7524 Leszek Koltunski
          newData.mFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_TREE,mSurface.getWidth(),mSurface.getHeight());
185 c204c69d leszek
          }
186
        }
187
      if( mNumChildren[0]==0 && newData.mFBO!=null )
188
        {
189 af27df87 leszek
        android.util.Log.d("NODE", "deleting FBO of newData node!!");
190 c204c69d leszek
        newData.mFBO.markForDeletion();
191
        newData.mFBO = null;
192
        }
193
194
      if( --mData.numPointingNodes==0 )
195
        {
196 07037b8a leszek
        android.util.Log.d("NODE", "deleting1 map key "+mData.key);
197
198 af27df87 leszek
        mMapNodeID.remove(mData.key);
199 c204c69d leszek
200
        if( !fboUsed && mData.mFBO!=null )
201
          {
202 af27df87 leszek
          android.util.Log.d("NODE", "deleting FBO of node surfaceID="+mSurface.getID());
203
204 c204c69d leszek
          mData.mFBO.markForDeletion();
205
          mData.mFBO = null;
206
          }
207
        }
208
209
      mData = newData;
210 fee0865c Leszek Koltunski
      }
211
    }
212 c204c69d leszek
213 a0f644b7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
214 7691a39f leszek
// return the total number of render calls issued
215 a0f644b7 Leszek Koltunski
216 d03782c0 leszek
  int drawRecursive(int renderNum, long currTime, DistortedOutputSurface surface)
217 a0f644b7 Leszek Koltunski
    {
218 7691a39f leszek
    int ret = 0;
219 c5369f1b leszek
    float halfX = mSurface.getWidth()/2.0f;
220
    float halfY = mSurface.getHeight()/2.0f;
221 a0f644b7 Leszek Koltunski
222 d03782c0 leszek
    if( mNumChildren[0]>0 && mData.numRender!=renderNum )
223 a0f644b7 Leszek Koltunski
      {
224 d03782c0 leszek
      mData.numRender = renderNum;
225
      mData.mFBO.setAsOutput();
226 a0f644b7 Leszek Koltunski
227 d03782c0 leszek
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
228
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
229 a0f644b7 Leszek Koltunski
230 d03782c0 leszek
      if( mSurface.setAsInput() )
231
        {
232
        ret++;
233
        DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO);
234 a0f644b7 Leszek Koltunski
        }
235
236 d03782c0 leszek
      for(int i=0; i<mNumChildren[0]; i++)
237
        {
238
        ret += mChildren.get(i).drawRecursive(renderNum, currTime, mData.mFBO);
239
        }
240 a0f644b7 Leszek Koltunski
      }
241
242 d03782c0 leszek
    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
243 7691a39f leszek
244 d03782c0 leszek
    if( input.setAsInput() )
245
      {
246
      ret++;
247
      mEffects.drawPriv(halfX, halfY, mMesh, surface, currTime);
248
      }
249
250
    return ret;
251 a0f644b7 Leszek Koltunski
    }
252
253 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
254
// PUBLIC API
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
/**
257 a09ada4c Leszek Koltunski
 * Constructs new Node.
258 6a06a912 Leszek Koltunski
 *     
259 c5369f1b leszek
 * @param surface InputSurface to put into the new Node.
260 07d8ef09 Leszek Koltunski
 * @param effects DistortedEffects to put into the new Node.
261 05403bba Leszek Koltunski
 * @param mesh MeshObject to put into the new Node.
262 6a06a912 Leszek Koltunski
 */
263 a09ada4c Leszek Koltunski
  public DistortedNode(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
264 6a06a912 Leszek Koltunski
    {
265 c5369f1b leszek
    mSurface       = surface;
266 8ca9f899 Leszek Koltunski
    mEffects       = effects;
267
    mMesh          = mesh;
268
    mChildren      = null;
269
    mNumChildren   = new int[1];
270
    mNumChildren[0]= 0;
271 6a06a912 Leszek Koltunski
   
272 9361b337 Leszek Koltunski
    ArrayList<Long> list = new ArrayList<>();
273 c5369f1b leszek
    list.add(mSurface.getID());
274 7691a39f leszek
    list.add(-mEffects.getID());
275 1942537e Leszek Koltunski
276 6a06a912 Leszek Koltunski
    mData = mMapNodeID.get(list);
277
   
278
    if( mData!=null )
279
      {
280
      mData.numPointingNodes++;
281
      }
282
    else
283
      {
284 af27df87 leszek
      mData = new NodeData(++mNextNodeID,list);
285 1942537e Leszek Koltunski
      mMapNodeID.put(list, mData);
286 6a06a912 Leszek Koltunski
      }
287
    }
288
289
///////////////////////////////////////////////////////////////////////////////////////////////////  
290
/**
291 a09ada4c Leszek Koltunski
 * Copy-constructs new Node from another Node.
292 6a06a912 Leszek Koltunski
 *     
293 a09ada4c Leszek Koltunski
 * @param node The DistortedNode to copy data from.
294 6a06a912 Leszek Koltunski
 * @param flags bit field composed of a subset of the following:
295 29a06526 Leszek Koltunski
 *        {@link Distorted#CLONE_SURFACE},  {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
296 6a06a912 Leszek Koltunski
 *        {@link Distorted#CLONE_FRAGMENT} and {@link Distorted#CLONE_CHILDREN}.
297 29a06526 Leszek Koltunski
 *        For example flags = CLONE_SURFACE | CLONE_CHILDREN.
298 6a06a912 Leszek Koltunski
 */
299 a09ada4c Leszek Koltunski
  public DistortedNode(DistortedNode node, int flags)
300 6a06a912 Leszek Koltunski
    {
301 432442f9 Leszek Koltunski
    mEffects= new DistortedEffects(node.mEffects,flags);
302 05403bba Leszek Koltunski
    mMesh = node.mMesh;
303 9361b337 Leszek Koltunski
304 29a06526 Leszek Koltunski
    if( (flags & Distorted.CLONE_SURFACE) != 0 )
305 e7a20702 Leszek Koltunski
      {
306 c5369f1b leszek
      mSurface = node.mSurface;
307 e7a20702 Leszek Koltunski
      }
308
    else
309
      {
310 c5369f1b leszek
      int w = node.mSurface.getWidth();
311
      int h = node.mSurface.getHeight();
312 8ca9f899 Leszek Koltunski
313 c5369f1b leszek
      if( node.mSurface instanceof DistortedTexture )
314 8ca9f899 Leszek Koltunski
        {
315 09ab7524 Leszek Koltunski
        mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
316 8ca9f899 Leszek Koltunski
        }
317 c5369f1b leszek
      else if( node.mSurface instanceof DistortedFramebuffer )
318 8ca9f899 Leszek Koltunski
        {
319 c5369f1b leszek
        boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth();
320 09ab7524 Leszek Koltunski
        mSurface = new DistortedFramebuffer(hasDepth,DistortedSurface.TYPE_TREE,w,h);
321 8ca9f899 Leszek Koltunski
        }
322 e7a20702 Leszek Koltunski
      }
323 9361b337 Leszek Koltunski
    if( (flags & Distorted.CLONE_CHILDREN) != 0 )
324 6a06a912 Leszek Koltunski
      {
325 c204c69d leszek
      if( node.mChildren==null )     // do NOT copy over the NULL!
326
        {
327
        node.mChildren = new ArrayList<>(2);
328
        }
329
330 6a06a912 Leszek Koltunski
      mChildren = node.mChildren;
331
      mNumChildren = node.mNumChildren;
332
      }
333
    else
334
      {
335
      mChildren = null;
336
      mNumChildren = new int[1];
337
      mNumChildren[0] = 0;
338
      }
339
   
340
    ArrayList<Long> list = generateIDList();
341
   
342
    mData = mMapNodeID.get(list);
343
   
344
    if( mData!=null )
345
      {
346
      mData.numPointingNodes++;
347
      }
348
    else
349
      {
350 af27df87 leszek
      mData = new NodeData(++mNextNodeID,list);
351 6a06a912 Leszek Koltunski
      mMapNodeID.put(list, mData);
352
      }
353
    }
354 c204c69d leszek
355 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
356
/**
357
 * Adds a new child to the last position in the list of our Node's children.
358 c204c69d leszek
 * <p>
359
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
360
 * DistortedAttachDeamon (by calling attachNow())
361
 *
362 6a06a912 Leszek Koltunski
 * @param node The new Node to add.
363
 */
364 c204c69d leszek
  public void attach(DistortedNode node)
365 6a06a912 Leszek Koltunski
    {
366 c204c69d leszek
    DistortedAttachDaemon.attach(this,node);
367 6a06a912 Leszek Koltunski
    }
368 c204c69d leszek
369 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
370
/**
371
 * Adds a new child to the last position in the list of our Node's children.
372 c204c69d leszek
 * <p>
373
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
374
 * DistortedAttachDeamon (by calling attachNow())
375
 *
376 c5369f1b leszek
 * @param surface InputSurface to initialize our child Node with.
377 07d8ef09 Leszek Koltunski
 * @param effects DistortedEffects to initialize our child Node with.
378 05403bba Leszek Koltunski
 * @param mesh MeshObject to initialize our child Node with.
379 6a06a912 Leszek Koltunski
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
380
 */
381 c204c69d leszek
  public DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
382 6a06a912 Leszek Koltunski
    {
383 c204c69d leszek
    DistortedNode node = new DistortedNode(surface,effects,mesh);
384
    DistortedAttachDaemon.attach(this,node);
385
    return node;
386
    }
387 f8377ef8 leszek
388 c204c69d leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
389
/**
390
 * This is not really part of the public API. Has to be public only because it is a part of the
391
 * DistortedAttacheable interface, which should really be a class that we extend here instead but
392
 * Java has no multiple inheritance.
393
 *
394
 * @param node The new Node to add.
395
 */
396
  public void attachNow(DistortedNode node)
397
    {
398 9361b337 Leszek Koltunski
    if( mChildren==null ) mChildren = new ArrayList<>(2);
399 c204c69d leszek
400 6a06a912 Leszek Koltunski
    mChildren.add(node);
401
    mNumChildren[0]++;
402
    }
403 c204c69d leszek
404 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
405
/**
406
 * Removes the first occurrence of a specified child from the list of children of our Node.
407 c204c69d leszek
 * <p>
408
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
409
 * DistortedAttachDeamon (by calling detachNow())
410
 *
411 6a06a912 Leszek Koltunski
 * @param node The Node to remove.
412
 */
413 c204c69d leszek
  public void detach(DistortedNode node)
414 6a06a912 Leszek Koltunski
    {
415 c204c69d leszek
    DistortedAttachDaemon.detach(this,node);
416 6a06a912 Leszek Koltunski
    }
417 a09ada4c Leszek Koltunski
418 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
419
/**
420
 * Removes the first occurrence of a specified child from the list of children of our Node.
421 a09ada4c Leszek Koltunski
 * <p>
422
 * A bit questionable method as there can be many different Nodes attached as children, some
423
 * of them having the same Effects but - for instance - different Mesh. Use with care.
424 c204c69d leszek
 * <p>
425
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
426
 * DistortedAttachDeamon (by calling detachNow())
427 a09ada4c Leszek Koltunski
 *
428 07d8ef09 Leszek Koltunski
 * @param effects DistortedEffects to remove.
429 6a06a912 Leszek Koltunski
 */
430 c204c69d leszek
  public void detach(DistortedEffects effects)
431 6a06a912 Leszek Koltunski
    {
432 07d8ef09 Leszek Koltunski
    long id = effects.getID();
433 a09ada4c Leszek Koltunski
    DistortedNode node;
434
435 6a06a912 Leszek Koltunski
    for(int i=0; i<mNumChildren[0]; i++)
436
      {
437
      node = mChildren.get(i);
438 a09ada4c Leszek Koltunski
439 07d8ef09 Leszek Koltunski
      if( node.mEffects.getID()==id )
440 6a06a912 Leszek Koltunski
        {
441 c204c69d leszek
        DistortedAttachDaemon.detach(this,node);
442
        break;
443 6a06a912 Leszek Koltunski
        }
444
      }
445
    }
446 a09ada4c Leszek Koltunski
447 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
448
/**
449 c204c69d leszek
 * This is not really part of the public API. Has to be public only because it is a part of the
450
 * DistortedAttacheable interface, which should really be a class that we extend here instead but
451
 * Java has no multiple inheritance.
452
 *
453
 * @param node The Node to remove.
454 6a06a912 Leszek Koltunski
 */
455 c204c69d leszek
  public void detachNow(DistortedNode node)
456 6a06a912 Leszek Koltunski
    {
457 c204c69d leszek
    if( mNumChildren[0]>0 && mChildren.remove(node) )
458 6a06a912 Leszek Koltunski
      {
459 c204c69d leszek
      mNumChildren[0]--;
460 af27df87 leszek
461
      if( mNumChildren[0]==0 && mData.mFBO!=null )
462
        {
463 07037b8a leszek
        if( --mData.numPointingNodes==0 )
464
          {
465
          mData.mFBO.markForDeletion();
466
          android.util.Log.d("NODE", "deleting2 map key "+mData.key);
467
468
          mMapNodeID.remove(mData.key);
469
          }
470 af27df87 leszek
        mData.mFBO = null;
471
        }
472 6a06a912 Leszek Koltunski
      }
473 c204c69d leszek
    }
474
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476
/**
477
 * Removes all children Nodes.
478
 * <p>
479
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
480
 * DistortedAttachDeamon (by calling detachAllNow())
481
 */
482
  public void detachAll()
483
    {
484
    DistortedAttachDaemon.detachAll(this);
485
    }
486
487
///////////////////////////////////////////////////////////////////////////////////////////////////
488
/**
489
 * This is not really part of the public API. Has to be public only because it is a part of the
490
 * DistortedAttacheable interface, which should really be a class that we extend here instead but
491
 * Java has no multiple inheritance.
492
 */
493
  public void detachAllNow()
494
    {
495 6a06a912 Leszek Koltunski
    if( mNumChildren[0]>0 )
496
      {
497
      mNumChildren[0] = 0;
498
      mChildren.clear();
499 af27df87 leszek
500
      if( mData.mFBO!=null )
501
        {
502 07037b8a leszek
        if( --mData.numPointingNodes==0 )
503
          {
504
          mData.mFBO.markForDeletion();
505
          android.util.Log.d("NODE", "deleting3 map key "+mData.key);
506
507
          mMapNodeID.remove(mData.key);
508
          }
509 af27df87 leszek
        mData.mFBO = null;
510
        }
511 6a06a912 Leszek Koltunski
      }
512
    }
513 d1e740c5 Leszek Koltunski
514 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
515
/**
516 421c2728 Leszek Koltunski
 * Returns the DistortedEffects object that's in the Node.
517 6a06a912 Leszek Koltunski
 * 
518 421c2728 Leszek Koltunski
 * @return The DistortedEffects contained in the Node.
519 6a06a912 Leszek Koltunski
 */
520 421c2728 Leszek Koltunski
  public DistortedEffects getEffects()
521 6a06a912 Leszek Koltunski
    {
522 07d8ef09 Leszek Koltunski
    return mEffects;
523 4e2382f3 Leszek Koltunski
    }
524
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
/**
527 c5369f1b leszek
 * Returns the DistortedInputSurface object that's in the Node.
528 4e2382f3 Leszek Koltunski
 *
529 c5369f1b leszek
 * @return The DistortedInputSurface contained in the Node.
530 4e2382f3 Leszek Koltunski
 */
531 c5369f1b leszek
  public DistortedInputSurface getSurface()
532 4e2382f3 Leszek Koltunski
    {
533 c5369f1b leszek
    return mSurface;
534 6a06a912 Leszek Koltunski
    }
535
536 8c327653 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
537
/**
538
 * Returns the DistortedFramebuffer object that's in the Node.
539
 *
540
 * @return The DistortedFramebuffer contained in the Node.
541
 */
542
  public DistortedFramebuffer getFramebuffer()
543
    {
544
    return mData.mFBO;
545
    }
546 6a06a912 Leszek Koltunski
547 8c327653 Leszek Koltunski
  }