1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
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.
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.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
22 // MeshLODTri.cpp: implementation of the MeshLODTri class.
24 //////////////////////////////////////////////////////////////////////
26 #include <common/Defines.h>
27 #include <3dsparse/MeshLODVector.h>
28 #include <3dsparse/MeshLODTri.h>
30 //////////////////////////////////////////////////////////////////////
31 // Construction/Destruction
32 //////////////////////////////////////////////////////////////////////
34 MeshLODTri::MeshLODTri(MeshLODVector
*v0
,MeshLODVector
*v1
,MeshLODVector
*v2
)
40 //DIALOG_ASSERT(vertex[0]!=vertex[1] && vertex[0]!=vertex[2] && vertex[1]!=vertex[2]);
44 vertex
[i
]->face
.push_back(this);
47 vertex
[i
]->addNeighbour(vertex
[j
]);
54 MeshLODTri::~MeshLODTri()
59 vertex
[i
]->removeFace(this);
65 vertex
[i
]->removeIfNonNeighbor(vertex
[i2
]);
66 vertex
[i2
]->removeIfNonNeighbor(vertex
[i
]);
75 void MeshLODTri::computeNormal()
77 normal
= ((*vertex
[1] - *vertex
[0]) * (*vertex
[2] - *vertex
[1])).Normalize();
80 bool MeshLODTri::hasVertex(MeshLODVector
*v
)
82 return (v
==vertex
[0] || v
==vertex
[1] || v
==vertex
[2]);
85 void MeshLODTri::replaceVertex(MeshLODVector
*vold
, MeshLODVector
*vnew
)
87 DIALOG_ASSERT(vold
&& vnew
);
88 DIALOG_ASSERT(vold
==vertex
[0] || vold
==vertex
[1] || vold
==vertex
[2]);
89 //DIALOG_ASSERT(vnew!=vertex[0] && vnew!=vertex[1] && vnew!=vertex[2]);
95 else if(vold
==vertex
[1])
101 DIALOG_ASSERT(vold
==vertex
[2]);
105 vold
->removeFace(this);
106 vnew
->face
.push_back(this);
111 vold
->removeIfNonNeighbor(vertex
[i
]);
112 vertex
[i
]->removeIfNonNeighbor(vold
);
119 vertex
[i
]->addNeighbour(vertex
[j
]);