00001
00002
00003
00004
00005
00006
00007 #ifndef PLANE_H
00008 #define PLANE_H
00009
00010 #include "raytrace_defs.h"
00011 #include "xml_util.h"
00012 #include "pluginfactory.h"
00013
00014 class Renderable;
00015 Renderable * new_plane(xmlNode * node);
00016
00017 class Plane : public Renderable {
00018 protected:
00020 class StaticInit {
00021 public:
00023 StaticInit() {
00024 log_debug("here");
00025 RenderableFactory::get_instance()->registerPlugin("plane", sigc::ptr_fun(new_plane));
00026 }
00027 };
00029 static StaticInit m_init;
00030
00033 Ray m_normal;
00034 Point3D m_point;
00035 double m_d;
00036
00037 public:
00039 Plane(Point3D p0, Point3D p1, Point3D p2, std::string color, std::string material, std::string bumpmap);
00040
00042
00043
00044 virtual ~Plane() {}
00045
00051 virtual bool collides_with(const Ray &ray, double &t) const;
00052
00054 virtual Ray get_normal(const Point3D &p) const;
00055 };
00056
00057 Renderable * new_plane(xmlNode * node) {
00058 log_debug("Entering new_plane()");
00059 Plane * rv = NULL;
00060
00061 xml_properties props = get_properties(node);
00062
00063 if ( props.empty() == false ) {
00064 rv = new Plane(
00065 props["p0"],
00066 props["p1"],
00067 props["p2"],
00068 props["color"],
00069 props["material"],
00070 props["bumpmap"]);
00071 }
00072 else {
00073 log_err("No properties specified for <plane> tag.");
00074 }
00075
00076 log_err("Leaving new_plane()");
00077 return dynamic_cast<Renderable *>(rv);
00078 }
00079
00080 void delete_plane(Plane * plane) {
00081 delete plane, plane = NULL;
00082 }
00083 #endif
00084