Пример #1
0
        public float distance2To(UVCoord other)
        {
            float dx = u - other.u;
            float dy = v - other.v;

            return(dx * dx + dy * dy);
        }
Пример #2
0
        public static bool Clockwise(UVCoord A, UVCoord B, UVCoord C)
        {
            UVCoord A2B = B - A;
            UVCoord B2C = C - B;

            if (Cross(A2B, B2C) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public BSEffectShaderProperty()
 {
     this.shaderFlags1 = 0U;
     this.shaderFlags2 = 0U;
     this.uvOffset = new UVCoord(0.0f, 0.0f);
     this.uvScale = new UVCoord(1f, 1f);
     this.sourceTexture = "";
     this.textureClampMode = 0U;
     this.falloffStartAngle = 0.0f;
     this.falloffStopAngle = 0.0f;
     this.falloffStartOpacity = 1f;
     this.falloffStopOpacity = 1f;
     this.emissiveColor = new Color4(0.0f, 0.0f, 0.0f, 0.0f);
     this.emissiveMultiple = 1f;
     this.softFalloffDepth = 0.0f;
     this.greyscaleTexture = "";
 }
 public BSLightingShaderProperty()
 {
     this.shaderType = 0U;
     this.shaderFlags1 = 2185233152U;
     this.shaderFlags2 = 32801U;
     this.uvOffset = new UVCoord(0.0f, 0.0f);
     this.uvScale = new UVCoord(1f, 1f);
     this.textureSet = -1;
     this.emissiveColor = new Color3(0.0f, 0.0f, 0.0f);
     this.emissiveMultiplier = 1f;
     this.textureClampMode = 3U;
     this.alpha = 1f;
     this.unknownFloat2 = 0.0f;
     this.glossiness = 80f;
     this.specularColor = new Color3(1f, 1f, 1f);
     this.specularStrength = 1f;
     this.lightingEffect1 = 0.3f;
     this.lightingEffect2 = 2f;
 }
Пример #5
0
        public static bool PointInTriangle(UVCoord p, UVCoord t1, UVCoord t2, UVCoord t3, out float u, out float v)
        {
            UVCoord vector2_1 = t3 - t1;
            UVCoord vector2_2 = t2 - t1;
            UVCoord B         = p - t1;
            float   num1      = UVCoord.Dot(vector2_1, vector2_1);
            float   num2      = UVCoord.Dot(vector2_1, vector2_2);
            float   num3      = UVCoord.Dot(vector2_1, B);
            float   num4      = UVCoord.Dot(vector2_2, vector2_2);
            float   num5      = UVCoord.Dot(vector2_2, B);
            float   num6      = (float)(1.0 / ((double)num1 * (double)num4 - (double)num2 * (double)num2));

            u = (float)((double)num4 * (double)num3 - (double)num2 * (double)num5) * num6;
            v = (float)((double)num1 * (double)num5 - (double)num2 * (double)num3) * num6;
            if ((double)u >= 0.0 && (double)v >= 0.0)
            {
                return((double)u + (double)v <= 1);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
 public BSVertexData()
 {
     this.vertex         = new Vector3(0.0f, 0.0f, 0.0f);
     this.bitangentX     = 0.0f;
     this.unknownShort1  = 0;
     this.unknownInt1    = 0;
     this.uvcoords       = new UVCoord(0.0f, 0.0f);
     this.normal         = new Vector3(0.0f, 0.0f, 0.0f);
     this.bitangentY     = 0.0f;
     this.tangent        = new Vector3(0.0f, 0.0f, 0.0f);
     this.bitangentZ     = 0.0f;
     this.vertexColors   = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
     this.boneWeights    = new float[4];
     this.boneWeights[0] = 0.0f;
     this.boneWeights[1] = 0.0f;
     this.boneWeights[2] = 0.0f;
     this.boneWeights[3] = 0.0f;
     this.boneIndices    = new byte[4];
     this.boneIndices[0] = 0;
     this.boneIndices[1] = 0;
     this.boneIndices[2] = 0;
     this.boneIndices[3] = 0;
     this.unknownInt2    = 0;
 }
Пример #7
0
 public static float Circumference(UVCoord a, UVCoord b, UVCoord c)
 {
     return(a.distanceTo(b) + b.distanceTo(c) + c.distanceTo(a));
 }
Пример #8
0
 public float distanceTo(UVCoord other)
 {
     return((float)Math.Sqrt(distance2To(other)));
 }
Пример #9
0
 public static float SignedArea(UVCoord a, UVCoord b, UVCoord c)
 {
     return(((a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1])) * 0.5f);
 }
Пример #10
0
 public static float Area(UVCoord a, UVCoord b, UVCoord c)
 {
     return((float)Math.Abs((a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1])) * 0.5f);
 }
 public void SetUVScale(UVCoord value)
 {
     this.uvScale = value;
 }
 public void SetUVOffset(UVCoord value)
 {
     this.uvOffset = value;
 }
 public override void Read(NiHeader header, BinaryReader reader)
 {
     this.shaderType = reader.ReadUInt32();
     base.Read(header, reader);
     this.shaderFlags1 = reader.ReadUInt32();
     this.shaderFlags2 = reader.ReadUInt32();
     this.uvOffset = Utils.ReadUVCoord(reader);
     this.uvScale = Utils.ReadUVCoord(reader);
     this.textureSet = reader.ReadInt32();
     this.emissiveColor = Utils.ReadColor3(reader);
     this.emissiveMultiplier = reader.ReadSingle();
     this.textureClampMode = reader.ReadUInt32();
     this.alpha = reader.ReadSingle();
     this.unknownFloat2 = reader.ReadSingle();
     this.glossiness = reader.ReadSingle();
     this.specularColor = Utils.ReadColor3(reader);
     this.specularStrength = reader.ReadSingle();
     this.lightingEffect1 = reader.ReadSingle();
     this.lightingEffect2 = reader.ReadSingle();
     if ((int)this.shaderType == 1)
         this.environmentMapScale = reader.ReadSingle();
     else if ((int)this.shaderType == 5)
         this.skinTintColor = Utils.ReadColor3(reader);
     else if ((int)this.shaderType == 6)
         this.hairTintColor = Utils.ReadColor3(reader);
     else if ((int)this.shaderType == 7)
     {
         this.maxPasses = reader.ReadSingle();
         this.scale = reader.ReadSingle();
     }
     else if ((int)this.shaderType == 11)
     {
         this.parallaxInnerLayerThickness = reader.ReadSingle();
         this.parallaxRefractionScale = reader.ReadSingle();
         this.parallaxInnerLayerTextureScale = Utils.ReadUVCoord(reader);
         this.parallaxEnvmapStrength = reader.ReadSingle();
     }
     else if ((int)this.shaderType == 14)
     {
         this.sparkleParameters = Utils.ReadVector4(reader);
     }
     else
     {
         if ((int)this.shaderType != 16)
             return;
         this.eyeCubemapScale = reader.ReadSingle();
         this.leftEyeReflectionCenter = Utils.ReadVector3(reader);
         this.rightEyeReflectionCenter = Utils.ReadVector3(reader);
     }
 }
 public static void WriteUVCoord(BinaryWriter writer, UVCoord value)
 {
     writer.Write(value[0]);
     writer.Write(value[1]);
 }
Пример #15
0
 public static float Dot(UVCoord A, UVCoord B)
 {
     return((float)((double)A[0] * (double)B[0] + (double)A[1] * (double)B[1]));
 }
Пример #16
0
 public static void WriteUVCoord(BinaryWriter writer, UVCoord value)
 {
     writer.Write(value[0]);
     writer.Write(value[1]);
 }
Пример #17
0
 public static float Cross(UVCoord A, UVCoord B)
 {
     return(A[0] * B[1] - A[1] * B[0]);
 }
 public override void Read(NiHeader header, BinaryReader reader)
 {
     base.Read(header, reader);
     this.shaderFlags1 = reader.ReadUInt32();
     this.shaderFlags2 = reader.ReadUInt32();
     this.uvOffset = Utils.ReadUVCoord(reader);
     this.uvScale = Utils.ReadUVCoord(reader);
     this.sourceTexture = Utils.ReadSizedString(reader);
     this.textureClampMode = reader.ReadUInt32();
     this.falloffStartAngle = reader.ReadSingle();
     this.falloffStopAngle = reader.ReadSingle();
     this.falloffStartOpacity = reader.ReadSingle();
     this.falloffStopOpacity = reader.ReadSingle();
     this.emissiveColor = Utils.ReadColor4(reader);
     this.emissiveMultiple = reader.ReadSingle();
     this.softFalloffDepth = reader.ReadSingle();
     this.greyscaleTexture = Utils.ReadSizedString(reader);
 }
 private bool UVAtlas(NiTriShapeData data, string texture, StaticDesc stat)
 {
     List<UVCoord> uvcoords = data.GetUVCoords();
     List<UVCoord> uvcoords2 = new List<UVCoord>();
     for (int index = 0; index < uvcoords.Count; ++index)
     {
         float u = uvcoords[index][0];
         float v = uvcoords[index][1];
         if (u < atlasToleranceMin || u > atlasToleranceMax || v < atlasToleranceMin || u > atlasToleranceMax)
         {
             if (this.verbose && !texture.Contains("glacierslablod"))
             {
                 logFile.WriteLog("Out of range " + atlasToleranceMin + " <= " + u + ", " + v + " <= " + atlasToleranceMax + " for " + texture + " in " + stat.staticModels[this.quadIndex]);
             }
             return false;
         }
         u = Math.Max(u, 0);
         v = Math.Max(v, 0);
         u = Math.Min(u, 1);
         v = Math.Min(v, 1);
         u *= AtlasList.Get(texture).scaleU;
         v *= AtlasList.Get(texture).scaleV;
         u += AtlasList.Get(texture).posU;
         v += AtlasList.Get(texture).posV;
         UVCoord coords = new UVCoord(u, v);
         uvcoords2.Add(coords);
     }
     data.SetUVCoords(uvcoords2);
     return true;
 }