1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #include <3dsparse/TreeModelFactory.h>
22 #include <common/Defines.h>
23 #include <stdio.h>
24 #include <math.h>
25 
TreeModelFactory()26 TreeModelFactory::TreeModelFactory()
27 {
28 }
29 
~TreeModelFactory()30 TreeModelFactory::~TreeModelFactory()
31 {
32 }
33 
createModel(const char * fileName)34 Model *TreeModelFactory::createModel(const char *fileName)
35 {
36 	Model *model = new Model();
37 	model->getMin() = FixedVector(fixed(true, -5000), fixed(true, -5000), fixed(true, -5000));
38 	model->getMax() = FixedVector(fixed(true, +5000), fixed(true, +5000), fixed(true, +5000));
39 	return model;
40 }
41 
getTypes(const char * type,bool snow,TreeType & normalType,TreeType & burntType)42 bool TreeModelFactory::getTypes(const char *type, bool snow,
43 	TreeType &normalType, TreeType &burntType)
44 {
45 	if (0 == strcmp(type, "pine"))
46 	{
47 		normalType = (snow?ePineSnow:ePineNormal);
48 		burntType = ePineBurnt;
49 	}
50 	else if (0 == strcmp(type, "pine2"))
51 	{
52 		normalType = (snow?ePine2Snow:ePine2);
53 		burntType = ePineBurnt;
54 	}
55 	else if (0 == strcmp(type, "pine3"))
56 	{
57 		normalType = (snow?ePine3Snow:ePine3);;
58 		burntType = ePineBurnt;
59 	}
60 	else if (0 == strcmp(type, "pine4"))
61 	{
62 		normalType = (snow?ePine4Snow:ePine4);;
63 		burntType = ePineBurnt;
64 	}
65 	else if (0 == strcmp(type, "burntpine"))
66 	{
67 		normalType = ePineBurnt;
68 		burntType = ePineBurnt;
69 	}
70 	else if (0 == strcmp(type, "yellowpine"))
71 	{
72 		normalType = (snow?ePineSnow:ePineYellow);
73 		burntType = ePineBurnt;
74 	}
75 	else if (0 == strcmp(type, "lightpine"))
76 	{
77 		normalType = (snow?ePineSnow:ePineLight);
78 		burntType = ePineBurnt;
79 	}
80 	else if (0 == strcmp(type, "palm"))
81 	{
82 		normalType = ePalmNormal;
83 		burntType = ePalmBurnt;
84 	}
85 	else if (0 == strcmp(type, "palm2"))
86 	{
87 		normalType = ePalm2;
88 		burntType = ePalmBurnt;
89 	}
90 	else if (0 == strcmp(type, "palm3"))
91 	{
92 		normalType = ePalm3;
93 		burntType = ePalmBurnt;
94 	}
95 	else if (0 == strcmp(type, "palm4"))
96 	{
97 		normalType = ePalm4;
98 		burntType = ePalmBurnt;
99 	}
100 	else if (0 == strcmp(type, "palmb"))
101 	{
102 		normalType = ePalmB;
103 		burntType = ePalmBurnt;
104 	}
105 	else if (0 == strcmp(type, "palmb2"))
106 	{
107 		normalType = ePalmB2;
108 		burntType = ePalmBurnt;
109 	}
110 	else if (0 == strcmp(type, "palmb3"))
111 	{
112 		normalType = ePalmB3;
113 		burntType = ePalmBurnt;
114 	}
115 	else if (0 == strcmp(type, "palmb4"))
116 	{
117 		normalType = ePalmB4;
118 		burntType = ePalmBurnt;
119 	}
120 	else if (0 == strcmp(type, "palmb5"))
121 	{
122 		normalType = ePalmB5;
123 		burntType = ePalmBurnt;
124 	}
125 	else if (0 == strcmp(type, "palmb6"))
126 	{
127 		normalType = ePalmB6;
128 		burntType = ePalmBurnt;
129 	}
130 	else if (0 == strcmp(type, "palmb7"))
131 	{
132 		normalType = ePalmB7;
133 		burntType = ePalmBurnt;
134 	}
135 	else if (0 == strcmp(type, "burntpalm"))
136 	{
137 		normalType = ePalmBurnt;
138 		burntType = ePalmBurnt;
139 	}
140 	else if (0 == strcmp(type, "oak"))
141 	{
142 		normalType = eOak;
143 		burntType = ePalmBurnt;
144 	}
145 	else if (0 == strcmp(type, "oak2"))
146 	{
147 		normalType = eOak2;
148 		burntType = ePalmBurnt;
149 	}
150 	else if (0 == strcmp(type, "oak3"))
151 	{
152 		normalType = eOak3;
153 		burntType = ePalmBurnt;
154 	}
155 	else if (0 == strcmp(type, "oak4"))
156 	{
157 		normalType = eOak4;
158 		burntType = ePalmBurnt;
159 	}
160 	else return false;
161 	return true;
162 }
163 
164