gpuray_glsl

view src/object.h @ 0:f234630e38ff

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 09 Nov 2014 13:03:36 +0200
parents
children
line source
1 /*
2 Simple introductory ray tracer
3 Copyright (C) 2012 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef OBJECT_H_
19 #define OBJECT_H_
21 #include "vmath/vmath.h"
22 #include "material.h"
23 #include "xform_node.h"
25 struct HitPoint;
27 class Object : public XFormNode {
28 public:
29 Matrix4x4 xform, inv_xform, dir_xform;
31 Material material; // surface material properties
33 virtual ~Object() {}
35 virtual void prepare_xform(long msec);
37 virtual bool intersect(const Ray &ray, HitPoint *pt) const = 0;
38 };
40 struct HitPoint {
41 float dist; // parametric distance of intersection along the ray
42 Vector3 pos; // world position of the intersection point
43 Vector3 normal; // surface normal vector at the intersection point
44 Vector2 texcoord; // texture coordinates at the intersection point
45 const Object *obj; // pointer to the intersected object
46 };
48 #endif // OBJECT_H_