00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TOXIC_RENDERER_IOBJECT_H
00024 #define TOXIC_RENDERER_IOBJECT_H
00025
00026 #include "common/math/matrix4.h"
00027 #include "basis.h"
00028 #include "globals.h"
00029
00030 namespace toxic {
00031
00032 class Context;
00033 class Framebuffer;
00034 class Hit;
00035 class ICamera;
00036 class ISurfaceShader;
00037 class Ray;
00038 class Scene;
00039
00040 class IObject : public Basis {
00041 public:
00042 enum IntersectionMask {
00043 INTERSECT_NO_RAYS = 0,
00044 INTERSECT_VISIBILITY_RAYS = 1,
00045 INTERSECT_PRIMARY_RAYS = 2,
00046 INTERSECT_REFLECTED_RAYS = 4,
00047 INTERSECT_SHADOW_RAYS = 8,
00048 INTERSECT_PHOTON_RAYS = 16,
00049 INTERSECT_PRIMARY_FG_RAYS = 32,
00050 INTERSECT_SECONDARY_FG_RAYS = 64,
00051 INTERSECT_AUTOFOCUS_RAYS = 128,
00052
00053
00054 INTERSECT_ALL_RAYS =
00055 INTERSECT_VISIBILITY_RAYS |
00056 INTERSECT_PRIMARY_RAYS |
00057 INTERSECT_REFLECTED_RAYS |
00058 INTERSECT_SHADOW_RAYS |
00059 INTERSECT_PHOTON_RAYS |
00060 INTERSECT_PRIMARY_FG_RAYS |
00061 INTERSECT_SECONDARY_FG_RAYS |
00062 INTERSECT_AUTOFOCUS_RAYS
00063 };
00064
00065 #ifdef USE_MAILBOXES
00066
00067 mutable int m_mailbox_ray_id;
00068 #endif // USE_MAILBOXES
00069
00070
00071
00072
00073 IObject(
00074 const sheep::Matrix4 &m,
00075 const ISurfaceShader *surface_shader = 0,
00076 IntersectionMask intersection_mask = INTERSECT_ALL_RAYS
00077 );
00078
00079 virtual ~IObject() {}
00080
00081
00082
00083 virtual void Finalize(const Context &context) {}
00084
00085
00086
00087
00088 virtual int GetObjectCount() const { return 1; }
00089
00090 void SetSurfaceShader(const ISurfaceShader *surface_shader);
00091 const ISurfaceShader *GetSurfaceShader() const;
00092
00093
00094
00095
00096
00097 virtual bool Intersect(
00098 const Context &context,
00099 const Ray &ray,
00100 Hit *hit = 0
00101 ) const = 0;
00102
00103 virtual void Annotate(
00104 const Context &context,
00105 const ICamera *camera,
00106 Framebuffer *framebuffer
00107 ) const {}
00108
00109 protected:
00110 const ISurfaceShader *m_surface_shader;
00111 IntersectionMask m_intersection_mask;
00112 };
00113
00114 #include "iobject.inl"
00115
00116 }
00117
00118 #endif // !TOXIC_RENDERER_IOBJECT_H