Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MaterialList.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: MaterialList.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.28 $      $Date: 2019/01/17 21:21:00 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Material properties list structure, master list of all materials
00019  ***************************************************************************/
00020 
00021 #ifndef MATERIAL_LIST_H__
00022 #define MATERIAL_LIST_H__
00023 
00024 #include "NameList.h"
00025 #include "ResizeArray.h"
00026 
00027 class Displayable;
00028 
00030 struct Material {
00031   float ambient;
00032   float specular;
00033   float diffuse;
00034   float shininess;
00035   float mirror;
00036   float opacity;
00037   float outline;
00038   float outlinewidth;
00039   float transmode;
00040   int ind;
00041 };
00042 
00043 
00045 enum MaterialProperty { 
00046   MAT_AMBIENT, MAT_SPECULAR, MAT_DIFFUSE, MAT_SHININESS, MAT_MIRROR,
00047   MAT_OPACITY, MAT_OUTLINE, MAT_OUTLINEWIDTH, MAT_TRANSMODE
00048 };
00049                         
00050 
00052 class MaterialList {
00053 protected:
00054   // list of materials 
00055   NameList<Material *> *mlist;
00056  
00057   // root displayable, used to propogate changes in material settings down
00058   // to all the displayables.
00059   Displayable *root;
00060 
00061   // tell users that settings have changed 
00062   void notify(int);
00063 
00064   // counter used to create unique material names
00065   int matcounter;
00066 
00067 public:
00068   // constructor: root of displayable tree
00069   MaterialList(Displayable *);
00070   ~MaterialList();
00071 
00072   // query raw material properties
00073   // The renderers would access the material properties from the
00074   // index in the DispCmd.
00075   int num() const { return mlist->num(); }
00076   const char *material_name(int i) const { return mlist->name(i); }
00077   const Material *material(int i) const  { return mlist->data(i); }
00078 
00079   // Displayables get the index for a material here.  If the name is no longer
00080   // valid, index 0 (opaque) is returned. 
00081   int material_index(const char *nm) const { return mlist->typecode(nm); }
00082 
00083   // modify material properties - the raw values may be scaled internally
00084   void set_name(int, const char *);
00085   void set_ambient(int, float); 
00086   void set_specular(int, float); 
00087   void set_diffuse(int, float); 
00088   void set_shininess(int, float); 
00089   void set_mirror(int, float); 
00090   void set_opacity(int, float); 
00091   void set_outline(int, float); 
00092   void set_outlinewidth(int, float); 
00093   void set_transmode(int, float); 
00094 
00095   // query material properties, with values scaled from 0 to 1
00096   float get_ambient(int); 
00097   float get_specular(int); 
00098   float get_diffuse(int); 
00099   float get_shininess(int); 
00100   float get_mirror(int); 
00101   float get_opacity(int); 
00102   float get_outline(int); 
00103   float get_outlinewidth(int); 
00104   float get_transmode(int); 
00105   
00106   // Add material with given name, or use new unique name if NULL.  
00107   // Copy settings from material with given name, or use material 0 
00108   // if copyfrom is NULL.  Return name of new material, or NULL on
00109   // error.
00110   const char *add_material(const char *name, const char *copyfrom); 
00111 
00112   // delete material; return success.
00113   int delete_material(int);
00114 
00115   // restore the default value of the given material.  Return success.
00116   int restore_default(int);
00117 };
00118 
00119 #endif
00120 

Generated on Fri Oct 4 02:44:11 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002