source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGClusterList.cpp @ 709

Revision 709, 5.3 KB checked in by igarcia, 18 years ago (diff)
Line 
1
2#include "IMGClusterList.h"
3
4namespace IMG {
5
6// Gametools -- Isma 17/08/2005
7//int Cluster::CalculaPatch (Vector3 &point)
8//{
9//      //printf("\nCalculaPatch on està el vertex: (%.4f, %.4f, %.4f)", point.x, point.y, point.z);   
10//     
11//      //this->Print();
12//     
13//      int idpatch = this->CalcPatch (point);
14//      if (ObscuranceRayTracing::Config::Debug) printf("\nEl idpatch calculat és: %d", idpatch);
15//      int id = GetIdPatch(idpatch);
16//      if (ObscuranceRayTracing::Config::Debug) printf("\nEl patch real és el : %d", id);
17//      return id;
18//}
19// Gametools -- Isma 17/08/2005
20//
21//int Cluster::CalcPatch (Vector3 &point)
22//{
23//      //printf("\nDins Calcular Patch, valor de la caixa: ");
24//      //bound->Print();
25//      int x, y;
26//      //Polygon2d poly2d;
27//      //int axisproj;
28//      Vector2 point2d;
29//      //Box box;
30//      Vector3 min, max;
31//      //Vector2 *vertexs;
32//      //int order;
33//     
34//     
35//      //vertexs = poly2d_text->GetVector3s();
36//      //vertexs = triangle2d_text->GetVector3s();
37//     
38//      //printf("\nCalc Patch ");
39//     
40//     
41//      //for (register unsigned int i = 0; i < 4; i++)
42//      //{
43//      //      box.AddBoundingVector3 (vertexs[i].x, vertexs[i].y, 0);         
44//      //}     
45//     
46//     
47//     
48//      min = bound->GetMinimum();     
49//      max = bound->GetMaximum();
50//      //box.Print();
51//     
52//      point2d = point2d.ProjectVector33d (point, axisproj);
53//      //printf("\nPoint2d: (%.4f, %.4f)", point2d.x, point2d.y);
54//     
55//     
56//      switch (axisproj)
57//      {
58//             
59//              case 1: // 2 3
60//                      // 0 1
61//                             
62//                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (max.x - min.x));
63//                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (max.y - min.y));
64//                      return x + y * ObscuranceRayTracing::Config::MapWidth;
65//              case 2: // 0 1
66//                      // 2 3
67//
68//                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (max.x - min.x));
69//                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (min.y - max.y));
70//                      //printf("\nValor x: %d", x);
71//                      //printf("\nValor y: %d", y);
72//                     
73//                      if (x < 0) x = -x;      //arreglo temporal si no no va bé
74//                      if (y < 0) y = -y;
75//                      return x + y * ObscuranceRayTracing::Config::MapWidth;
76//             
77//              case 0: // 3 2
78//                      // 1 0
79//
80//                     
81//                      x = int ( (point2d.x - min.x) * ObscuranceRayTracing::Config::MapWidth / (min.x - max.x));
82//                      y = int ( (point2d.y - min.y) * ObscuranceRayTracing::Config::MapHeight / (max.y - min.y));
83//                     
84//                      //printf("\nValor x: %d", x);
85//                      //printf("\nValor y: %d", y);
86//                      if (x < 0) x = -x;
87//                      if (y < 0) y = -y;
88//                      return x + y * ObscuranceRayTracing::Config::MapWidth;         
89//      }
90//     
91//      return -1;
92//}
93//
94// Gametools -- Isma 17/08/2005
95//
96//bool Cluster::CreatePatches( bool dinamic)
97//{
98//      if (ObscuranceRayTracing::Config::Debug)
99//      {
100//              printf("\n\nCreant Patches en cluster (%d), isdinamic %d\n\n", dinamic, GetId());
101//              printf("\nEl polygon es: ");
102//              Print();
103//              //printf("\n-----------\n ");
104//      }
105//     
106//      //if (!Inc) return false;
107//      //if (!vertexs) return false;
108//                             
109//      int acum = 0;
110//      register unsigned int i = 0, j = 0;
111//      //Vector3 orig = Inc[0], valorx = Inc[1], valory = Inc[2];
112//     
113//     
114//      Vector3 orig, valorx, valory;
115//     
116//      orig = lumel_origin;
117//      valorx = lumel_x_axis;
118//      valory = lumel_y_axis;
119//     
120//      //if (ObscuranceRayTracing::Config::Debug)
121//      {
122//              printf("\nValor de origen: (%.4f, %.4f, %.4f)", lumel_origin.x, lumel_origin.y,lumel_origin.z);
123//              printf("\nValor de Ax: (%.4f, %.4f, %.4f)", lumel_x_axis.x, lumel_x_axis.y, lumel_x_axis.z);
124//              printf("\nValor de Ay: (%.4f, %.4f, %.4f)", lumel_y_axis.x, lumel_y_axis.y, lumel_y_axis.z);
125//      }
126//     
127//      Vector3 p0, p1, p2, p3;
128//     
129//     
130//      patchlistid.GetList()->reserve ( ObscuranceRayTracing::Config::MapHeight * ObscuranceRayTracing::Config::MapWidth);
131//      int cont = 0;
132//      for (; j <  ObscuranceRayTracing::Config::MapHeight; j++)
133//      {               
134//              i = 0;
135//              for (i = 0; i < ObscuranceRayTracing::Config::MapWidth; i++)
136//              {                       
137//                      Patch * patch = new Patch;                                             
138//                      patch->SetCoord (i, j);
139//                      //patch->SetCoord (j, i);
140//                      patch->SetIdLumel(i + j + acum);
141//                      patch->SetCluster (this);
142//                     
143//                      if (dinamic) patch->dinamic = dinamic;
144//                     
145//                     
146//                      Patch::seqid++;                 
147//                                             
148//                      //if (ObscuranceRayTracing::Config::Debug) patch->Print(2);
149//                     
150//                      patchlistid.Insert(patch->GetId());     //add the id (index) to polygon's patchlistid
151//                     
152//                      //if (dinamic) ObscuranceRayTracing::patchlistdinamic.Insert(patch);
153//                      //else ObscuranceRayTracing::patchlist.Insert(patch);
154//                     
155//                      ObscuranceRayTracing::patchlist_triangle.Insert(patch);
156//                      //ObscuranceRayTracing::patchlist_cluster.Insert(patch);
157//                      //patch->Print(2);
158//                     
159//                      delete patch;
160//                      cont++;
161//              }
162//                     
163//              acum = acum + ObscuranceRayTracing::Config::MapWidth - 1;       //el id del patch segÃŒent acum += lightmap_del_polygon->GetWidth() - 1
164//      }
165//     
166//      //if (ObscuranceRayTracing::Config::Debug)
167//              printf("\n\nLlista de indexs de patchs del polygon: %d" , patchlistid.GetSize());
168//      return true;
169//}
170//
171
172bool ClusterList::Insert(Cluster * p) {
173        if (!p) return false;
174        //printf("\nInserting polygon");
175        //p->Print();   
176        //list.push_back(p);
177        //printf("\nInsert polygon: INsert\n");
178        list.push_back(*p);
179        //printf("\nInsert polygon: INsert fora\n");
180        return true;
181}
182
183void ClusterList::Print() {
184        printf("\n\n\nNombre de  cluster a la llista: %d --> ", list.size());
185        for (register int i = 0; i < list.size(); i ++)
186        {
187                //printf( "%d", GetPolygon(i)->GetId());
188                Get(i)->Print();
189        }
190       
191}
192
193ClusterList::~ClusterList()
194{
195        list.clear();
196}
197
198
199}
Note: See TracBrowser for help on using the repository browser.