Example #1
0
        /** {@inheritDoc} */
        public void preRender(ColladaTraversalContext tc, DrawContext dc)
        {
            List <ColladaRenderable> children = this.getChildren();

            if (WWUtil.isEmpty(children))
            {
                return;
            }

            Matrix matrix = this.getMatrix();

            try
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.pushMatrix();
                    tc.multiplyMatrix(matrix);
                }

                foreach (ColladaRenderable node in children)
                {
                    node.preRender(tc, dc);
                }
            }
            finally
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.popMatrix();
                }
            }
        }
Example #2
0
        public Box getLocalExtent(ColladaTraversalContext tc)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Create shapes for this node, if necessary
            if (this.shapes == null)
            {
                this.shapes = this.createShapes();
            }

            if (this.getMatrix() != null)
            {
                tc.pushMatrix();
                tc.multiplyMatrix(this.getMatrix());
            }

            ArrayList <Box> extents = new ArrayList <Box>();

            foreach (ColladaMeshShape shape in this.shapes)
            {
                Box extent = shape.getLocalExtent(tc);
                if (extent != null)
                {
                    extents.add(extent);
                }
            }

            if (this.children != null)
            {
                foreach (ColladaRenderable node in children)
                {
                    Box extent = node.getLocalExtent(tc);
                    if (extent != null)
                    {
                        extents.add(extent);
                    }
                }
            }

            if (this.getMatrix() != null)
            {
                tc.popMatrix();
            }

            if (extents.isEmpty())
            {
                return(null);
            }

            return(Box.union(extents));
        }
Example #3
0
        /** {@inheritDoc} */
        public void render(ColladaTraversalContext tc, DrawContext dc)
        {
            // Create shapes for this node, if necessary
            if (this.shapes == null)
            {
                this.shapes = this.createShapes();
            }

            Matrix matrix = this.getMatrix();

            try
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.pushMatrix();
                    tc.multiplyMatrix(matrix);
                }

                ColladaRoot root = this.getRoot();

                // Apply the current root position and highlight state to shapes in this node. Do this every frame so that
                // the node will pickup changes in the root's state.
                bool     highlighted  = root.isHighlighted();
                int      altitudeMode = root.getAltitudeMode();
                Position position     = root.getPosition();

                Matrix traversalMatrix = tc.peekMatrix();
                foreach (ColladaMeshShape shape in this.shapes)
                {
                    shape.setModelPosition(position);
                    shape.setAltitudeMode(altitudeMode);
                    shape.setHighlighted(highlighted);

                    shape.render(dc, traversalMatrix);
                }

                foreach (ColladaRenderable node in this.getChildren())
                {
                    node.render(tc, dc);
                }
            }
            finally
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.popMatrix();
                }
            }
        }