The Material Parameters class is a serializable class that encapsulates all the parameters needed by a material for a particular primitive. Some examples of material parameters are the Local2World transform matrix, colors or specular intensity values associated with a primitive. You must make the distinction between material variables that are the variables exposed by a shader to render a particular material, and the values of these variables which are contained by an instance of this MaterialParameters class.
Пример #1
0
 /// <summary>
 /// Creates a primitive with parameters
 /// </summary>
 /// <param name="_Parent">The parent mesh for that primitive</param>
 /// <param name="_Parameters"></param>
 internal Primitive( Mesh _Parent, MaterialParameters _Parameters, int _VerticesCount, int _FacesCount )
 {
     m_Parent = _Parent;
     m_Parameters = _Parameters;
     m_VerticesCount = _VerticesCount;
     m_Faces = new Face[_FacesCount];
 }
Пример #2
0
            public void Load( System.IO.BinaryReader _Reader )
            {
                // Retrieve the material parameters
                int	MaterialID = _Reader.ReadInt32();
                m_Parameters = m_Parent.m_Owner.FindMaterialParameters( MaterialID );

                // Read faces & vertices count
                int	FacesCount = _Reader.ReadInt32();
                m_VerticesCount = _Reader.ReadInt32();

                // Read faces
                m_Faces = new Face[FacesCount];
                for ( int FaceIndex=0; FaceIndex < FacesCount; FaceIndex++ )
                    m_Faces[FaceIndex].Load( _Reader );

                // Read vertex streams
                ClearVertexStreams();
                int	StreamsCount = _Reader.ReadInt32();
                for ( int StreamIndex=0; StreamIndex < StreamsCount; StreamIndex++ )
                {
                    VertexStream	Stream = new VertexStream( _Reader );
                    m_Streams.Add( Stream );
                }
            }
Пример #3
0
        /// <summary>
        /// Creates a scene from a stream
        /// </summary>
        /// <param name="_Reader"></param>
        /// <param name="_TextureProvider"></param>
        /// <returns></returns>
        public void Load( System.IO.BinaryReader _Reader )
        {
            // Read back textures
            ClearTextures();
            int	TexturesCount = _Reader.ReadInt32();
            for ( int TextureIndex=0; TextureIndex < TexturesCount; TextureIndex++ )
            {
                Texture2D	T = new Texture2D( this, _Reader );
                m_Textures.Add( T );
                m_URL2Texture.Add( T.URL, T );
                m_ID2Texture.Add( T.ID, T );
            }
            m_TextureIDCounter = m_Textures.Count;

            // Read back material parameters
            ClearMaterialParameters();
            int	MaterialParametersCount = _Reader.ReadInt32();
            for ( int MaterialParameterIndex=0; MaterialParameterIndex < MaterialParametersCount; MaterialParameterIndex++ )
            {
                MaterialParameters	MP = new MaterialParameters( this, _Reader );
                m_MaterialParameters.Add( MP );
                m_ID2MaterialParameters.Add( MP.ID, MP );
            }
            m_MaterialParametersIDCounter = m_MaterialParameters.Count;

            // Read back the nodes hierarchy
            ClearNodes();
            bool	bHasRoot = _Reader.ReadBoolean();
            if ( !bHasRoot )
                return;

            // Read back root type
            Node.NODE_TYPE	Type = (Node.NODE_TYPE) _Reader.ReadByte();
            switch ( Type )
            {
                case Node.NODE_TYPE.NODE:
                    m_Root = new Node( this, null, _Reader );
                    break;

                case Node.NODE_TYPE.MESH:
                    m_Root = new Mesh( this, null, _Reader );
                    m_Meshes.Add( m_Root as Mesh );
                    break;

                case Node.NODE_TYPE.LIGHT:
                    m_Root = new Light( this, null, _Reader );
                    m_Lights.Add( m_Root as Light );
                    break;

                case Node.NODE_TYPE.CAMERA:
                    m_Root = new Camera( this, null, _Reader );
                    m_Cameras.Add( m_Root as Camera );
                    break;
            }
            m_ID2Node[m_Root.ID] = m_Root;

            // Propagate state once so matrices are up to date
            m_Root.PropagateState();
        }
Пример #4
0
        public Primitive AddPrimitive( string _Name, MaterialParameters _Material, int _VerticesCount, int _FacesCount )
        {
            Primitive	Result = new Primitive( this, _Material, _VerticesCount, _FacesCount );
            m_Primitives.Add( Result );
            Result.Visible = m_bVisible;

            return Result;
        }
Пример #5
0
 public ParameterTexture2D( MaterialParameters _Owner, string _Name )
     : base(_Owner, _Name)
 {
 }
Пример #6
0
        /// <summary>
        /// Creates a new material parameter block
        /// </summary>
        /// <param name="_Name">The name of the parameter block</param>
        /// <param name="_ShaderURL">The URL of the shader that uses theses parameters (this can be a path to an actual shader, or an identifier like Phong, Lambert, Blinn, whatever really as anyway these parameters are later read and identified by you so you can use whatever makes you comfortable)</param>
        /// <returns></returns>
        public MaterialParameters CreateMaterialParameters( string _Name, string _ShaderURL )
        {
            MaterialParameters	Result = new MaterialParameters( this, m_MaterialParametersIDCounter++, _Name, _ShaderURL );
            m_MaterialParameters.Add( Result );
            m_ID2MaterialParameters.Add( Result.ID, Result );

            return Result;
        }
Пример #7
0
 public ParameterFloat3( MaterialParameters _Owner, string _Name )
     : base(_Owner, _Name)
 {
 }
Пример #8
0
 public ParameterMatrix4( MaterialParameters _Owner, string _Name )
     : base(_Owner, _Name)
 {
 }
Пример #9
0
 public Parameter( MaterialParameters _Owner, string _Name )
 {
     m_Owner = _Owner;
     m_Name = _Name;
 }
Пример #10
0
 public Parameter(MaterialParameters _Owner, string _Name)
 {
     m_Owner = _Owner;
     m_Name  = _Name;
 }
Пример #11
0
 public ParameterTexture2D(MaterialParameters _Owner, string _Name) : base(_Owner, _Name)
 {
 }
Пример #12
0
 public ParameterMatrix4(MaterialParameters _Owner, string _Name) : base(_Owner, _Name)
 {
 }
Пример #13
0
 public ParameterFloat3(MaterialParameters _Owner, string _Name) : base(_Owner, _Name)
 {
 }