Пример #1
0
        public Software.Meshes.IndexedPlane GetPlane(Vector2 textureSize)
        {
            Software.Meshes.IndexedPlane plane = new Graphics.Software.Meshes.IndexedPlane();
            if (SizeMode == SizeMode.Fixed)
            {
                plane.Size = Size;
            }
            else
            {
                plane.Size = textureSize;
            }

            var sourceTextureAreaSize = new Vector2(
                textureSize.X * (TextureUVMax.X - TextureUVMin.X),
                textureSize.Y * (TextureUVMax.Y - TextureUVMin.Y));

            var sourceAreaPosMin = OrientationUtil.Position(TextureAnchor, sourceTextureAreaSize,
                                                            Vector2.Zero, plane.Size);
            var sourceAreaPosMax = sourceAreaPosMin + plane.Size;

            var texturePosMin = sourceAreaPosMin + new Vector2(
                TextureUVMin.X * textureSize.X,
                TextureUVMin.Y * textureSize.Y
                );

            var texturePosMax = sourceAreaPosMax + new Vector2(
                TextureUVMin.X * textureSize.X,
                TextureUVMin.Y * textureSize.Y
                );

            plane.UVMin = new Vector2(texturePosMin.X / textureSize.X, texturePosMin.Y / textureSize.Y);
            plane.UVMax = new Vector2(texturePosMax.X / textureSize.X, texturePosMax.Y / textureSize.Y);
            return(plane);
        }
Пример #2
0
            public override Model9 Construct(StretchingImageGraphic metaResource, ContentPool content)
            {
                Model9 m = new Model9();

                m.Texture = content.Acquire <SlimDX.Direct3D9.Texture>(metaResource.Texture);
                Software.Meshes.IndexedPlane plane = new Graphics.Software.Meshes.IndexedPlane();
                plane.Size     = metaResource.Size - metaResource.BorderSize * 2;
                plane.Position = Common.Math.ToVector3(metaResource.BorderSize);
                plane.UVMin    = metaResource.TextureUVMin;
                plane.UVMax    = metaResource.TextureUVMax;
                m.Mesh         = content.Acquire <Mesh9>(new MeshConcretize
                {
                    MeshDescription = plane,
                    Layout          = Software.Vertex.PositionTexcoord.Instance
                });
                return(m);
            }