| 1 | // tPolyModel.h  |
| 2 | //  |
| 3 | // This file implements tScene polygonal models. A tPolyModel contains a tMesh and a functional interface over it.  |
| 4 | //  |
| 5 | // Copyright (c) 2006, 2017, 2023 Tristan Grimmer.  |
| 6 | // Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby  |
| 7 | // granted, provided that the above copyright notice and this permission notice appear in all copies.  |
| 8 | //  |
| 9 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL  |
| 10 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,  |
| 11 | // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN  |
| 12 | // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR  |
| 13 | // PERFORMANCE OF THIS SOFTWARE.  |
| 14 |   |
| 15 | #pragma once  |
| 16 | #include "Scene/tObject.h"  |
| 17 | #include "Scene/tMesh.h"  |
| 18 | namespace tScene  |
| 19 | {  |
| 20 |   |
| 21 |   |
| 22 | class tPolyModel : public tObject  |
| 23 | {  |
| 24 | public:  |
| 25 | tPolyModel() { }  |
| 26 | tPolyModel(const tChunk& chunk) { Load(chunk); }  |
| 27 | virtual ~tPolyModel() { }  |
| 28 |   |
| 29 | void Save(tChunkWriter&) const;  |
| 30 | void Load(const tChunk&);  |
| 31 | void Clear() { tObject::Clear(); IsLodGroupMember = false; Mesh.Clear(); }  |
| 32 | void Scale(float scale) { Mesh.Scale(scale); }  |
| 33 |   |
| 34 | // The bounding radius is the same as the maxRadius, but if you need both it's more efficient to use the  |
| 35 | // ComputeMinMaxRadius function.  |
| 36 | float ComputeBoundingRadius() const;  |
| 37 | void ComputeMinMaxRadius(float& minRadius, float& maxRadius) const;  |
| 38 | tMath::tBox ComputeBoundingBox() const;  |
| 39 | float ComputeApproxArea() const;  |
| 40 | tPolyModel& operator=(const tPolyModel&);  |
| 41 |   |
| 42 | bool IsLodGroupMember = false; // This will be true if this model is a member of any LOD group.  |
| 43 | tMesh Mesh;  |
| 44 | };  |
| 45 |   |
| 46 |   |
| 47 | // Implementation below this line.  |
| 48 |   |
| 49 |   |
| 50 | inline tPolyModel& tPolyModel::operator=(const tPolyModel& src)  |
| 51 | {  |
| 52 | if (this == &src)  |
| 53 | return *this;  |
| 54 |   |
| 55 | tObject::operator=(src);  |
| 56 | IsLodGroupMember = src.IsLodGroupMember;  |
| 57 | Mesh = src.Mesh;  |
| 58 | return *this;  |
| 59 | }  |
| 60 |   |
| 61 |   |
| 62 | } |