예제 #1
0
        // Make from Src : Batched / Shared Material에서 만들때는 이 함수를 이용하자
        //---------------------------------------------------
        public void MakeFromSrc(apOptMaterialInfo srcMatInfo)
        {
            Clear();

            _isBaked   = true;
            _mainTex   = srcMatInfo._mainTex;
            _textureID = srcMatInfo._textureID;
            _shader    = srcMatInfo._shader;


            if (srcMatInfo.NumProp_Float > 0)
            {
                _props_Float = new Property_Float[srcMatInfo.NumProp_Float];
                for (int i = 0; i < srcMatInfo.NumProp_Float; i++)
                {
                    Property_Float srcProp = srcMatInfo._props_Float[i];
                    _props_Float[i] = new Property_Float(srcProp._name, srcProp._value);
                }
            }

            if (srcMatInfo.NumProp_Int > 0)
            {
                _props_Int = new Property_Int[srcMatInfo.NumProp_Int];
                for (int i = 0; i < srcMatInfo.NumProp_Int; i++)
                {
                    Property_Int srcProp = srcMatInfo._props_Int[i];
                    _props_Int[i] = new Property_Int(srcProp._name, srcProp._value);
                }
            }

            if (srcMatInfo.NumProp_Vector > 0)
            {
                _props_Vector = new Property_Vector[srcMatInfo.NumProp_Vector];
                for (int i = 0; i < srcMatInfo.NumProp_Vector; i++)
                {
                    Property_Vector srcProp = srcMatInfo._props_Vector[i];
                    _props_Vector[i] = new Property_Vector(srcProp._name, srcProp._value);
                }
            }

            if (srcMatInfo.NumProp_Texture > 0)
            {
                _props_Texture = new Property_Texture[srcMatInfo.NumProp_Texture];
                for (int i = 0; i < srcMatInfo.NumProp_Texture; i++)
                {
                    Property_Texture srcProp = srcMatInfo._props_Texture[i];
                    _props_Texture[i] = new Property_Texture(srcProp._name, srcProp._value);
                }
            }

            if (srcMatInfo.NumProp_Color > 0)
            {
                _props_Color = new Property_Color[srcMatInfo.NumProp_Color];
                for (int i = 0; i < srcMatInfo.NumProp_Color; i++)
                {
                    Property_Color srcProp = srcMatInfo._props_Color[i];
                    _props_Color[i] = new Property_Color(srcProp._name, srcProp._value);
                }
            }
        }
예제 #2
0
        public void AddProperty_Int(List <Property_Int> propList, string name, int value)
        {
            Property_Int existProp = propList.Find(delegate(Property_Int a)
            {
                return(string.Equals(a._name, name));
            });

            if (existProp != null)
            {
                existProp._value = value;
            }
            else
            {
                propList.Add(new Property_Int(name, value));
            }
        }
예제 #3
0
        // Functions
        //---------------------------------------------------
        public static bool IsSameInfo(apOptMaterialInfo infoA, apOptMaterialInfo infoB)
        {
            if (infoA._mainTex != infoB._mainTex ||
                infoA._textureID != infoB._textureID ||
                infoA._shader != infoB._shader ||

                infoA.NumProp_Float != infoB.NumProp_Float ||
                infoA.NumProp_Int != infoB.NumProp_Int ||
                infoA.NumProp_Vector != infoB.NumProp_Vector ||
                infoA.NumProp_Texture != infoB.NumProp_Texture ||
                infoA.NumProp_Color != infoB.NumProp_Color)
            {
                //기본 속성에서 차이가 있다.
                return(false);
            }

            //이제 상세 설정이 모두 동일한지 확인해야한다.
            //하나라도 다르면 패스
            //이름이나 속성을 순서대로 비교해서 하나라도 다르면 다른 것이다.
            //정렬을 했기 때문에 순서대로 비교하면 된다.

            int numFloat   = infoA.NumProp_Float;
            int numInt     = infoA.NumProp_Int;
            int numVector  = infoA.NumProp_Vector;
            int numTexture = infoA.NumProp_Texture;
            int numColor   = infoA.NumProp_Color;

            //1. Float
            if (numFloat > 0)
            {
                Property_Float propA = null;
                Property_Float propB = null;
                for (int i = 0; i < numFloat; i++)
                {
                    propA = infoA._props_Float[i];
                    propB = infoB._props_Float[i];
                    if (!string.Equals(propA._name, propB._name))
                    {
                        return(false);
                    }

                    if (Mathf.Abs(propA._value - propB._value) > 0.0001f)
                    {
                        return(false);
                    }
                }
            }

            //2. Int
            if (numInt > 0)
            {
                Property_Int propA = null;
                Property_Int propB = null;
                for (int i = 0; i < numInt; i++)
                {
                    propA = infoA._props_Int[i];
                    propB = infoB._props_Int[i];
                    if (!string.Equals(propA._name, propB._name))
                    {
                        return(false);
                    }

                    if (propA._value != propB._value)
                    {
                        return(false);
                    }
                }
            }

            //3. Vector
            if (numVector > 0)
            {
                Property_Vector propA = null;
                Property_Vector propB = null;
                for (int i = 0; i < numVector; i++)
                {
                    propA = infoA._props_Vector[i];
                    propB = infoB._props_Vector[i];
                    if (!string.Equals(propA._name, propB._name))
                    {
                        return(false);
                    }

                    if (Mathf.Abs(propA._value.x - propB._value.x) > 0.0001f ||
                        Mathf.Abs(propA._value.y - propB._value.y) > 0.0001f ||
                        Mathf.Abs(propA._value.z - propB._value.z) > 0.0001f ||
                        Mathf.Abs(propA._value.w - propB._value.w) > 0.0001f)
                    {
                        return(false);
                    }
                }
            }

            //4. Texture
            if (numTexture > 0)
            {
                Property_Texture propA = null;
                Property_Texture propB = null;
                for (int i = 0; i < numTexture; i++)
                {
                    propA = infoA._props_Texture[i];
                    propB = infoB._props_Texture[i];
                    if (!string.Equals(propA._name, propB._name))
                    {
                        return(false);
                    }

                    if (propA._value != propB._value)
                    {
                        return(false);
                    }
                }
            }


            //5. Color
            if (numColor > 0)
            {
                Property_Color propA = null;
                Property_Color propB = null;
                for (int i = 0; i < numColor; i++)
                {
                    propA = infoA._props_Color[i];
                    propB = infoB._props_Color[i];
                    if (!string.Equals(propA._name, propB._name))
                    {
                        return(false);
                    }

                    if (Mathf.Abs(propA._value.r - propB._value.r) > 0.001f ||
                        Mathf.Abs(propA._value.g - propB._value.g) > 0.001f ||
                        Mathf.Abs(propA._value.b - propB._value.b) > 0.001f ||
                        Mathf.Abs(propA._value.a - propB._value.a) > 0.001f)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }