/** * Culls this node. This implementation appends the node stack to * the draw list in the cull context. * @param cc the cull context. */ protected void cull(CullContext cc) { cc.appendNodes(); }
/** * Constructs a transform context for the specified view canvas. * @param canvas the view canvas. */ public CullContext(ViewCanvas canvas) { super(canvas); initFrustum(); }
/** * Pops the transform matrix from the specified cull context. * @param cc the cull context. */ protected void cullEnd(CullContext cc) { cc.popLocalToWorld(); super.cullEnd(cc); }
CullContext cc = new CullContext(canvas); world.cullApply(cc); DrawList dl = cc.getDrawList(); DrawContext dc = new DrawContext(canvas); dl.draw(dc);
/** * Pushes the transform matrix onto the specified cull context. * @param cc the cull context. */ protected void cullBegin(CullContext cc) { super.cullBegin(cc); cc.pushLocalToWorld(_transform); }
/** * Ends the cull process for this node. * @param cc the cull context. */ protected void cullEnd(CullContext cc) { cc.popNode(); }
/** * Appends the node stack to the draw list in this context. */ public void appendNodes() { _drawList.append(getNodes()); }
/** * Applies the cull process to this node. If the view frustum intersects * the bounding sphere of this node, then this method calls the three * methods * {@link #cullBegin(CullContext)}, * {@link #cull(CullContext)}, and * {@link #cullEnd(CullContext)}, in that order. * @param cc the cull context. */ protected void cullApply(CullContext cc) { if (cc.frustumIntersectsSphereOf(this)) { cullBegin(cc); cull(cc); cullEnd(cc); } }
private void initFrustum() { // Frustum planes. Point inside lie in or above the planes. _planes[0] = new Plane(-1.0, 0.0, 0.0, 1.0); // right _planes[1] = new Plane( 1.0, 0.0, 0.0, 1.0); // left _planes[2] = new Plane( 0.0,-1.0, 0.0, 1.0); // top _planes[3] = new Plane( 0.0, 1.0, 0.0, 1.0); // bottom _planes[4] = new Plane( 0.0, 0.0,-1.0, 1.0); // near _planes[5] = new Plane( 0.0, 0.0, 1.0, 1.0); // far // Initially, all six planes are active; mark each with one bit. _active = 0x0000003F; Matrix44 worldToCube = getWorldToCube(); for (int i=0; i<6; ++i) { _planes[i].transformWithInverse(worldToCube); } } }
/** * Pushes the view-dependent transform onto the specified cull context. * @param cc the cull context. */ protected void cullBegin(CullContext cc) { super.cullBegin(cc); Matrix44 transform = computeTransform(cc); cc.pushLocalToWorld(transform); }
/** * Pops the view-dependent transform from the specified cull context. * @param cc the cull context. */ protected void cullEnd(CullContext cc) { cc.popLocalToWorld(); super.cullEnd(cc); }