2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 #include "BSP_GhostTest3D.h"
30 #include "BSP_TMesh.h"
31 #include "MEM_SmartPtr.h"
32 #include "BSP_PlyLoader.h"
38 MEM_SmartPtr<BSP_TMesh>
50 MEM_SmartPtr<BSP_TMesh> output = new BSP_TMesh;
52 std::vector<BSP_TVertex> &verts = output->VertexSet();
56 MT_Scalar x_scale = fx*MT_PI/x;
57 MT_Scalar y_scale = fy*MT_PI/y;
62 for (j = 0; j < y; j++) {
63 for (i = 0; i < x; i++) {
64 float z = ampx*sin(x_scale * i) + ampy*sin(y_scale * j);
66 MT_Vector3 val(i*fsx - sx/2,j*fsy - sy/2,z);
70 verts.push_back(chuff);
76 for (j = 0; j < (y-1); j++) {
77 for (i = 0; i < (x-1); i++) {
80 poly[1] = poly[0] + 1;
81 poly[2] = poly[1] + y;
84 output->AddFace(poly,4);
88 output->m_min = MT_Vector3(-sx/2,-sy/2,-ampx -ampy);
89 output->m_max = MT_Vector3(sx/2,sy/2,ampx + ampy);
102 MEM_SmartPtr<BSP_TMesh> mesh1 = BSP_PlyLoader::NewMeshFromFile("bsp_cube.ply",min,max);
103 MEM_SmartPtr<BSP_TMesh> mesh2 = BSP_PlyLoader::NewMeshFromFile("bsp_cube.ply",min2,max2);
111 MEM_SmartPtr<BSP_TMesh> mesh1 = NewTestMesh(10,10,2,2,4,4,20,20);
112 MEM_SmartPtr<BSP_TMesh> mesh2 = NewTestMesh(10,10,2,2,4,4,20,20);
116 cout << "could not load mesh!";
122 // MEM_SmartPtr<BSP_TMesh> mesh2 = new BSP_TMesh(mesh1.Ref());
124 BSP_GhostTestApp3D app;
126 cout << "Mesh polygons :" << mesh1->FaceSet().size() << "\n";
127 cout << "Mesh vertices :" << mesh1->VertexSet().size() << "\n";