Class ColladaMeshShape

    • Field Detail

      • elementType

        protected int elementType
        OpenGL element type for this shape (GL.GL_LINES or GL.GL_TRIANGLES).
      • vertsPerShape

        protected int vertsPerShape
        Number of vertices per shape. Two in the case of a line mesh, three in the case of a triangle mesh.
      • shapeCount

        protected int shapeCount
        Total number of shapes (lines or triangles) in this mesh. Equal to the sum of the shapes in each geometry.
      • geometries

        protected java.util.List<ColladaMeshShape.Geometry> geometries
        Geometry objects that describe different parts of the mesh.
      • coordBuffer

        protected java.nio.FloatBuffer coordBuffer
        The vertex data buffer for this shape data. The first part contains vertex coordinates, the second part contains normals, and the third part contains texture coordinates.
      • normalBuffer

        protected java.nio.FloatBuffer normalBuffer
        The slice of the coordBuffer that contains normals.
      • normalBufferPosition

        protected int normalBufferPosition
        The index of the first normal in the coordBuffer.
      • textureCoordsBuffer

        protected java.nio.FloatBuffer textureCoordsBuffer
        Texture coordinates for all geometries in this shape.
      • texCoordBufferPosition

        protected int texCoordBufferPosition
        The index of the first texture coordinate in the coordBuffer.
    • Constructor Detail

      • ColladaMeshShape

        protected ColladaMeshShape​(java.util.List<? extends ColladaAbstractGeometry> geometries)
        Create an instance of the shape.
        Parameters:
        geometries - Geometries to render. All geometries must be of the same type (either ColladaTriangles or ColladaLines.
    • Method Detail

      • createTriangleMesh

        public static ColladaMeshShape createTriangleMesh​(java.util.List<ColladaTriangles> geometries,
                                                          ColladaBindMaterial bindMaterial)
        Create a triangle mesh shape.
        Parameters:
        geometries - COLLADA elements that defines geometry for this shape. Must contain at least one element.
        bindMaterial - Material applied to the mesh. May be null.
        Returns:
        The resulting shape.
      • createLineMesh

        public static ColladaMeshShape createLineMesh​(java.util.List<ColladaLines> geometries,
                                                      ColladaBindMaterial bindMaterial)
        Create a line mesh shape.
        Parameters:
        geometries - COLLADA elements that defines geometry for this shape. Must contain at least one element.
        bindMaterial - Material applied to the mesh. May be null.
        Returns:
        The resulting shape.
      • intersect

        public java.util.List<Intersection> intersect​(Line line,
                                                      Terrain terrain)
                                               throws java.lang.InterruptedException
        Compute the intersections of a specified line with this shape. If the shape's altitude mode is other than WorldWind.ABSOLUTE, the shape's geometry is created relative to the specified terrain rather than the terrain used during rendering, which may be at lower level of detail than required for accurate intersection determination.

        COLLADA shapes do not support intersection tests because the shape may be rendered multiple times with different transform matrices. It's not possible to determine intersection without the transform matrix applied when the shape is rendered.

        Specified by:
        intersect in class AbstractShape
        Parameters:
        line - the line to intersect.
        terrain - the Terrain to use when computing the shape's geometry.
        Returns:
        Always returns null.
        Throws:
        java.lang.InterruptedException - if the operation is interrupted.
        See Also:
        Terrain
      • setModelPosition

        public void setModelPosition​(Position modelPosition)
        Specifies this shape's geographic position. The position's altitude is relative to this shape's altitude mode. Overridden to invalidate cached geometry when the model position is changed.
        Overrides:
        setModelPosition in class AbstractGeneralShape
        Parameters:
        modelPosition - this shape's geographic position.
      • beginDrawing

        protected OGLStackHandler beginDrawing​(DrawContext dc,
                                               int attrMask)
        Description copied from class: AbstractShape
        Establish the OpenGL state needed to draw this shape.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Overrides:
        beginDrawing in class AbstractShape
        Parameters:
        dc - the current draw context.
        attrMask - an attribute mask indicating state the caller will set. This base class implementation sets GL_CURRENT_BIT, GL_LINE_BIT, GL_HINT_BIT, GL_POLYGON_BIT, GL_COLOR_BUFFER_BIT, and GL_TRANSFORM_BIT.
        Returns:
        the stack handler used to set the OpenGL state. Callers should use this to set additional state, especially state indicated in the attribute mask argument.
      • render

        public void render​(DrawContext dc,
                           Matrix matrix)
        Render the mesh in a given orientation.
        Parameters:
        dc - Current draw context.
        matrix - Matrix to be multiply with the current modelview matrix to orient the mesh.
      • pick

        public void pick​(DrawContext dc,
                         java.awt.Point pickPoint,
                         Matrix matrix)
        Pick the mesh in a given orientation.
        Parameters:
        dc - Current draw context.
        pickPoint - Current pick point.
        matrix - Matrix to multiply with the current modelview matrix to orient the mesh.
      • drawBatched

        protected void drawBatched​(DrawContext dc)
        Draws this ordered renderable and all subsequent Path ordered renderables in the ordered renderable list. If the current pick mode is true, only shapes within the same layer are drawn as a batch.

        A AbstractShape.AbstractShapeData must be current when this method is called. Overridden because ColladaMeshShape uses OrderedMeshShape instead of adding itself to the ordered renderable queue.

        Overrides:
        drawBatched in class AbstractShape
        Parameters:
        dc - the current draw context.
      • addOrderedRenderable

        protected void addOrderedRenderable​(DrawContext dc)
        Adds this shape to the draw context's ordered renderable list. Overridden because this shape uses ColladaMeshShape.OrderedMeshShape to represent this drawn instance of the mesh in the ordered renderable queue.
        Overrides:
        addOrderedRenderable in class AbstractShape
        Parameters:
        dc - the current draw context.
      • doDrawOrderedRenderable

        protected void doDrawOrderedRenderable​(DrawContext dc,
                                               PickSupport pickCandidates,
                                               Matrix matrix)
        Draw the shape as an OrderedRenderable, using the specified transform matrix.
        Parameters:
        dc - Current draw context.
        pickCandidates - Pick candidates for this frame.
        matrix - Transform matrix to apply before trying shape. m
      • doDrawInteriorVA

        protected void doDrawInteriorVA​(DrawContext dc,
                                        ColladaMeshShape.Geometry geometry)
        Draw one geometry in the mesh interior using vertex arrays.
        Parameters:
        dc - Current draw context.
        geometry - Geometry to draw.
      • doDrawInteriorVBO

        protected void doDrawInteriorVBO​(DrawContext dc,
                                         ColladaMeshShape.Geometry geometry,
                                         int[] vboIds)
        Draw one geometry in the mesh interior using vertex buffer objects.
        Parameters:
        dc - Current draw context.
        geometry - Geometry to draw.
        vboIds - Array of vertex buffer identifiers. The first element of the array identifies the buffer that contains vertex coordinates and normal vectors.
      • setModelViewMatrix

        protected void setModelViewMatrix​(DrawContext dc)
        Called during drawing to set the modelview matrix to apply the correct position, scale and orientation for this shape.
        Parameters:
        dc - the current DrawContext
        Throws:
        java.lang.IllegalArgumentException - if draw context is null or the draw context GL is null
      • isOrderedRenderableValid

        protected boolean isOrderedRenderableValid​(DrawContext dc)
        Determines whether this shape's ordered renderable state is valid and can be rendered. Called by AbstractShape.makeOrderedRenderable(DrawContext)just prior to adding the shape to the ordered renderable list.
        Specified by:
        isOrderedRenderableValid in class AbstractShape
        Parameters:
        dc - the current draw context.
        Returns:
        true if this shape is ready to be rendered as an ordered renderable.
      • createMinimalGeometry

        protected void createMinimalGeometry​(DrawContext dc,
                                             ColladaMeshShape.ShapeData shapeData)
        Compute enough geometry to determine this shape's extent, reference point and eye distance.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Parameters:
        dc - the current draw context.
        shapeData - the current shape data for this shape.
      • createFullGeometry

        protected void createFullGeometry​(DrawContext dc)
        Create full geometry for the shape, including normals and texture coordinates.
        Parameters:
        dc - Current draw context.
      • computeExtent

        protected Extent computeExtent​(DrawContext dc)
        Compute the shape's extent, using the active orientation matrix.
        Parameters:
        dc - Current draw context.
        Returns:
        The spatial extent of the shape, or null if the extent cannot be determined.
      • createVertexCoords

        protected void createVertexCoords​(DrawContext dc)
        Create the shape's vertex coordinates. The coordinates are stored in coordBuffer.
        Parameters:
        dc - Current draw context.
      • createNormals

        protected void createNormals()
        Create this shape's vertex normals. The normals are stored in normalBuffer.
      • createTexCoords

        protected void createTexCoords()
        Create this shape's texture coordinates. The texture coordinates are stored in textureCoordsBuffer.
      • fillVBO

        protected void fillVBO​(DrawContext dc)
        Fill this shape's vertex buffer objects. If the vertex buffer object resource IDs don't yet exist, create them.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Specified by:
        fillVBO in class AbstractShape
        Parameters:
        dc - the current draw context.
      • computeReferenceCenter

        protected Vec4 computeReferenceCenter​(DrawContext dc)
        Computes this shape's reference center.
        Parameters:
        dc - the current draw context.
        Returns:
        the computed reference center, or null if it cannot be computed.
      • computeEyeDistance

        protected double computeEyeDistance​(DrawContext dc)
        Computes the minimum distance between this shape and the eye point.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Parameters:
        dc - the current draw context.
        Returns:
        the minimum distance from the shape to the eye point.
      • computeRenderMatrix

        protected Matrix computeRenderMatrix​(DrawContext dc)
        Computes the transform to use during rendering to orient the model.
        Parameters:
        dc - the current draw context
        Returns:
        the modelview transform for this shape.
      • mustApplyTexture

        protected boolean mustApplyTexture​(DrawContext dc)
        Indicates whether texture should be applied to this shape. Called during rendering to determine whether texture state should be established during preparation for interior drawing.

        Note: This method always returns false during the pick pass.

        Specified by:
        mustApplyTexture in class AbstractShape
        Parameters:
        dc - the current draw context
        Returns:
        True if any geometry in this shape includes a texture.
      • mustApplyTexture

        protected boolean mustApplyTexture​(ColladaMeshShape.Geometry geometry)
        Indicates whether or not a texture must be applied to a geometry.
        Parameters:
        geometry - Geometry to test.
        Returns:
        True if the specified geometry includes a texture.
      • getTexture

        protected WWTexture getTexture​(ColladaMeshShape.Geometry geometry)
        Indicates the texture applied to this shape.
        Parameters:
        geometry - The geometry to set the texture from.
        Returns:
        The texture that must be applied to the shape, or null if there is no texture, or the texture is not available.
      • applyMaterial

        protected void applyMaterial​(DrawContext dc,
                                     Material material)
        Apply a material to the active draw context.
        Parameters:
        dc - Current draw context.
        material - Material to apply.
      • getMaterial

        protected Material getMaterial​(ColladaMeshShape.Geometry geometry)
        Indicates the material applied to a geometry.
        Parameters:
        geometry - Geometry for which to find material.
        Returns:
        Material to apply to the geometry. If the COLLADA document does not define a material, this method return a default material.
      • getInstanceMaterial

        protected ColladaInstanceMaterial getInstanceMaterial​(ColladaMeshShape.Geometry geometry)
        Indicates the instance_material element for a geometry.
        Parameters:
        geometry - Geometry for which to find material.
        Returns:
        Material for the specified geometry, or null if the material cannot be resolved.
      • getTexCoordSemantic

        protected java.lang.String getTexCoordSemantic​(ColladaMeshShape.Geometry geometry)
        Indicates the semantic that identifies texture coordinates. This may be specified for each material using a bind_vertex_input element.
        Parameters:
        geometry - Geometry for which to find semantic.
        Returns:
        The semantic string that identifies the texture coordinates, or null if the geometry does not define the semantic.
      • getTextureSource

        protected java.lang.String getTextureSource​(ColladaAbstractGeometry geometry)
        Indicates the source (file path or URL) of the texture applied to a geometry.
        Parameters:
        geometry - Geometry for which to find texture source.
        Returns:
        The source of the texture, or null if it cannot be resolved.
      • getImageRef

        protected java.lang.String getImageRef​(ColladaEffect effect,
                                               ColladaTexture texture)
        Indicates the reference string for an image. The image reference identifies an image element in this, or another COLLADA file. For example, "#myImage".
        Parameters:
        effect - Effect that defines the texture.
        texture - Texture for which to find the image reference.
        Returns:
        The image reference, or null if it cannot be resolved.
      • getEffect

        protected ColladaEffect getEffect​(ColladaAbstractGeometry geometry)
        Indicates the effect applied to a geometry.
        Parameters:
        geometry - Geometry for which to find effect.
        Returns:
        Effect applied to the specified geometry, or null if no effect is defined, or the effect is not available.
      • isDoubleSided

        protected boolean isDoubleSided​(ColladaAbstractGeometry geometry)
        Indicates whether or not a geometry is double sided. A geometry is double sided if its effect element contains a technique for the profile "GOOGLEEARTH", and the technique includes a double_sided field. The double_sided field is not part of the COLLADA specification, but many COLLADA models packaged in KML include the element.
        Parameters:
        geometry - Geometry to test.
        Returns:
        True if the geometry is marked as double sided. Otherwise false.