Beispiel #1
0
        /// <summary>
        /// Calculate texture coordinates with face texturemapping values
        /// </summary>
        /// <param name="face"></param>
        /// <param name="minimiseShiftValues"></param>
        public void CalculateTextureCoordinatesForFace(SolidFace face, bool minimiseShiftValues = false)
        {
            if (face.TextureMapping.TextureLocked)
            {
                return;
            }

            TextureMapping mapping = face.TextureMapping;

            foreach (SolidIndex vertexIndex in face.Indices)
            {
                Vector3 position = VertexPositions[vertexIndex.Index];
                double  u        = (Vector3.Dot(position, mapping.UAxis) / mapping.UScale - mapping.UShift) /
                                   face.Texture.Width;
                double v = (Vector3.Dot(position, mapping.VAxis) / mapping.VScale + mapping.VShift) /
                           face.Texture.Height;

                vertexIndex.DiffuseUv = new Vector2((float)u, (float)v);
            }

            if (minimiseShiftValues)
            {
                MinimiseTextureShiftValuesForFace(face);
            }
        }
Beispiel #2
0
 public SolidFace()
 {
     Indices                      = new List <SolidIndex>();
     TextureMapping               = new TextureMapping();
     TextureMapping.UScale        = TextureMapping.VScale = (float)TextureMapping.DefaultScaleValue;
     TextureMapping.UShift        = TextureMapping.VShift = (float)TextureMapping.DefaultShiftValue;
     TextureMapping.Rotation      = (float)TextureMapping.DefaultRotationValue;
     TextureMapping.TextureLocked = TextureMapping.DefaultTextureLockValue;
 }