示例#1
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();
                }
            }
        }
示例#2
0
        /**
         * Create shapes for a geometry.
         *
         * @param geomInstance Geometry for which to create shapes.
         * @param shapes       List to collect the new shapes.
         */
        protected void createShapesForGeometry(ColladaInstanceGeometry geomInstance, List <ColladaMeshShape> shapes)
        {
            ColladaGeometry geometry = geomInstance.get();

            if (geometry == null)
            {
                return;
            }

            ColladaMesh mesh = geometry.getMesh();

            if (mesh == null)
            {
                return;
            }

            ColladaBindMaterial bindMaterial = geomInstance.getBindMaterial();
            ColladaRoot         root         = this.getRoot();

            List <ColladaTriangles> triangles = mesh.getTriangles();

            if (!WWUtil.isEmpty(triangles))
            {
                ColladaMeshShape newShape = ColladaMeshShape.createTriangleMesh(triangles, bindMaterial);
                newShape.setDelegateOwner(root);

                shapes.add(newShape);
            }

            List <ColladaLines> lines = mesh.getLines();

            if (!WWUtil.isEmpty(lines))
            {
                ColladaMeshShape newShape = ColladaMeshShape.createLineMesh(lines, bindMaterial);
                newShape.setDelegateOwner(root);

                shapes.add(newShape);
            }
        }