00001
00002 #include "PlaneShape.h"
00003
00004 #include "PhysicsManager.h"
00005
00006 #include <vrs/colorattribute.h>
00007 #include <vrs/constantdetail.h>
00008 #include <vrs/facestyle.h>
00009 #include <vrs/plane.h>
00010
00011 namespace vrsode
00012 {
00013
00014 PlaneShape::PlaneShape(VRS::Vector p_normal, double p_anchor)
00015 {
00016 setCollisionShape(CS_Plane);
00017
00018 m_normal = p_normal;
00019 m_anchor = p_anchor;
00020
00021 createGeometry();
00022 createDebugNode();
00023 }
00024
00025 PlaneShape::~PlaneShape()
00026 {
00027
00028 }
00029
00030 void
00031 PlaneShape::createGeometry()
00032 {
00033
00034 setGeomId(dCreatePlane(0, m_normal[0], m_normal[1], m_normal[2], m_anchor));
00035 }
00036
00037 void
00038 PlaneShape::createDebugNode()
00039 {
00040 debugNode()->clear();
00041
00042 if(!debugNodeActive())
00043 return;
00044
00045 debugNode()->append(new VRS::ColorAttribute(1.0, 0.3, 0.3, 0.3));
00046 debugNode()->append(new VRS::ConstantDetail(1, 1));
00047 debugNode()->append(new VRS::Plane(m_normal, m_normal * m_anchor));
00048 }
00049
00050 double
00051 PlaneShape::anchor()
00052 {
00053 return m_anchor;
00054 }
00055
00056 VRS::Vector
00057 PlaneShape::normal()
00058 {
00059 return m_normal;
00060 }
00061
00062 void
00063 PlaneShape::setAnchor(double p_anchor)
00064 {
00065
00066 m_anchor = p_anchor;
00067 createDebugNode();
00068 dGeomPlaneSetParams(geomId(),
00069 m_normal[0], m_normal[1], m_normal[2], m_anchor);
00070 }
00071
00072 void
00073 PlaneShape::setNormal(VRS::Vector p_normal)
00074 {
00075
00076 m_normal = p_normal;
00077 createDebugNode();
00078 dGeomPlaneSetParams(geomId(),
00079 m_normal[0], m_normal[1], m_normal[2], m_anchor);
00080 }
00081
00082 void
00083 PlaneShape::setNormalAndAnchor(VRS::Vector p_normal, double p_anchor)
00084 {
00085
00086 m_normal = p_normal;
00087 m_anchor = p_anchor;
00088 createDebugNode();
00089 dGeomPlaneSetParams(geomId(),
00090 m_normal[0], m_normal[1], m_normal[2], m_anchor);
00091 }
00092
00093 }