//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : Material.cpp Data : 23.04.14 Versione : 1.5d7 // Contenuto : Implementazione funzioni per gestione materiali. // // // // Modifiche : 23.04.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "Material.h" using namespace std ; //------------------------- Constants ---------------------------------------- const Material EMERALD( Color( 0.022, 0.175, 0.022), Color( 0.076, 0.614,0.076), Color( 0.633, 0.728, 0.633), 76.8) ; const Material JADE( Color( 0.135, 0.223, 0.158), Color( 0.54, 0.89,0.63), Color( 0.316, 0.316, 0.316), 12.8) ; const Material OBSIDIAN( Color( 0.054, 0.05, 0.066), Color( 0.183, 0.17,0.225), Color( 0.333, 0.329, 0.346), 38.4) ; const Material PEARL( Color( 0.25, 0.207, 0.207), Color( 1.0, 0.829,0.829), Color( 0.297, 0.297, 0.297), 11.3) ; const Material RUBY( Color( 0.175, 0.012, 0.012), Color( 0.614, 0.041,0.041), Color( 0.728, 0.627, 0.627), 76.8) ; const Material TURQUOISE( Color( 0.1, 0.187, 0.175), Color( 0.396, 0.742,0.691), Color( 0.297, 0.308, 0.307), 12.8) ; const Material BRASS( Color( 0.329, 0.224, 0.027), Color( 0.780, 0.569,0.114), Color( 0.992, 0.941, 0.808), 27.9) ; const Material BRONZE( Color( 0.213, 0.128, 0.054), Color( 0.714, 0.429,0.181), Color( 0.394, 0.272, 0.167), 25.6) ; const Material CHROME( Color( 0.25, 0.25, 0.25), Color( 0.4, 0.4,0.4), Color( 0.775, 0.775, 0.775), 76.8) ; const Material COPPER( Color( 0.191, 0.074, 0.023), Color( 0.704, 0.270,0.083), Color( 0.257, 0.138, 0.086), 12.8) ; const Material GOLD( Color( 0.247, 0.199, 0.075), Color( 0.751, 0.606, 0.226), Color( 0.797, 0.724, 0.208), 51.2) ; const Material SILVER( Color( 0.192, 0.192, 0.192), Color( 0.508, 0.508, 0.508), Color( 0.774, 0.774, 0.774), 51.2) ; const Material BLACKPLASTIC( Color( 0.0, 0.0, 0.0), Color( 0.01, 0.01, 0.01), Color( 0.5, 0.5, 0.5), 32) ; const Material CYANPLASTIC( Color( 0.0, 0.1, 0.06), Color( 0.0, 0.51, 0.51), Color( 0.502, 0.502, 0.502), 32) ; const Material GREENPLASTIC( Color( 0.0, 0.0, 0.0), Color( 0.1, 0.35, 0.1), Color( 0.45, 0.55, 0.45), 32) ; const Material REDPLASTIC( Color( 0.0, 0.0, 0.0), Color( 0.5, 0.0, 0.0), Color( 0.7, 0.6, 0.6), 32) ; const Material WHITEPLASTIC( Color( 0.0, 0.0, 0.0), Color( 0.55, 0.55, 0.55), Color( 0.7, 0.7, 0.7), 32) ; const Material YELLOWPLASTIC( Color( 0.0, 0.0, 0.0), Color( 0.5, 0.5, 0.0), Color( 0.6, 0.6, 0.5), 32) ; const Material BLACKRUBBER( Color( 0.02, 0.02, 0.02), Color( 0.01, 0.01, 0.01), Color( 0.4, 0.4, 0.4), 10) ; const Material CYANRUBBER( Color( 0.0, 0.05, 0.05), Color( 0.4, 0.5, 0.5), Color( 0.04, 0.7, 0.7), 10) ; const Material GREENRUBBER( Color( 0.0, 0.05, 0.0), Color( 0.4, 0.5, 0.4), Color( 0.04, 0.7, 0.04), 10) ; const Material REDRUBBER( Color( 0.05, 0.0, 0.0), Color( 0.5, 0.4, 0.4), Color( 0.7, 0.04, 0.04), 10) ; const Material WHITERUBBER( Color( 0.05, 0.05, 0.05), Color( 0.5, 0.5, 0.5), Color( 0.7, 0.7, 0.7), 10) ; const Material YELLOWRUBBER( Color( 0.05, 0.05, 0.0), Color( 0.5, 0.5, 0.4), Color( 0.7, 0.7, 0.04), 10) ; struct NamedMaterial { const char* szName ; Material matM ; } ; static const NamedMaterial StdMaterial[] = { { "EMERALD", EMERALD}, { "JADE", JADE}, { "OBSIDIAN", OBSIDIAN}, { "PEARL", PEARL}, { "RUBY", RUBY}, { "TURQUOISE", TURQUOISE}, { "BRASS", BRASS}, { "BRONZE", BRONZE}, { "CHROME", CHROME}, { "COPPER", COPPER}, { "GOLD", GOLD}, { "SILVER", SILVER}, { "BLACKPLASTIC", BLACKPLASTIC}, { "CYANPLASTIC", CYANPLASTIC}, { "GREENPLASTIC", GREENPLASTIC}, { "REDPLASTIC", REDPLASTIC}, { "WHITEPLASTIC", WHITEPLASTIC}, { "YELLOWPLASTIC", YELLOWPLASTIC}, { "BLACKRUBBER", BLACKRUBBER}, { "CYANRUBBER", CYANRUBBER}, { "GREENRUBBER", GREENRUBBER}, { "REDRUBBER", REDRUBBER}, { "WHITERUBBER", WHITERUBBER}, { "YELLOWRUBBER", YELLOWRUBBER} } ; static const int NUM_STDMATERIAL = ( sizeof(StdMaterial) / sizeof(StdMaterial[0]) ) ; //---------------------------------------------------------------------------- bool GetStdMaterial( int nInd, string& sName, Material& mMat) { // verifico indice if ( nInd < 0 || nInd >= NUM_STDMATERIAL) return false ; // assegno i dati sName = StdMaterial[nInd].szName ; mMat = StdMaterial[nInd].matM ; return true ; }