private void ShapePostParsing() {
        if (!gvrRenderingDataUSEd) {
            // SHAPE node not being USEd (shared) elsewhere

            // Shape containts Text
            if (gvrTextViewSceneObject != null) {
                gvrTextViewSceneObject.setTextColor((((0xFF << 8)
                        + (int) (shaderSettings.diffuseColor[0] * 255) << 8)
                        + (int) (shaderSettings.diffuseColor[1] * 255) << 8)
                        + (int) (shaderSettings.diffuseColor[2] * 255));
                gvrTextViewSceneObject = null;
            }

            {
                // UNIVERSAL_LIGHTS

                if (!gvrMaterialUSEd) { // if GVRMaterial is NOT set by a USE statement.

                    if (meshAttachedSceneObject == null) {
                        gvrMaterial = shaderSettings.material;
                        gvrRenderData.setMaterial(gvrMaterial);
                    } else {
                        // This GVRSceneObject came with a GVRRenderData and GVRMaterial
                        // already attached.  Examples of this are Text or primitives
                        // such as the Box, Cone, Cylinder, Sphere

                        DefinedItem definedGRRenderingData = null;
                        if (gvrRenderData != null) {
                            // <Shape> node created an unused gvrRenderData
                            // Check if we had a DEF in Shape node so that we can point to
                            // the new gvrRenderData
                            for (DefinedItem definedItem : mDefinedItems) {
                                if (definedItem.getGVRRenderData() == gvrRenderData) {
                                    definedGRRenderingData = definedItem;
                                    break;
                                }
                            }
                        }
                        gvrRenderData = meshAttachedSceneObject.getRenderData();
                        // reset the DEF item to now point to the shader
                        if (definedGRRenderingData != null)
                            definedGRRenderingData.setGVRRenderData(gvrRenderData);
                        gvrMaterial = gvrRenderData.getMaterial();
                    }
                    // X3D doesn't have an ambient color so need to do color
                    // calibration tests on how to set this.
                    gvrMaterial.setVec4("diffuse_color",
                            shaderSettings.diffuseColor[0],
                            shaderSettings.diffuseColor[1],
                            shaderSettings.diffuseColor[2],
                            (1.0f - shaderSettings.getTransparency()) );
                    gvrMaterial.setVec4("specular_color",
                            shaderSettings.specularColor[0],
                            shaderSettings.specularColor[1],
                            shaderSettings.specularColor[2], 1.0f);
                    gvrMaterial.setVec4("emissive_color",
                            shaderSettings.emissiveColor[0],
                            shaderSettings.emissiveColor[1],
                            shaderSettings.emissiveColor[2], 1.0f);
                    gvrMaterial.setFloat("specular_exponent",
                            128.0f * shaderSettings.shininess);

                    if (!shaderSettings.getMaterialName().isEmpty()) {
                        DefinedItem definedItem = new DefinedItem(
                                shaderSettings.getMaterialName());
                        definedItem.setGVRMaterial(gvrMaterial);
                        mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        // of DEFined items Clones
                        // objects with USE
                    }

                    if ( shaderSettings.getMultiTexture()) {
                        if ( !shaderSettings.getMultiTextureName().isEmpty() ) {
                            DefinedItem definedItem = new DefinedItem(
                                    shaderSettings.getMultiTextureName() );
                            definedItem.setGVRMaterial(gvrMaterial);
                            mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        }
                        gvrMaterial.setTexture("diffuseTexture", shaderSettings.getMultiTextureGVRTexture(0) );
                        gvrMaterial.setTexture("diffuseTexture1", shaderSettings.getMultiTextureGVRTexture(1) );
                        // 0:Mul; 1=for ADD; 2 for SUBTRACT; 3 for DIVIDE; 4=smooth add; 5=Signed add
                        gvrMaterial.setInt("diffuseTexture1_blendop", shaderSettings.getMultiTextureMode().ordinal());
                        gvrMaterial.setTexCoord("diffuseTexture", "a_texcoord", "diffuse_coord");
                        gvrMaterial.setTexCoord("diffuseTexture1", "a_texcoord", "diffuse_coord1");

                    }
                    else if (shaderSettings.texture != null) {
                        gvrMaterial.setTexture("diffuseTexture",
                                shaderSettings.texture);
                        // if the TextureMap is a DEFined item, then set the
                        // GVRMaterial to it as well to help if we set the
                        // in a SCRIPT node.
                        for (DefinedItem definedItem: mDefinedItems) {
                            if ( definedItem.getGVRTexture() == shaderSettings.texture) {
                                definedItem.setGVRMaterial(gvrMaterial);
                                break;
                            }
                        }
                    }

                    if ( !shaderSettings.movieTextures.isEmpty()) {
                        try {
                            GVRVideoSceneObjectPlayer<?> videoSceneObjectPlayer = null;
                            try {
                                videoSceneObjectPlayer = utility.makeExoPlayer(shaderSettings.movieTextures.get(0));
                            }
                            catch (Exception e) {
                                Log.e(TAG, "Exception getting videoSceneObjectPlayer: " + e);
                            }
                            videoSceneObjectPlayer.start();

                            GVRVideoSceneObject gvrVideoSceneObject =
                                    new GVRVideoSceneObject(gvrContext, gvrRenderData.getMesh(), videoSceneObjectPlayer,
                                            GVRVideoSceneObject.GVRVideoType.MONO);
                            currentSceneObject.addChildObject(gvrVideoSceneObject);
                            // Primitives such as Box, Cone, etc come with their own mesh
                            // so we need to remove these.
                            if ( meshAttachedSceneObject != null) {
                                GVRSceneObject primitiveParent = meshAttachedSceneObject.getParent();
                                primitiveParent.removeChildObject(meshAttachedSceneObject);
                            }
                            meshAttachedSceneObject = gvrVideoSceneObject;

                            if (shaderSettings.getMovieTextureName() != null) {
                                gvrVideoSceneObject.setName(shaderSettings.getMovieTextureName());
                                DefinedItem item = new DefinedItem(shaderSettings.getMovieTextureName());
                                item.setGVRVideoSceneObject(gvrVideoSceneObject);
                                mDefinedItems.add(item);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.e(TAG, "X3D MovieTexture Exception:\n" + e);
                        }
                    }  // end MovieTexture

                    // Texture Transform
                    // If DEFined iteam, add to the DeFinedItem list. Maay be interactive
                    // GearVR may not be doing texture transforms on primitives or text
                    // crash otherwise.

                    if (meshAttachedSceneObject == null) {
                        if (!shaderSettings.getTextureTransformName().isEmpty()) {
                            DefinedItem definedItem = new DefinedItem(
                                    shaderSettings.getTextureTransformName());
                            definedItem.setGVRMaterial(gvrMaterial);
                            definedItem.setTextureTranslation(shaderSettings.getTextureTranslation());
                            definedItem.setTextureCenter(shaderSettings.getTextureCenter());
                            definedItem.setTextureScale(shaderSettings.getTextureScale());
                            definedItem.setTextureRotation(shaderSettings.getTextureRotation().getValue());
                            definedItem.setName(shaderSettings.getTextureTransformName());
                            mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        }
                        // Texture Transform Matrix equation:
                        // TC' = -C * S * R * C * T * TC
                        //where TC' is the transformed texture coordinate
                        //   TC is the original Texture Coordinate
                        //   C = center, S = scale, R = rotation, T = translation
                        Matrix3f textureTransform = animationInteractivityManager.SetTextureTransformMatrix(
                                shaderSettings.getTextureTranslation(),
                                shaderSettings.getTextureCenter(),
                                shaderSettings.getTextureScale(),
                                shaderSettings.getTextureRotation());

                        shaderSettings.textureMatrix = textureTransform;
                        float[] texMtx = new float[9];
                        shaderSettings.textureMatrix.get(texMtx);
                        gvrMaterial.setFloatArray("texture_matrix", texMtx);
                    }

                    // Appearance node thus far contains properties of GVRMaterial
                    // node
                    if (!shaderSettings.getAppearanceName().isEmpty()) {
                        DefinedItem definedItem = new DefinedItem(
                                shaderSettings.getAppearanceName());
                        definedItem.setGVRMaterial(gvrMaterial);
                        mDefinedItems.add(definedItem);
                        // Add gvrMaterial to Array list
                        // of DEFined items Clones
                        // objects with USE
                    }

                    if ((shaderSettings.getTransparency() != 0) && (shaderSettings.getTransparency() != 1)) {
                        gvrRenderData.setRenderingOrder(GVRRenderingOrder.TRANSPARENT);
                    }

                } // end ! gvrMaterialUSEd

                gvrTexture = null;
            }
        } // end !gvrRenderingDataUSEd

        if (meshAttachedSceneObject != null) {
            // gvrRenderData already attached to a GVRSceneObject such as a
            // Cone or Cylinder or a Movie Texture
            meshAttachedSceneObject = null;
        } else
            currentSceneObject.attachRenderData(gvrRenderData);

        if (lodManager.shapeLODSceneObject != null) {
            // if this Shape node was a direct child of a
            // Level-of-Detial (LOD),then restore the parent object
            // since we had to add a GVRSceneObject to support
            // the Shape node's attachement to LOD.
            currentSceneObject = currentSceneObject.getParent();
            lodManager.shapeLODSceneObject = null;
        }

        gvrMaterialUSEd = false; // for DEFine and USE, true if we encounter a
        // USE
        gvrRenderingDataUSEd = false; // for DEFine and USE gvrRenderingData for
        // x3d SHAPE node
        gvrRenderData = null;

    }
private void ShapePostParsing ( ) { if ( ! gvrRenderingDataUSEd ) { if ( gvrTextViewSceneObject != null ) { gvrTextViewSceneObject . setTextColor ( ( ( ( 0xFF << 8 ) + ( int ) ( shaderSettings . diffuseColor [ 0 ] * 255 ) << 8 ) + ( int ) ( shaderSettings . diffuseColor [ 1 ] * 255 ) << 8 ) + ( int ) ( shaderSettings . diffuseColor [ 2 ] * 255 ) ) ; gvrTextViewSceneObject = null ; } { if ( ! gvrMaterialUSEd ) { if ( meshAttachedSceneObject == null ) { gvrMaterial = shaderSettings . material ; gvrRenderData . setMaterial ( gvrMaterial ) ; } else { DefinedItem definedGRRenderingData = null ; if ( gvrRenderData != null ) { for ( DefinedItem definedItem : mDefinedItems ) { if ( definedItem . getGVRRenderData ( ) == gvrRenderData ) { definedGRRenderingData = definedItem ; break ; } } } gvrRenderData = meshAttachedSceneObject . getRenderData ( ) ; if ( definedGRRenderingData != null ) definedGRRenderingData . setGVRRenderData ( gvrRenderData ) ; gvrMaterial = gvrRenderData . getMaterial ( ) ; } gvrMaterial . setVec4 ( "diffuse_color" , shaderSettings . diffuseColor [ 0 ] , shaderSettings . diffuseColor [ 1 ] , shaderSettings . diffuseColor [ 2 ] , ( 1.0f - shaderSettings . getTransparency ( ) ) ) ; gvrMaterial . setVec4 ( "specular_color" , shaderSettings . specularColor [ 0 ] , shaderSettings . specularColor [ 1 ] , shaderSettings . specularColor [ 2 ] , 1.0f ) ; gvrMaterial . setVec4 ( "emissive_color" , shaderSettings . emissiveColor [ 0 ] , shaderSettings . emissiveColor [ 1 ] , shaderSettings . emissiveColor [ 2 ] , 1.0f ) ; gvrMaterial . setFloat ( "specular_exponent" , 128.0f * shaderSettings . shininess ) ; if ( ! shaderSettings . getMaterialName ( ) . isEmpty ( ) ) { DefinedItem definedItem = new DefinedItem ( shaderSettings . getMaterialName ( ) ) ; definedItem . setGVRMaterial ( gvrMaterial ) ; mDefinedItems . add ( definedItem ) ; } if ( shaderSettings . getMultiTexture ( ) ) { if ( ! shaderSettings . getMultiTextureName ( ) . isEmpty ( ) ) { DefinedItem definedItem = new DefinedItem ( shaderSettings . getMultiTextureName ( ) ) ; definedItem . setGVRMaterial ( gvrMaterial ) ; mDefinedItems . add ( definedItem ) ; } gvrMaterial . setTexture ( "diffuseTexture" , shaderSettings . getMultiTextureGVRTexture ( 0 ) ) ; gvrMaterial . setTexture ( "diffuseTexture1" , shaderSettings . getMultiTextureGVRTexture ( 1 ) ) ; gvrMaterial . setInt ( "diffuseTexture1_blendop" , shaderSettings . getMultiTextureMode ( ) . ordinal ( ) ) ; gvrMaterial . setTexCoord ( "diffuseTexture" , "a_texcoord" , "diffuse_coord" ) ; gvrMaterial . setTexCoord ( "diffuseTexture1" , "a_texcoord" , "diffuse_coord1" ) ; } else if ( shaderSettings . texture != null ) { gvrMaterial . setTexture ( "diffuseTexture" , shaderSettings . texture ) ; for ( DefinedItem definedItem : mDefinedItems ) { if ( definedItem . getGVRTexture ( ) == shaderSettings . texture ) { definedItem . setGVRMaterial ( gvrMaterial ) ; break ; } } } if ( ! shaderSettings . movieTextures . isEmpty ( ) ) { try { GVRVideoSceneObjectPlayer < ? > videoSceneObjectPlayer = null ; try { videoSceneObjectPlayer = utility . makeExoPlayer ( shaderSettings . movieTextures . get ( 0 ) ) ; } catch ( Exception e ) { Log . e ( TAG , "Exception getting videoSceneObjectPlayer: " + e ) ; } videoSceneObjectPlayer . start ( ) ; GVRVideoSceneObject gvrVideoSceneObject = new GVRVideoSceneObject ( gvrContext , gvrRenderData . getMesh ( ) , videoSceneObjectPlayer , GVRVideoSceneObject . GVRVideoType . MONO ) ; currentSceneObject . addChildObject ( gvrVideoSceneObject ) ; if ( meshAttachedSceneObject != null ) { GVRSceneObject primitiveParent = meshAttachedSceneObject . getParent ( ) ; primitiveParent . removeChildObject ( meshAttachedSceneObject ) ; } meshAttachedSceneObject = gvrVideoSceneObject ; if ( shaderSettings . getMovieTextureName ( ) != null ) { gvrVideoSceneObject . setName ( shaderSettings . getMovieTextureName ( ) ) ; DefinedItem item = new DefinedItem ( shaderSettings . getMovieTextureName ( ) ) ; item . setGVRVideoSceneObject ( gvrVideoSceneObject ) ; mDefinedItems . add ( item ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; Log . e ( TAG , "X3D MovieTexture Exception:\n" + e ) ; } } if ( meshAttachedSceneObject == null ) { if ( ! shaderSettings . getTextureTransformName ( ) . isEmpty ( ) ) { DefinedItem definedItem = new DefinedItem ( shaderSettings . getTextureTransformName ( ) ) ; definedItem . setGVRMaterial ( gvrMaterial ) ; definedItem . setTextureTranslation ( shaderSettings . getTextureTranslation ( ) ) ; definedItem . setTextureCenter ( shaderSettings . getTextureCenter ( ) ) ; definedItem . setTextureScale ( shaderSettings . getTextureScale ( ) ) ; definedItem . setTextureRotation ( shaderSettings . getTextureRotation ( ) . getValue ( ) ) ; definedItem . setName ( shaderSettings . getTextureTransformName ( ) ) ; mDefinedItems . add ( definedItem ) ; } Matrix3f textureTransform = animationInteractivityManager . SetTextureTransformMatrix ( shaderSettings . getTextureTranslation ( ) , shaderSettings . getTextureCenter ( ) , shaderSettings . getTextureScale ( ) , shaderSettings . getTextureRotation ( ) ) ; shaderSettings . textureMatrix = textureTransform ; float [ ] texMtx = new float [ 9 ] ; shaderSettings . textureMatrix . get ( texMtx ) ; gvrMaterial . setFloatArray ( "texture_matrix" , texMtx ) ; } if ( ! shaderSettings . getAppearanceName ( ) . isEmpty ( ) ) { DefinedItem definedItem = new DefinedItem ( shaderSettings . getAppearanceName ( ) ) ; definedItem . setGVRMaterial ( gvrMaterial ) ; mDefinedItems . add ( definedItem ) ; } if ( ( shaderSettings . getTransparency ( ) != 0 ) && ( shaderSettings . getTransparency ( ) != 1 ) ) { gvrRenderData . setRenderingOrder ( GVRRenderingOrder . TRANSPARENT ) ; } } gvrTexture = null ; } } if ( meshAttachedSceneObject != null ) { meshAttachedSceneObject = null ; } else currentSceneObject . attachRenderData ( gvrRenderData ) ; if ( lodManager . shapeLODSceneObject != null ) { currentSceneObject = currentSceneObject . getParent ( ) ; lodManager . shapeLODSceneObject = null ; } gvrMaterialUSEd = false ; gvrRenderingDataUSEd = false ; gvrRenderData = null ; }
Called after parsing </Shape>