source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp @ 245

Revision 245, 1.4 KB checked in by bittner, 19 years ago (diff)

Merged sources with ViewCellBsp?

Line 
1#include "ViewCell.h"
2#include "Mesh.h"
3#include "MeshKdTree.h"
4#include "Triangle3.h"
5
6
7ViewCell::ViewCell(Mesh *mesh): mMesh(mesh), mPvs(NULL)
8{
9}
10
11Mesh *ViewCell::GetMesh()
12{
13        return mMesh;
14}
15
16BspPvs *ViewCell::GetPVS()
17{
18        return mPvs;
19}
20
21AxisAlignedBox3 ViewCell::GetBox()
22{
23        return mMesh->mBox;
24}
25 
26int ViewCell::CastRay(Ray &ray)
27{
28        return 0;
29}
30 
31bool ViewCell::IsConvex()
32{
33        return mMesh->mIsConvex;
34}
35
36bool ViewCell::IsWatertight()
37{
38        return mMesh->mIsWatertight;
39}
40
41float ViewCell::IntersectionComplexity()
42{
43        return (float)mMesh->mFaces.size();
44}
45
46int ViewCell::Type() const
47{
48        return VIEWCELL;
49}
50
51void  ViewCell::GetRandomSurfacePoint(Vector3 &point, Vector3 &normal)
52{
53        point = Vector3(0,0,0);
54}
55
56void ViewCell::DeriveViewCells(const ObjectContainer &objects,
57                                                           ViewCellContainer &viewCells,
58                                                           const int maxViewCells)
59{
60        // maximal max viewcells
61        int limit = maxViewCells > 0 ? Min((int)objects.size(), maxViewCells) : (int)objects.size();
62
63        for (int i = 0; i < limit; ++i)
64        {
65                Intersectable *object = objects[i];
66
67                // extract the mesh instances
68                if (object->Type() == Intersectable::MESH_INSTANCE)
69                {
70                        MeshInstance *inst = dynamic_cast<MeshInstance *>(object);
71
72                        ViewCell *viewCell = new ViewCell(inst->GetMesh());
73                        viewCells.push_back(viewCell);
74                }
75                //TODO: transformed meshes
76        }
77}
Note: See TracBrowser for help on using the repository browser.