Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

ac3dmaterial.cpp

00001 /***************************************************************************
00002                           AC3DMaterial.cpp  -  description
00003           $Id: ac3dmaterial.cpp 3 2006-06-11 08:16:14Z neoneurone $
00004                              -------------------
00005     begin                : mer juin 29 05
00006     copyright            : (C) 2005 by Duong-Khang NGUYEN
00007     email                : neoneurone @ users sourceforge net
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   any later version.                                                    *
00016  *                                                                         *
00017  ***************************************************************************/
00018  
00019 #include "ac3dmaterial.h"
00020 
00021 #include "macros.h"             // for debugging macros
00022 #include "ac3dmacros.h"
00023 
00024 #include <sstream>
00025 
00026 using std::stringstream;
00027 
00028 namespace AC3D {
00029 
00030 
00031    /*=====================================================================*/
00032 AC3DMaterial::AC3DMaterial():
00033 rgb( .0, .0, .0 ),
00034 amb( .0, .0, .0 ),
00035 emis( .0, .0, .0 ),
00036 spec( .0, .0, .0 ),
00037 shi( .0 ),
00038 trans( .0 )
00039 {
00040 }
00041 
00042 
00043    /*=====================================================================*/
00044 AC3DMaterial::AC3DMaterial(
00045     const string data
00046 ):
00047 rgb( .0, .0, .0 ),
00048 amb( .0, .0, .0 ),
00049 emis( .0, .0, .0 ),
00050 spec( .0, .0, .0 ),
00051 shi( .0 ),
00052 trans( .0 )
00053 {
00054     char cstr[AC3D_MAX_LINE_LENGTH];
00055 
00056 //  OPENCITY_DEBUG("ctor");
00057     assert( data != "" );
00058 
00059 // WARNING: no error checking
00060 // MATERIAL "ac3dmat1" rgb 1 1 1  amb 0.2 0.2 0.2  emis 0 0 0  spec 0.5 0.5 0.5  shi 10  trans 0
00061     sscanf(
00062         data.c_str()
00063         , "MATERIAL %s rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %f trans %f "
00064         , cstr
00065         , &rgb.fR, &rgb.fG, &rgb.fB
00066         , &amb.fR, &amb.fG, &amb.fB
00067         , &emis.fR, &emis.fG, &emis.fB
00068         , &spec.fR, &spec.fG, &spec.fB
00069         , &shi , &trans
00070     );
00071         
00072     this->strName = cstr;
00073 }
00074 
00075 
00076    /*=====================================================================*/
00077 AC3DMaterial::~AC3DMaterial()
00078 {
00079 }
00080 
00081 
00082    /*=====================================================================*/
00083 string
00084 AC3DMaterial::ToStr() const
00085 {
00086     stringstream ss;
00087 
00088     ss << "MATERIAL " << this->strName << " "
00089        << "rgb " << rgb.fR << " " << rgb.fG << " " << rgb.fB << " "
00090        << "amb " << amb.fR << " " << amb.fG << " " << amb.fB << " "
00091        << "emis " << emis.fR << " " << emis.fG << " " << emis.fB << " "
00092        << "spec " << spec.fR << " " << spec.fG << " " << spec.fB << " "
00093        << "shi " << shi << " "
00094        << "trans " << trans << endl;
00095 
00096     return ss.str();
00097 }
00098 
00099 
00100 }
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2