OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / saisei-1.0 / src / oldcode / DungeonBuilderA.cpp
1 #include "DungeonBuilderA.h"
2 #include "MapImageColor.h"
3
4 et::DungeonBuilderA::DungeonBuilderA(mof::PixelMap& map , mof::TextureManager* pTextureManager , float scale)
5 : et::DungeonBuilder(map , pTextureManager , scale)
6 {
7 }
8
9 et::DungeonBuilderA::~DungeonBuilderA(void)
10 {
11 }
12
13 void et::DungeonBuilderA::addParts(std::vector<et::VertexTypeDungeon>& vertices , int x , int y){
14         mof::PixelMap map = getMap();
15         const float SCALE = getScale();
16         et::VertexTypeDungeon vertex;
17         vertex.y = 0.0f;
18         float t = 0.0001f;//\83e\83N\83X\83`\83\83\8b«\8aE\95â\90³
19         vertex.color = mof::createColor(255 , 255 , 255);
20         float tableX[]={ 0.0f , SCALE , SCALE , SCALE , 0.0f , 0.0f};
21         float tableZ[]={ 0.0f , 0.0f , -SCALE , -SCALE , -SCALE , 0.0f};
22         float tableTU[]={ 0.25f+t , 0.5f-t , 0.5f-t , 0.5f-t , 0.25f+t , 0.25f+t};
23         float tableTV[]={ 0.0f+t, 0.0f+t , 0.25f-t , 0.25f-t , 0.25f-t , 0.0f+t};
24
25
26         if(et::isWalkableColor(map.get(x , y))){
27                 for(int i = 0 ; i < 6 ; i++){
28                         vertex.x = tableX[i] + SCALE * x;
29                         vertex.z = tableZ[i] - SCALE * y;
30                         vertex.tu = tableTU[i];
31                         vertex.tv = tableTV[i];
32                         vertices.push_back(vertex);
33                 }
34                 return;
35         }
36         else if(map.get(x , y) == mof::createColor( 255 , 0 , 0)){
37                 
38                 for(int i = 0 ; i < 6 ; i++){
39                         vertex.x = tableX[i] + SCALE * x;
40                         vertex.y = SCALE;
41                         vertex.z = tableZ[i] - 0.3f * y;
42                         vertex.tu = tableTU[i] -0.25f;
43                         vertex.tv = tableTV[i];
44                         vertices.push_back(vertex);
45                 }
46
47                 //\95Ç\82ð\92Ç\89Á
48                 if(y > 0 && map.get(x , y-1) != mof::createColor(255 , 0 , 0)){
49                         //\8fã\95û\8cü\82É\95Ç
50                         for(int i = 0 ; i < 6 ; i++){
51                                 vertex.x = tableX[i] + SCALE * x;
52                                 vertex.y = tableZ[i] +SCALE;
53                                 vertex.z =  - SCALE * y;
54                                 vertex.tu = tableTU[i] - 0.25f;
55                                 vertex.tv = tableTV[i];
56                                 vertices.push_back(vertex);
57                         }
58                 }
59                 if(y < map.getHeight() && map.get(x , y+1) != mof::createColor(255 , 0 , 0)){
60                         //\89º\95û\8cü\82É\95Ç
61                         for(int i = 0 ; i < 6 ; i++){
62                                 vertex.x = tableX[i] + SCALE * x;
63                                 vertex.y = tableZ[i] + SCALE;
64                                 vertex.z =  - SCALE * (y+1);
65                                 if(et::isWalkableColor(map.get(x , y+1)))vertex.tu = tableTU[i] + 0.5f;
66                                 else vertex.tu = tableTU[i] - 0.25f;
67                                 vertex.tv = tableTV[i];
68                                 vertices.push_back(vertex);
69                         }
70                 }
71                 if(x > 0 && map.get(x-1 , y) != mof::createColor(255 , 0 , 0)){
72                         //\8d\95û\8cü\82É\95Ç
73                         for(int i = 0 ; i < 6 ; i++){
74                                 vertex.x = SCALE * x;
75                                 vertex.y = tableZ[5-i] + SCALE;
76                                 vertex.z =   -SCALE * (y+1) + tableX[5-i];
77                                 if(et::isWalkableColor(map.get(x-1 , y)))vertex.tu = tableTU[5-i] + 0.5f;
78                                 else vertex.tu = tableTU[5-i] - 0.25f;
79                                 vertex.tv = tableTV[5-i];
80                                 vertices.push_back(vertex);
81                         }
82                 }
83                 if(x < map.getWidth() && map.get(x+1 , y) != mof::createColor(255 , 0 , 0)){
84                         //\89E\95û\8cü\82É\95Ç
85                         for(int i = 0 ; i < 6 ; i++){
86                                 vertex.x = SCALE * (x+1);
87                                 vertex.y = tableZ[i] + SCALE;
88                                 vertex.z =   -SCALE * (y+1) + tableX[i];
89                                 if(et::isWalkableColor(map.get(x+1 , y)))vertex.tu = tableTU[i] + 0.5f;
90                                 else vertex.tu = tableTU[i] - 0.25f;
91                                 vertex.tv = tableTV[i];
92                                 vertices.push_back(vertex);
93                         }
94                 }       
95         }
96         else return;
97
98         
99 }