Debian Codegraph @

src/model/ac3dmaterial.cpp

raw symbols SCIP
1 /***************************************************************************
2 AC3DMaterial.cpp - description
3 -------------------
4 begin : june 29th, 05
5 copyright : (C) 2005 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: ac3dmaterial.cpp 395 2008-12-27 21:12:05Z neoneurone $
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * any later version. *
17 * *
18 ***************************************************************************/
19
20 #include "ac3dmaterial.h"
21
22 #include "macros.h" // for debugging macros
23 #include "ac3dmacros.h"
24
25 #include <cstdio>
26 #include <sstream>
27
28 using std::stringstream;
29
30 namespace AC3D {
31
32
33 /*=====================================================================*/
34 AC3DMaterial::AC3DMaterial():
35 rgb( .0, .0, .0 ),
36 amb( .0, .0, .0 ),
37 emis( .0, .0, .0 ),
38 spec( .0, .0, .0 ),
39 shi( .0 ),
40 trans( .0 )
41 {
42 }
43
44
45 /*=====================================================================*/
46 AC3DMaterial::AC3DMaterial(
47 const string data
48 ):
49 rgb( .0, .0, .0 ),
50 amb( .0, .0, .0 ),
51 emis( .0, .0, .0 ),
52 spec( .0, .0, .0 ),
53 shi( .0 ),
54 trans( .0 )
55 {
56 char cstr[AC3D_MAX_LINE_LENGTH];
57
58 // OPENCITY_DEBUG("ctor");
59 assert( data != "" );
60
61 // WARNING: no error checking
62 // 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
63 sscanf(
64 data.c_str()
65 , "MATERIAL %s rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %f trans %f "
66 , cstr
67 , &rgb.fR, &rgb.fG, &rgb.fB
68 , &amb.fR, &amb.fG, &amb.fB
69 , &emis.fR, &emis.fG, &emis.fB
70 , &spec.fR, &spec.fG, &spec.fB
71 , &shi , &trans
72 );
73
74 this->strName = cstr;
75 }
76
77
78 /*=====================================================================*/
79 AC3DMaterial::~AC3DMaterial()
80 {
81 }
82
83
84 /*=====================================================================*/
85 string
86 AC3DMaterial::ToStr() const
87 {
88 stringstream ss;
89
90 ss << "MATERIAL " << this->strName << " "
91 << "rgb " << rgb.fR << " " << rgb.fG << " " << rgb.fB << " "
92 << "amb " << amb.fR << " " << amb.fG << " " << amb.fB << " "
93 << "emis " << emis.fR << " " << emis.fG << " " << emis.fB << " "
94 << "spec " << spec.fR << " " << spec.fG << " " << spec.fB << " "
95 << "shi " << shi << " "
96 << "trans " << trans << endl;
97
98 return ss.str();
99 }
100
101
102 }
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118