MPMA Framework 0.4
|
00001 00002 //Luke Lenhart (2005-2008) 00003 //See /docs/License.txt for details on how this code may be used. 00004 00005 #pragma once 00006 00007 #include "../base/Setup.h" 00008 00009 #ifdef MPMA_COMPILE_GEO 00010 00011 #include "Geo.h" 00012 00013 namespace GEO 00014 { 00015 // -- 3D 00016 00018 struct Line 00019 { 00020 Vector3 pos; 00021 Vector3 dir; 00022 00023 // 00024 inline Line() {} 00025 inline Line(const Vector3 &inPos, const Vector3 &inDir) 00026 { pos=inPos; dir=inDir; } 00027 }; 00028 00030 struct Plane 00031 { 00032 float c0,c1,c2,c3; 00033 00034 // 00035 inline Plane() {} 00036 00037 inline Plane(const Vector3 &inPos, const Vector3 &inNormal) 00038 { 00039 Normal()=inNormal; 00040 Renormalize(); 00041 c3=-VecDot(inPos,Normal()); 00042 } 00044 inline Plane(float inC0,float inC1,float inC2,float inC3): c0(inC0), c1(inC1), c2(inC2), c3(inC3) 00045 { Renormalize(); } 00046 00048 inline Vector3& Normal() const { return *((Vector3*)this); } 00049 00051 inline void Renormalize() { Normal().Normalize(); } 00052 }; 00053 00055 struct Sphere 00056 { 00057 Vector3 pos; 00058 float radius; 00059 00060 // 00061 inline Sphere() {} 00062 inline Sphere(const Vector3 &p, float r) 00063 { pos=p; radius=r; } 00064 }; 00065 00067 struct AARectoid 00068 { 00069 Vector3 center; 00070 float xradius; 00071 float yradius; 00072 float zradius; 00073 00074 // 00075 inline AARectoid() {} 00076 inline AARectoid(Vector3 c, float x, float y, float z) 00077 { center=c; xradius=x; yradius=y; zradius=z; } 00078 }; 00079 00081 struct XAlignedUnboundedCylinder: Line 00082 { 00083 float y; 00084 float z; 00085 float radius; 00086 00087 // 00088 inline XAlignedUnboundedCylinder() {} 00089 inline XAlignedUnboundedCylinder(float ypos, float zpos, float rad) 00090 { y=ypos; z=zpos; radius=rad; } 00091 }; 00092 00094 struct YAlignedEllipsoid: Sphere 00095 { 00096 float ymultiplier; 00097 00098 // 00099 inline YAlignedEllipsoid() {} 00100 inline YAlignedEllipsoid(const Vector3 &p, float r, float ymod) 00101 { pos=p; radius=r; ymultiplier=ymod; } 00102 }; 00103 00104 // -- 2D 00105 00107 struct Line2D 00108 { 00109 Vector2 pos; 00110 Vector2 dir; 00111 00112 // 00113 inline Line2D() {} 00114 inline Line2D(const Vector2 &inPos, const Vector2 &inDir) 00115 { pos=inPos; dir=inDir; } 00116 }; 00117 00119 struct Circle 00120 { 00121 Vector2 pos; 00122 float radius; 00123 00124 inline Circle() {} 00125 inline Circle(GEO::Vector2 position, float rad) 00126 { pos=position; radius=rad; } 00127 }; 00128 00130 struct AxisAlignedEllipse 00131 { 00132 Vector2 pos; 00133 float radius; 00134 float xmod; 00135 float ymod; 00136 00137 inline AxisAlignedEllipse() {} 00138 inline AxisAlignedEllipse(Vector2 position, float rad, float xax, float yax) 00139 { pos=position; radius=rad; xmod=xax; ymod=yax; } 00140 }; 00141 00142 }; //namespace GEO 00143 00144 #endif //#ifdef MPMA_COMPILE_GEO