コード例 #1
0
        public static void PlaceTextureOnFace(Face face, ImageBuffer textureToUse)
        {
            FaceTextureData faceData = FaceTextureData.Get(face);

            faceData.Textures.Add(textureToUse);
            int count = 0;

            foreach (FaceEdge faceEdge in face.FaceEdges())
            {
                FaceEdgeTextureUvData edgeUV = FaceEdgeTextureUvData.Get(faceEdge);
                switch (count++)
                {
                case 0:
                    edgeUV.TextureUV.Add(new Vector2(0, 0));
                    break;

                case 1:
                    edgeUV.TextureUV.Add(new Vector2(1, 0));
                    break;

                case 2:
                    edgeUV.TextureUV.Add(new Vector2(1, 1));
                    break;

                case 3:
                    edgeUV.TextureUV.Add(new Vector2(0, 1));
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Face.cs プロジェクト: asmboom/PixelFarm
        public ImageBuffer GetTexture(int index)
        {
            FaceTextureData faceData = FaceTextureData.Get(this);

            if (faceData != null && index < faceData.Textures.Count)
            {
                return(faceData.Textures[index]);
            }

            return(null);
        }
コード例 #3
0
		static public FaceTextureData Get(Face faceToGetTextureDataFor)
		{
			FaceTextureData plugin;
			facesWithTextureData.TryGetValue(faceToGetTextureDataFor, out plugin);

			if (plugin == null)
			{
				FaceTextureData newPlugin = new FaceTextureData();
				facesWithTextureData.Add(faceToGetTextureDataFor, newPlugin);

				return newPlugin;
			}

			return plugin;
		}
コード例 #4
0
ファイル: FaceTexturesData.cs プロジェクト: asmboom/PixelFarm
        static public FaceTextureData Get(Face faceToGetTextureDataFor)
        {
            FaceTextureData plugin;

            facesWithTextureData.TryGetValue(faceToGetTextureDataFor, out plugin);

            if (plugin == null)
            {
                FaceTextureData newPlugin = new FaceTextureData();
                facesWithTextureData.Add(faceToGetTextureDataFor, newPlugin);

                return(newPlugin);
            }

            return(plugin);
        }
コード例 #5
0
        public static void PlaceTextureOnFace(this Mesh mesh, int face, ImageBuffer textureToUse, Matrix4X4 textureCoordinateMapping)
        {
            var faceTextures = new Dictionary <int, FaceTextureData>(mesh.FaceTextures);

            var uvs     = new Vector2Float[3];
            int uvIndex = 0;

            foreach (int vertexIndex in new int[] { mesh.Faces[face].v0, mesh.Faces[face].v1, mesh.Faces[face].v2 })
            {
                var edgeStartPosition = mesh.Vertices[vertexIndex];
                var textureUv         = edgeStartPosition.Transform(textureCoordinateMapping);
                uvs[uvIndex++] = new Vector2Float(textureUv);
            }

            faceTextures[face] = new FaceTextureData(textureToUse, uvs[0], uvs[1], uvs[2]);

            mesh.FaceTextures = faceTextures;

            mesh.MarkAsChanged();
        }