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.

RevLine 
[1315]1#include "IntersectableWrapper.h"
[1328]2#include "Mesh.h"
3#include "Triangle3.h"
[1199]4
5
6namespace GtpVisibilityPreprocessor {
7
8
[1328]9AxisAlignedBox3 TriangleIntersectable::GetBox() const
[1327]10{       
[1344]11        return mItem.GetBoundingBox();
[1327]12}
[1199]13
[1327]14
[1328]15int TriangleIntersectable::CastRay(Ray &ray)
[1344]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
[1327]42        return 0;
43}
[1199]44       
[1327]45
[1328]46int TriangleIntersectable::NumberOfFaces() const
[1327]47{
[1328]48        return 1;
[1327]49}
50
[1344]51
52Vector3 TriangleIntersectable::GetNormal(const int idx) const
53{
54        return mItem.GetNormal();
55}
56
57 
[1138]58}
Note: See TracBrowser for help on using the repository browser.