Exemple #1
0
        private SSMeshOBJSubsetData _loadMaterialSubset(SSAssetManager.Context ctx, WavefrontObjLoader wff,
                                                        WavefrontObjLoader.MaterialInfoWithFaces objMatSubset)
        {
            // generate renderable geometry data...
            SSVertex_PosNormTexDiff[] vertices;
            UInt16[] triIndices, wireframeIndices;
            VertexSoup_VertexFormatBinder.generateDrawIndexBuffer(
                wff, out triIndices, out vertices);
            wireframeIndices = OpenTKHelper.generateLineIndicies(triIndices);
            SSMeshOBJSubsetData subsetData = new SSMeshOBJSubsetData(
                vertices, triIndices, wireframeIndices);

            // setup the material...
            // load and link every texture present
            subsetData.TextureMaterial = new SSTextureMaterial();
            if (objMatSubset.mtl.diffuseTextureResourceName != null)
            {
                subsetData.TextureMaterial.diffuseTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.diffuseTextureResourceName);
            }
            if (objMatSubset.mtl.ambientTextureResourceName != null)
            {
                subsetData.TextureMaterial.ambientTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.ambientTextureResourceName);
            }
            if (objMatSubset.mtl.bumpTextureResourceName != null)
            {
                subsetData.TextureMaterial.bumpMapTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.bumpTextureResourceName);
            }
            if (objMatSubset.mtl.specularTextureResourceName != null)
            {
                subsetData.TextureMaterial.specularTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.specularTextureResourceName);
            }
            return(subsetData);
        }
Exemple #2
0
        private SSMeshOBJSubsetData _loadMaterialSubset(string baseDirectory, WavefrontObjLoader wff,
                                                        WavefrontObjLoader.MaterialInfoWithFaces objMatSubset)
        {
            // generate renderable geometry data...
            SSVertex_PosNormTex[] vertices;
            UInt16[] triIndices, wireframeIndices;
            VertexSoup_VertexFormatBinder.generateDrawIndexBuffer(
                wff, objMatSubset, out triIndices, out vertices);
            wireframeIndices = OpenTKHelper.generateLineIndicies(triIndices);
            SSMeshOBJSubsetData subsetData = new SSMeshOBJSubsetData(
                vertices, triIndices, wireframeIndices);

            // setup the material...
            // load and link every texture present
            subsetData.textureMaterial = SSTextureMaterial.FromBlenderMtl(baseDirectory, objMatSubset.mtl);
            subsetData.colorMaterial   = SSColorMaterial.fromMtl(objMatSubset.mtl);
            return(subsetData);
        }
        private SSMeshOBJSubsetData _loadMaterialSubset(SSAssetManager.Context ctx, WavefrontObjLoader wff,
                                                        WavefrontObjLoader.MaterialInfoWithFaces objMatSubset)
        {
            // create new mesh subset-data
            SSMeshOBJSubsetData subsetData = new SSMeshOBJSubsetData();

            // setup the material...

            // load and link every texture present
            subsetData.TextureMaterial = new SSTextureMaterial();
            if (objMatSubset.mtl.diffuseTextureResourceName != null)
            {
                subsetData.TextureMaterial.diffuseTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.diffuseTextureResourceName);
            }
            if (objMatSubset.mtl.ambientTextureResourceName != null)
            {
                subsetData.TextureMaterial.ambientTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.ambientTextureResourceName);
            }
            if (objMatSubset.mtl.bumpTextureResourceName != null)
            {
                subsetData.TextureMaterial.bumpMapTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.bumpTextureResourceName);
            }
            if (objMatSubset.mtl.specularTextureResourceName != null)
            {
                subsetData.TextureMaterial.specularTex = SSAssetManager.GetInstance <SSTexture>(ctx, objMatSubset.mtl.specularTextureResourceName);
            }

            // generate renderable geometry data...
            VertexSoup_VertexFormatBinder.generateDrawIndexBuffer(wff, out subsetData.indicies, out subsetData.vertices);

            // TODO: setup VBO/IBO buffers
            // http://www.opentk.com/doc/graphics/geometry/vertex-buffer-objects

            subsetData.wireframe_indicies = OpenTKHelper.generateLineIndicies(subsetData.indicies);

            subsetData.vbo           = new SSVertexBuffer <SSVertex_PosNormTexDiff>(subsetData.vertices);
            subsetData.ibo           = new SSIndexBuffer(subsetData.indicies, subsetData.vbo);
            subsetData.ibo_wireframe = new SSIndexBuffer(subsetData.wireframe_indicies, subsetData.vbo);

            return(subsetData);
        }