示例#1
0
        private void Create3DDataForLayer(int layerIndex,
                                          VectorPOD <ColorVertexData> colorVertexData,
                                          VectorPOD <int> vertexIndexArray,
                                          GCodeRenderInfo renderInfo)
        {
            colorVertexData.Clear();
            vertexIndexArray.Clear();
            featureStartIndex[layerIndex].Clear();
            featureEndIndex[layerIndex].Clear();

            for (int i = 0; i < renderFeatures[layerIndex].Count; i++)
            {
                featureStartIndex[layerIndex].Add(vertexIndexArray.Count);
                RenderFeatureBase feature = renderFeatures[layerIndex][i];
                if (feature != null)
                {
                    feature.CreateRender3DData(colorVertexData, vertexIndexArray, renderInfo);
                }
                featureEndIndex[layerIndex].Add(vertexIndexArray.Count);
            }
        }
示例#2
0
		private void Create3DDataForLayer(int layerIndex,
			VectorPOD<ColorVertexData> colorVertexData,
			VectorPOD<int> vertexIndexArray,
			GCodeRenderInfo renderInfo)
		{
			colorVertexData.Clear();
			vertexIndexArray.Clear();
			featureStartIndex[layerIndex].Clear();
			featureEndIndex[layerIndex].Clear();

			for (int i = 0; i < renderFeatures[layerIndex].Count; i++)
			{
				featureStartIndex[layerIndex].Add(vertexIndexArray.Count);
				RenderFeatureBase feature = renderFeatures[layerIndex][i];
				if (feature != null)
				{
					feature.CreateRender3DData(colorVertexData, vertexIndexArray, renderInfo);
				}
				featureEndIndex[layerIndex].Add(vertexIndexArray.Count);
			}
		}
示例#3
0
        private void CreateRenderData(Mesh meshToBuildListFor)
        {
            subMeshs = new List<SubTriangleMesh>();
            SubTriangleMesh currentSubMesh = null;
            VectorPOD<TriangleVertexData> vertexDatas = new VectorPOD<TriangleVertexData>();
            // first make sure all the textures are created
            foreach (Face face in meshToBuildListFor.Faces)
            {
                ImageBuffer faceTexture = face.GetTexture(0);
                if (faceTexture != null)
                {
                    ImageGlPlugin.GetImageGlPlugin(faceTexture, true);
                }

                // don't compare the data of the texture but rather if they are just the same object
                if (subMeshs.Count == 0 || (object)subMeshs[subMeshs.Count - 1].texture != (object)faceTexture)
                {
                    SubTriangleMesh newSubMesh = new SubTriangleMesh();
                    newSubMesh.texture = faceTexture;
                    subMeshs.Add(newSubMesh);

#if USE_VBO
                    if (currentSubMesh != null)
                    {
                        CreateVBOForSubMesh(vertexDatas, currentSubMesh);
                        vertexDatas.Clear();
                    }
                    currentSubMesh = subMeshs[subMeshs.Count - 1];
#else
                    currentSubMesh = subMeshs[subMeshs.Count - 1];
                    vertexDatas = currentSubMesh.vertexDatas;
#endif
                }

                Vector2[] textureUV = new Vector2[2];
                Vector3[] position = new Vector3[2];
                int vertexIndex = 0;
                foreach (FaceEdge faceEdge in face.FaceEdges())
                {
                    if (vertexIndex < 2)
                    {
                        textureUV[vertexIndex] = faceEdge.GetUVs(0);
                        position[vertexIndex] = faceEdge.firstVertex.Position;
                    }
                    else
                    {
                        TriangleVertexData tempVertex;
                        tempVertex.textureU = (float)textureUV[0].x; tempVertex.textureV = (float)textureUV[0].y;
                        tempVertex.positionsX = (float)position[0].x; tempVertex.positionsY = (float)position[0].y; tempVertex.positionsZ = (float)position[0].z;
                        tempVertex.normalsX = (float)face.normal.x; tempVertex.normalsY = (float)face.normal.y; tempVertex.normalsZ = (float)face.normal.z;
                        vertexDatas.Add(tempVertex);

                        tempVertex.textureU = (float)textureUV[1].x; tempVertex.textureV = (float)textureUV[1].y;
                        tempVertex.positionsX = (float)position[1].x; tempVertex.positionsY = (float)position[1].y; tempVertex.positionsZ = (float)position[1].z;
                        tempVertex.normalsX = (float)face.normal.x; tempVertex.normalsY = (float)face.normal.y; tempVertex.normalsZ = (float)face.normal.z;
                        vertexDatas.Add(tempVertex);

                        Vector2 textureUV2 = faceEdge.GetUVs(0);
                        Vector3 position2 = faceEdge.firstVertex.Position;
                        tempVertex.textureU = (float)textureUV2.x; tempVertex.textureV = (float)textureUV2.y;
                        tempVertex.positionsX = (float)position2.x; tempVertex.positionsY = (float)position2.y; tempVertex.positionsZ = (float)position2.z;
                        tempVertex.normalsX = (float)face.normal.x; tempVertex.normalsY = (float)face.normal.y; tempVertex.normalsZ = (float)face.normal.z;
                        vertexDatas.Add(tempVertex);

                        textureUV[1] = faceEdge.GetUVs(0);
                        position[1] = faceEdge.firstVertex.Position;
                    }

                    vertexIndex++;
                }
            }

            CreateVBOForSubMesh(vertexDatas, currentSubMesh);
        }