Inheritance: IDisposable
示例#1
0
 public void Dispose()
 {
     if (_model != null)
     {
         _defaultEffect.Dispose();
         _defaultEffect = null;
         _model = null;
     }
 }
示例#2
0
 public void SetShader(RShader Shader)
 {
     shader.effect = Shader.effect;
 }
示例#3
0
 public void GetShader(ref RShader Shader)
 {
     Shader = shader;
 }
示例#4
0
 public RMaterial Clone()
 {
     int num = 1;
     for(int i=0; i<RMaterialFactory.Instance._MaterialList.Count; i++)
         if (RMaterialFactory.Instance._MaterialList.ContainsKey(this.name+num))
         {
             num++;
         }
     RMaterial mat = new RMaterial();
     RShader sh = new RShader();
     sh.effect = shader.effect.Clone();
     mat.name = this.name+num;
     mat.shader = sh;
     mat.ambColor = ambColor;
     mat.diffColor = diffColor;
     mat.ID = RMaterialFactory._instance._MaterialList.Count + 1;
     mat.specColor = specColor;
     mat.specPower = specPower;
     RMaterialFactory._instance._MaterialList.Add(mat.name, mat);
     return mat;
 }
示例#5
0
        public void Load(string filename)
        {
            _model = REngine.Instance._content.Load<Model>(filename);
            Matrix = Matrix.CreateScale(1.0f);
            Scaling = new Vector3(1f, 1f, 1f);
            Matrix = BuildScalingMatrix(Matrix);
            #if XBOX
            _defaultEffect = REngine.Instance._resourceContent.Load<RShader>("Actor.Xbox");
            #elif MACOSX
            _defaultEffect = RShader.LoadEffectResource("Actor.ogl.mgfxo");
            #else
            _defaultEffect = RShader.LoadEffectResource("Actor.ogl.mgfxo");
            #endif
            _defaultEffect.effect.CurrentTechnique = _defaultEffect.effect.Techniques[0];
            _sphere = _model.Meshes[0].BoundingSphere;
            foreach (ModelMesh mesh in _model.Meshes)
            {
                _sphere = BoundingSphere.CreateMerged(_sphere, mesh.BoundingSphere);
                for (int i = 0; i < mesh.MeshParts.Count; i++)
                {
                    BasicEffect effect = (BasicEffect)mesh.MeshParts[i].Effect;

                    Texture t = effect.Texture;
                    mesh.MeshParts[i].Effect = _defaultEffect.effect.Clone();
                    mesh.MeshParts[i].Effect.Parameters["Texture"].SetValue(t);

                }
            }
            _skinningData = _model.Tag as SkinningData;
            _player = new AnimationPlayer(_skinningData);
            _player.StartClip(_skinningData.AnimationIndexes[0], 1.0f);
            _playing = true;
        }