Exemplo n.º 1
0
        internal void UpdateMaterial(MaterialState type)
        {
            if (MeshRender == null)
            {
                return;
            }

            Material[] mats = null;
            switch (type)
            {
            case MaterialState.Normal:
            {
                mats = Materials;
                break;
            }

            case MaterialState.TouMing:
            {
                mats = TouMingMaterials;
                break;
            }
            }

            if (mats != null)
            {
                MeshRender.materials = mats;
            }
        }
Exemplo n.º 2
0
            public MaterialState CreateMaterialState()
            {
                MaterialState objMaterial = new MaterialState();

                objMaterial.FrontMaterial.Ambient = Material.Ambient;
                if (Material.AmbientTexture != null)
                {
                    objMaterial.FrontMaterialAmbientTexture  = Material.AmbientTexture;
                    objMaterial.FrontMaterialAmbientTexCoord = 0;
                }

                objMaterial.FrontMaterial.Diffuse = Material.Diffuse;
                if (Material.DiffuseTexture != null)
                {
                    objMaterial.FrontMaterialDiffuseTexture  = Material.DiffuseTexture;
                    objMaterial.FrontMaterialDiffuseTexCoord = 0;
                }

                objMaterial.FrontMaterial.Specular  = Material.Specular;
                objMaterial.FrontMaterial.Shininess = Material.SpecularExponent;

                if (Material.NormalTexture != null)
                {
                    objMaterial.FrontMaterialNormalTexture  = Material.NormalTexture;
                    objMaterial.FrontMaterialNormalTexCoord = 0;
                }

                return(objMaterial);
            }
Exemplo n.º 3
0
 /// <summary>
 /// 修改材质
 /// </summary>
 /// <param name="state"></param>
 public void ChangeMatTo(MaterialState state)
 {
     if (state.materials != null)
     {
         List <string> keywords = new List <string>();
         foreach (var clip in state.Clips)
         {
             if (clip.from.type == PropertyType.keyword)
             {
                 keywords.Add(clip.from.key);
             }
         }
         Material[] mats = new Material[state.materials.Length];
         for (int i = 0; i < state.materials.Length; i++)
         {
             var mat = state.materials[i];
             if (mat == null)
             {
                 mats[i] = Renderer.materials[i];
             }
             else
             {
                 mats[i] = mat;
             }
             mats[i].shaderKeywords = keywords.ToArray();
         }
         Renderer.materials = mats;
     }
 }
Exemplo n.º 4
0
        private SceneObjectGeometry CreateCubeGeometry()
        {
            SceneObjectGeometry cubeGeometry = new SceneObjectGeometry("Cube");

            #region State

            cubeGeometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            cubeGeometry.ObjectState.DefineState(new TransformState());

            MaterialState cubeMaterialState = new MaterialState();
            cubeMaterialState.FrontMaterial           = new MaterialState.Material(ColorRGBAF.ColorWhite * 0.5f);
            cubeMaterialState.FrontMaterial.Ambient   = ColorRGBAF.ColorBlack;
            cubeMaterialState.FrontMaterial.Diffuse   = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Specular  = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Shininess = 10.0f;
            cubeGeometry.ObjectState.DefineState(cubeMaterialState);

            #endregion

            #region Vertex Arrays

            if (_CubeArrayPosition == null)
            {
                _CubeArrayPosition = new ArrayBuffer <Vertex3f>();
                _CubeArrayPosition.Create(ArrayPosition);
            }

            if (_CubeArrayColor == null)
            {
                _CubeArrayColor = new ArrayBuffer <ColorRGBF>();
                _CubeArrayColor.Create(ArrayColors);
            }

            if (_CubeArrayNormal == null)
            {
                _CubeArrayNormal = new ArrayBuffer <Vertex3f>();
                _CubeArrayNormal.Create(ArrayNormals);
            }

            if (_CubeArrays == null)
            {
                _CubeArrays = new VertexArrays();
                _CubeArrays.SetArray(_CubeArrayPosition, VertexArraySemantic.Position);
                _CubeArrays.SetArray(_CubeArrayColor, VertexArraySemantic.Color);
                _CubeArrays.SetArray(_CubeArrayNormal, VertexArraySemantic.Normal);
                _CubeArrays.SetElementArray(PrimitiveType.Triangles);
            }

            cubeGeometry.VertexArray = _CubeArrays;

            #endregion

            #region Program

            cubeGeometry.BoundingVolume = new BoundingBox(-Vertex3f.One * _CubeSize, Vertex3f.One * _CubeSize);

            #endregion

            return(cubeGeometry);
        }
        public GameObject Pop(MaterialState state)
        {
            GameObject obj;

            switch (state)
            {
            case MaterialState.WOOD:
                obj = woodPool.pop();
                break;

            case MaterialState.STONE:
                obj = stonePool.pop();
                break;

            case MaterialState.IRON:
                obj = ironPool.pop();
                break;

            case MaterialState.ADAM:
                obj = adamPool.pop();
                break;

            default:
                obj = woodPool.pop();
                break;
            }
            activeList.Add(obj);
            return(obj);
        }
 public void Remove(MaterialState state, GameObject obj)
 {
     if (activeList.Remove(obj))
     {
         Reset(state, obj);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Sets the standard material as renderer.
 /// </summary>
 public void SetStandardMaterial()
 {
     if (null != standardMaterial)
     {
         GetComponent <Renderer> ().material = standardMaterial;
         materialState = MaterialState.Standard;             // refresh the actual state of material
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Sets the playback material.
 /// </summary>
 public void SetPlaybackMaterial()
 {
     if (null != playbackMaterial)
     {
         GetComponent <Renderer> ().material = playbackMaterial;
         materialState = MaterialState.Playback;
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Sets the negative material.
 /// </summary>
 private void SetNegativeMaterial()
 {
     if (null != negativeMaterial)
     {
         GetComponent <Renderer> ().material = negativeMaterial;
         materialState = MaterialState.Negative;
     }
 }
Exemplo n.º 10
0
    IEnumerator DelayChangeMaterialState(MaterialState type)
    {
        yield return(new WaitForSeconds(0.8f));

        if (m_MatChangeState == type)
        {
            ChangeMaterialState(type);
        }
    }
Exemplo n.º 11
0
 void _updateState(MaterialState state, bool value)
 {
     if (value)
     {
         _states.Add(state);
     }
     else
     {
         _states.Remove(state);
     }
 }
Exemplo n.º 12
0
 void ChangeMaterialState(MaterialState type)
 {
     //SSDebug.Log("ChangeMaterialState -> type ================ " + type);
     for (int i = 0; i < m_MaterrialDt.Length; i++)
     {
         if (m_MaterrialDt[i] != null)
         {
             m_MaterrialDt[i].UpdateMaterial(type);
         }
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Substance"/> class.
 /// </summary>
 /// <param name="type">The MaterialType of the substance.</param>
 /// <param name="mass">The mass of substance to be created.</param>
 /// <param name="tempInCelsius">The temperature of the substance in celsius.</param>
 /// <param name="state">The material state of the substance.</param>
 public Substance(MaterialType type, double mass, double tempInCelsius, MaterialState state = MaterialState.Unknown)
 {
     if (mass > float.MaxValue)
     {
         mass = float.MaxValue;
     }
     m_ssh       = new MementoHelper(this, true);
     m_type      = type;
     m_mass      = mass;
     Temperature = tempInCelsius;
     State       = state;
 }
Exemplo n.º 14
0
 public TileData(bool isPlayerGround, int index, int hp, TileState tileState, MaterialState materialState)
 {
     if (tileState != TileState.MATERIAL)
     {
         return;
     }
     this.isPlayerGround = isPlayerGround;
     this.index          = index;
     this.hp             = hp;
     this.tileState      = tileState;
     this.materialState  = materialState;
 }
Exemplo n.º 15
0
        private void Collect(MaterialState materialState, int clickTileIndex)
        { // 플레이어가 자원 타일을 클릭하면 들어오는 함수
            if (!isNearTile(clickTileIndex) || onBunker)
            {
                return;
            }
            if (!isHasStamina())
            {
                if (isPlayer)
                {
                    unitUI.ShowMessege("스테미너가 부족합니다.");
                }
                unitUI.UnitStaminaDiscount(unitData.stamina);
                return;
            }
            if (ground.GetTile(clickTileIndex).TileHurt(unitData.unitDemage) == false)
            {
                return;
            }
            switch (materialState)
            {
            case MaterialState.WOOD:
                unitData.unitMaterial.wood += unitData.unitDemage;
                unitUI.ShowHeadPopUp("나무 + " + unitData.unitDemage);
                break;

            case MaterialState.STONE:
                unitData.unitMaterial.stone += unitData.unitDemage;
                unitUI.ShowHeadPopUp("돌 + " + unitData.unitDemage);
                break;

            case MaterialState.IRON:
                unitData.unitMaterial.iron += unitData.unitDemage;
                unitUI.ShowHeadPopUp("철 + " + unitData.unitDemage);
                break;

            case MaterialState.ADAM:
                unitData.unitMaterial.adam += unitData.unitDemage;
                unitUI.ShowHeadPopUp("아티움 + " + unitData.unitDemage);
                break;
            }
            if (isPlayer)
            {
                EventManager.Instance.emit(EVENT_TYPE.MATERIAL_COLLECT, this, unitData.unitMaterial);
            }
            else
            {
                EventManager.Instance.emit(EVENT_TYPE.ENEMYMATERAIL_COLLECT, this, unitData.unitMaterial);
            }

            UnitStaminaCount();
            CheckAround();
        }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        rb              = GetComponent <Rigidbody> ();
        rend            = GetComponent <Renderer>();
        currentMaterial = MaterialState.undefined;
        gemCount        = 0;
        enemyCount      = 0;

        updateGemText();
        updateEnemiesText();

                #if UNITY_IOS
        Screen.orientation = ScreenOrientation.LandscapeLeft;
                #endif
    }
Exemplo n.º 17
0
    /// <summary>
    /// 更新材质球.
    /// </summary>
    void UpdateMaterialState(MaterialState type)
    {
        if (m_MatChangeState == type)
        {
            return;
        }
        m_MatChangeState = type;

        if (Time.time - m_TimeLast < 0.8f)
        {
            StartCoroutine(DelayChangeMaterialState(type));
            return;
        }
        m_TimeLast = Time.time;
        ChangeMaterialState(type);
    }
Exemplo n.º 18
0
    public MaterialState GetState(string stateName)
    {
        if (stateName.IsNullOrEmpty())
        {
            return(Default);
        }
        if (dic == null)
        {
            dic = new Dictionary <string, MaterialState>();
            foreach (var state in States)
            {
                dic[state.StateName] = state;
            }
        }
        MaterialState sta = null;

        dic.TryGetValue(stateName, out sta);
        return(sta);
    }
Exemplo n.º 19
0
        /// <summary>
        /// Constructor for MaterialType. Provides a way for the user to specify all of the detailed
        /// characteristics of the material.
        /// </summary>
        /// <param name="model">The model to which this MaterialType will belong.</param>
        /// <param name="name">The name of this MaterialType.</param>
        /// <param name="guid">The Guid of this MaterialType.</param>
        /// <param name="specificGravity">The specific gravity associated with material of this type.</param>
        /// <param name="specificHeat">The specific heat associated with material of this type.</param>
        /// <param name="stpState">State of the material at Standard Temperature &amp; Pressure conditions.</param>
        /// <param name="molecularWeight">The molecular weight.</param>
        /// <param name="latentHeatOfVaporization">The latent heat of vaporization associated with material of this type. J/kg.</param>
        public MaterialType(IModel model, string name, Guid guid,
                            double specificGravity,
                            double specificHeat,
                            MaterialState stpState,
                            double molecularWeight,
                            double latentHeatOfVaporization
                            )
        {
            m_name   = name;
            m_guid   = guid;
            m_model  = model;
            STPState = stpState;
            SetSpecificGravity(specificGravity);                   // kilogram per liter.
            SetSpecificHeat(specificHeat);                         // Joules per Kilogram-degree K.
            SetMolecularWeight(molecularWeight);
            SetLatentHeatOfVaporization(latentHeatOfVaporization); // Joules per Kilogram.
            m_emissionClassifications = null;

            IMOHelper.RegisterWithModel(this);
        }
Exemplo n.º 20
0
    public void ChangeMaterial(MaterialState state)
    {
        if (health.IsDead)
        {
            return;
        }

        if (state == MaterialState.NormalMaterial)
        {
            highlightImage.color = normalColor;
        }
        else if (state == MaterialState.HighlightMaterial)
        {
            highlightImage.color = highlightColor;
        }
        else if (state == MaterialState.SelectedMaterial)
        {
            highlightImage.color = selectedColor;
        }
    }
        private void Reset(MaterialState state, GameObject obj)
        {
            switch (state)
            {
            case MaterialState.WOOD:
                woodPool.push(obj);
                break;

            case MaterialState.STONE:
                stonePool.push(obj);
                break;

            case MaterialState.IRON:
                ironPool.push(obj);
                break;

            case MaterialState.ADAM:
                adamPool.push(obj);
                break;
            }
            obj.SetActive(false);
        }
Exemplo n.º 22
0
        private SceneObjectGeometry CreatePlane()
        {
            SceneObjectGeometry geometry = new SceneObjectGeometry("Plane");

            geometry.VertexArray = VertexArrays.CreatePlane(50.0f, 50.0f, 0.0f, 1, 1);
            geometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            geometry.ObjectState.DefineState(new TransformState());

            MaterialState cubeMaterialState = new MaterialState();

            cubeMaterialState.FrontMaterial          = new MaterialState.Material(ColorRGBAF.ColorWhite * 0.5f);
            cubeMaterialState.FrontMaterial.Ambient  = ColorRGBAF.ColorBlack;
            cubeMaterialState.FrontMaterial.Diffuse  = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Specular = ColorRGBAF.ColorBlack;
            geometry.ObjectState.DefineState(cubeMaterialState);

            geometry.LocalModel.RotateX(-90.0);

            geometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");

            return(geometry);
        }
Exemplo n.º 23
0
    public GameObject NextState()
    {
        switch (currentState)
        {
        case MaterialState.original:
            currentState++;
            return(refinedMaterial);

        case MaterialState.refined:
            currentState++;
            return(processedMaterial);

        case MaterialState.processed:
            currentState = MaterialState.damaged;
            return(damagedMaterial);

        case MaterialState.damaged:
            return(damagedMaterial);

        default:
            return(damagedMaterial);
        }
    }
Exemplo n.º 24
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Pick Up"))
        {
            if (currentMaterial == MaterialState.gem)
            {
                other.gameObject.SetActive(false);
                gemCount++;
                updateGemText();
            }
        }
        else if (other.gameObject.CompareTag("Enemy"))
        {
            enemyCount++;
            updateEnemiesText();
            other.gameObject.SetActive(false);
            gameObject.SetActive(false);
        }
        else if (other.gameObject.CompareTag("Gem Wall"))
        {
            Debug.Log("on trigger enter GEM wall");
            rend.material   = other.GetComponent <Renderer> ().material;
            other.isTrigger = false;
            currentMaterial = MaterialState.gem;
        }
        else if (other.gameObject.CompareTag("Enemy Wall"))
        {
            Debug.Log("on trigger enter ENEMY wall");
            rend.material   = other.GetComponent <Renderer> ().material;
            other.isTrigger = false;
            currentMaterial = MaterialState.enemy;
        }

//		Debug.Log (other.GetComponent<Renderer>().material.name);
//		Debug.Log (rend.material.name);
    }
Exemplo n.º 25
0
 /// <summary>
 /// Constructor for MaterialType. Uses default values for all unspecified (see larger
 /// ctor) properties, marks Molecular Weight as unknown.
 /// </summary>
 /// <param name="model">The model to which this MaterialType will belong.</param>
 /// <param name="name">The name of this MaterialType.</param>
 /// <param name="guid">The Guid of this MaterialType.</param>
 /// <param name="specificGravity">The specific gravity associated with material of this type.</param>
 /// <param name="specificHeat">The specific heat associated with material of this type.</param>
 /// <param name="stpState">The state of the material at standard temperature and pressure.</param>
 public MaterialType(IModel model, string name, Guid guid, double specificGravity, double specificHeat, MaterialState stpState)
     : this(model, name, guid, specificGravity, specificHeat, stpState, UNKNOWN_MOLECULAR_WEIGHT,
            s_default_Lhov)
 {
 }
Exemplo n.º 26
0
		public MaterialResource(string description, string serialNumber, MaterialState state)
		{
			_description = description;
			_serialNumber = serialNumber;
			_state = state;
		}
Exemplo n.º 27
0
        private void RenderMeshes(IEnumerable <Mesh> Meshes)
        {
            foreach (Mesh Mesh in Meshes)
            {
                int n = Mesh.BaseMesh.NodeIndex;

                if (n < Visibilities.Length && !Visibilities[n])
                {
                    continue;
                }

                Shader Shader = Shaders[Mesh.BaseMesh.MaterialIndex];

                GL.UseProgram(Shader.Handle);

                Shader.SetVtx4x4Array(DefaultShaderIds.ProjMtx, Renderer.Camera.ProjectionMatrix);
                Shader.SetVtx3x4Array(DefaultShaderIds.ViewMtx, Renderer.Camera.ViewMatrix * Transform);
                Shader.SetVtx3x4Array(DefaultShaderIds.NormMtx, Transform.ClearScale());
                Shader.SetVtx3x4Array(DefaultShaderIds.WrldMtx, Matrix4.Identity);

                int MaterialIndex    = Mesh.BaseMesh.MaterialIndex;
                H3DMaterialParams MP = BaseModel.Materials[MaterialIndex].MaterialParams;

                MaterialState MS = MaterialStates[Mesh.BaseMesh.MaterialIndex];

                Vector4 MatAmbient = new Vector4(
                    MS.Ambient.R,
                    MS.Ambient.G,
                    MS.Ambient.B,
                    MP.ColorScale);

                Vector4 MatDiffuse = new Vector4(
                    MS.Diffuse.R,
                    MS.Diffuse.G,
                    MS.Diffuse.B,
                    MS.Diffuse.A);

                Shader.SetVtxVector4(DefaultShaderIds.MatAmbi, MatAmbient);
                Shader.SetVtxVector4(DefaultShaderIds.MatDiff, MatDiffuse);
                Shader.SetVtx3x4Array(DefaultShaderIds.TexMtx0, MS.Transforms[0]);
                Shader.SetVtx3x4Array(DefaultShaderIds.TexMtx1, MS.Transforms[1]);
                Shader.SetVtx2x4Array(DefaultShaderIds.TexMtx2, MS.Transforms[2]);

                Shader.SetVtxVector4(DefaultShaderIds.TexTran, new Vector4(
                                         MS.Transforms[0].Row3.X,
                                         MS.Transforms[0].Row3.Y,
                                         MS.Transforms[1].Row3.X,
                                         MS.Transforms[1].Row3.Y));

                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.EmissionUniform), MS.Emission);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.AmbientUniform), MS.Ambient);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.DiffuseUniform), MS.Diffuse);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Specular0Uniform), MS.Specular0);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Specular1Uniform), MS.Specular1);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant0Uniform), MS.Constant0);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant1Uniform), MS.Constant1);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant2Uniform), MS.Constant2);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant3Uniform), MS.Constant3);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant4Uniform), MS.Constant4);
                GL.Uniform4(GL.GetUniformLocation(Shader.Handle, FragmentShaderGenerator.Constant5Uniform), MS.Constant5);

                Mesh.Texture0Name = MS.Texture0Name;
                Mesh.Texture1Name = MS.Texture1Name;
                Mesh.Texture2Name = MS.Texture2Name;

                Mesh.Render();
            }
        }
Exemplo n.º 28
0
        private void SetSphereMaterial(SceneObjectGeometry sphere, string material)
        {
            MaterialState sphereMaterial = new MaterialState();

            sphereMaterial.FrontMaterial           = new MaterialState.Material(ColorRGBAF.ColorWhite);
            sphereMaterial.FrontMaterial.Ambient   = ColorRGBAF.ColorWhite * 0.2f;
            sphereMaterial.FrontMaterial.Diffuse   = ColorRGBAF.ColorWhite * 0.8f;
            sphereMaterial.FrontMaterial.Specular  = ColorRGBAF.ColorWhite * 1.0f;
            sphereMaterial.FrontMaterial.Shininess = 32.0f;

            sphere.ObjectState.DefineState(sphereMaterial);

            if (material == null)
            {
                return;
            }

            string basePath = Path.Combine("Data", "PhotosculptTextures");
            string textureFilename, texturePath;

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "diffuse");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialDiffuseTexture  = texture;
                    sphereMaterial.FrontMaterialDiffuseTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "normal");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialNormalTexture  = texture;
                    sphereMaterial.FrontMaterialNormalTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "specular");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialSpecularTexture  = texture;
                    sphereMaterial.FrontMaterialSpecularTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "ambientocclusion");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialAmbientTexture  = texture;
                    sphereMaterial.FrontMaterialAmbientTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "displace");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    // texture.RequestMipmapsCreation();
                    texture.WrapCoordR     = Texture.Wrap.Repeat;
                    texture.WrapCoordS     = Texture.Wrap.Repeat;
                    texture.MinFilter      = Texture.Filter.Nearest;
                    texture.MagFilter      = Texture.Filter.Nearest;
                    texture.MipmapMaxLevel = 0;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialDisplacementTexture = texture;
                    // sphereMaterial.FrontMaterialDisplacementTexCoord = 0;
                    sphereMaterial.FrontMaterialDisplacementFactor = 0.2f;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }
        }
Exemplo n.º 29
0
 public MaterialResource(string description, string serialNumber, MaterialState state)
 {
     _description  = description;
     _serialNumber = serialNumber;
     _state        = state;
 }
 public GPUSkinningMaterial GetMaterial(MaterialState state)
 {
     return(mtrls[(int)state]);
 }
Exemplo n.º 31
0
 /// <summary>
 /// Constructor for MaterialType. Uses default values for all unspecified (see larger constructor) properties.
 /// </summary>
 /// <param name="model">The model to which this MaterialType will belong.</param>
 /// <param name="name">The name of this MaterialType.</param>
 /// <param name="guid">The Guid of this MaterialType.</param>
 /// <param name="specificGravity">The specific gravity associated with material of this type.</param>
 /// <param name="specificHeat">The specific heat associated with material of this type.</param>
 /// <param name="stpState">The state of the material at standard temperature and pressure.</param>
 /// <param name="molecularWeight">The molecular weight of this substance.</param>
 public MaterialType(IModel model, string name, Guid guid, double specificGravity, double specificHeat, MaterialState stpState, double molecularWeight)
     : this(model, name, guid, specificGravity, specificHeat, stpState, molecularWeight,
            s_default_Lhov)
 {
 }