source: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp @ 1344

Revision 1344, 1.0 KB checked in by mattausch, 18 years ago (diff)

worked on triangle processing. logical units will be created by grouping objects
using their visibility definitions.

Line 
1#include "IntersectableWrapper.h"
2#include "Mesh.h"
3#include "Triangle3.h"
4
5
6namespace GtpVisibilityPreprocessor {
7
8
9AxisAlignedBox3 TriangleIntersectable::GetBox() const
10{       
11        return mItem.GetBoundingBox();
12}
13
14
15int TriangleIntersectable::CastRay(Ray &ray)
16{       
17        float nearestT = MAX_FLOAT;
18        float t;
19        Vector3 nearestNormal;
20
21        if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty())
22                nearestT = ray.intersections[0].mT;
23
24        const int hitCode = mItem.CastRay(ray, t, nearestT, nearestNormal);
25
26        nearestT = t;
27
28        if ((hitCode == Ray::INTERSECTION) && (ray.GetType() == Ray::LOCAL_RAY))
29        {
30                if (!ray.intersections.empty())
31                {
32                        ray.intersections[0] = Ray::Intersection(nearestT, nearestNormal, this, 0);
33                }
34                else
35                {
36                        ray.intersections.push_back(Ray::Intersection(nearestT, nearestNormal, this, 0));
37                }
38               
39                return 1;
40        }
41
42        return 0;
43}
44       
45
46int TriangleIntersectable::NumberOfFaces() const
47{
48        return 1;
49}
50
51
52Vector3 TriangleIntersectable::GetNormal(const int idx) const
53{
54        return mItem.GetNormal();
55}
56
57 
58}
Note: See TracBrowser for help on using the repository browser.