• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5 package com.jme3.scene;
6 
7 import com.jme3.math.Transform;
8 
9 /**
10  *
11  * SimpleBatchNode  comes with some restrictions, but can yield better performances.
12  * Geometries to be batched has to be attached directly to the BatchNode
13  * You can't attach a Node to a SimpleBatchNode
14  * SimpleBatchNode is recommended when you have a large number of geometries using the same material that does not require a complex scene graph structure.
15  * @see BatchNode
16  * @author Nehon
17  */
18 public class SimpleBatchNode extends BatchNode {
19 
SimpleBatchNode()20     public SimpleBatchNode() {
21         super();
22     }
23 
SimpleBatchNode(String name)24     public SimpleBatchNode(String name) {
25         super(name);
26     }
27 
28     @Override
attachChild(Spatial child)29     public int attachChild(Spatial child) {
30 
31         if (!(child instanceof Geometry)) {
32             throw new UnsupportedOperationException("BatchNode is BatchMode.Simple only support child of type Geometry, use BatchMode.Complex to use a complex structure");
33         }
34 
35         return super.attachChild(child);
36     }
37 
38     @Override
setTransformRefresh()39     protected void setTransformRefresh() {
40 
41         refreshFlags |= RF_TRANSFORM;
42         setBoundRefresh();
43         for (Batch batch : batches.values()) {
44             batch.geometry.setTransformRefresh();
45         }
46     }
47 
getTransforms(Geometry geom)48      protected Transform getTransforms(Geometry geom){
49         return geom.getLocalTransform();
50     }
51 
52     @Override
batch()53     public void batch() {
54         doBatch();
55     }
56 }
57