00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "asAabbox3d.h"
00018
00019 #ifdef __COMPILE_WITH_ANGELSCRIPT__
00020
00021 #include "asIrrHelper.h"
00022 #include "asVector3d.h"
00023 #include "asLine3d.h"
00024
00025
00026
00030 template<typename T>
00031 void constructor(void *memory)
00032 {
00033 new (memory) aabbox3d<T>();
00034 }
00035
00039 template<typename T>
00040 void constructor(T minX, T minY, T minZ, T maxX, T maxY, T maxZ, void *memory)
00041 {
00042 new (memory) aabbox3d<T>(minX, minY, minZ, maxX, maxY, maxZ);
00043 }
00044
00048 template<typename T>
00049 void constructor(const vector3d<T> &init, void *memory)
00050 {
00051 new (memory) aabbox3d<T>(init);
00052 }
00053
00057 template<typename T>
00058 void constructor(const vector3d<T> &min, const vector3d<T> &max, void *memory)
00059 {
00060 new (memory) aabbox3d<T>(min, max);
00061 }
00062
00066 template<typename T>
00067 void deconstructor(void *memory)
00068 {
00069 ((aabbox3d<T>*)memory)->~aabbox3d<T>();
00070 }
00071
00072
00077 template<typename T>
00078 void bindAabbox3dT(asIScriptEngine *engine, const char *typeName, const char *asType)
00079 {
00080
00081 int r;
00082 std::stringstream ss;
00083
00084
00085 r = engine->RegisterObjectType(typeName, sizeof(aabbox3d<T>), asOBJ_VALUE | asOBJ_APP_CLASS_CD); assert(r >= 0);
00086
00087
00088
00089 r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(constructor<T>,
00090 (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00091
00092 ss.str("");
00093 ss << "void f(" << asType << ", " << asType << ", " << asType << ", " << asType << ", "
00094 << asType << ", " << asType << ", " << asType << ")";
00095 r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, ss.str().c_str(), asFUNCTIONPR(constructor<T>,
00096 (T, T, T, T, T, T, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00097
00098 ss.str("");
00099 ss << "void f(const " << getVector3dName(asType) << " &in)";
00100 r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, ss.str().c_str(), asFUNCTIONPR(constructor<T>,
00101 (const vector3d<T>&, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00102
00103 ss.str("");
00104 ss << "void f(const " << getVector3dName(asType) << " &in, const " << getVector3dName(asType) << " &in)";
00105 r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, ss.str().c_str(), asFUNCTIONPR(constructor<T>,
00106 (const vector3d<T>&, const vector3d<T>&, void*), void), asCALL_CDECL_OBJLAST);
00107 assert(r >= 0);
00108
00109 r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_DESTRUCT, "void f()", asFUNCTION(deconstructor<T>),
00110 asCALL_CDECL_OBJLAST); assert(r >= 0);
00111
00112
00113 ss.str("");
00114 ss << "bool opEquals(const " << typeName << " &in)";
00115 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), asFUNCTIONPR(equal< aabbox3d<T> >,
00116 (const aabbox3d<T>&, const aabbox3d<T>&), bool), asCALL_CDECL_OBJFIRST); assert(r >= 0);
00117
00118
00119 ss.str("");
00120 ss << "void addInternalBox(const " << typeName << " &in)";
00121 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00122 asMETHOD(aabbox3d<T>, addInternalBox), asCALL_THISCALL); assert(r >= 0);
00123
00124 ss.str("");
00125 ss << "void addInternalPoint(const " << getVector3dName(asType) << " &in)";
00126 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00127 asMETHODPR(aabbox3d<T>, addInternalPoint, (const vector3d<T>&), void),
00128 asCALL_THISCALL); assert(r >= 0);
00129
00130 ss.str("");
00131 ss << asType << " getArea()";
00132 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00133 asMETHOD(aabbox3d<T>, getArea), asCALL_THISCALL); assert(r >= 0);
00134
00135 ss.str("");
00136 ss << getVector3dName(asType) << " getCenter()";
00137 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00138 asMETHOD(aabbox3d<T>, getCenter), asCALL_THISCALL); assert(r >= 0);
00139
00140 ss.str("");
00141 ss << getVector3dName(asType) << " getExtent()";
00142 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00143 asMETHOD(aabbox3d<T>, getExtent), asCALL_THISCALL); assert(r >= 0);
00144
00145 ss.str("");
00146 ss << typeName << " getInterpolated(const " << typeName << " &in, f64)";
00147 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00148 asMETHOD(aabbox3d<T>, getInterpolated), asCALL_THISCALL); assert(r >= 0);
00149
00150 ss.str("");
00151 ss << asType << " getVolume()";
00152 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00153 asMETHOD(aabbox3d<T>, getVolume), asCALL_THISCALL); assert(r >= 0);
00154
00155 ss.str("");
00156 ss << "bool intersectsWithBox(const " << typeName << " &in)";
00157 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00158 asMETHOD(aabbox3d<T>, intersectsWithBox), asCALL_THISCALL); assert(r >= 0);
00159
00160 ss.str("");
00161 ss << "bool isFullInside(const " << typeName << " &in)";
00162 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00163 asMETHOD(aabbox3d<T>, isFullInside), asCALL_THISCALL); assert(r >= 0);
00164
00165 ss.str("");
00166 ss << "bool isPointInside(const " << getVector3dName(asType) << " &in)";
00167 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00168 asMETHOD(aabbox3d<T>, isPointInside), asCALL_THISCALL); assert(r >= 0);
00169
00170 ss.str("");
00171 ss << "bool isPointTotalInside(const " << getVector3dName(asType) << " &in)";
00172 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00173 asMETHOD(aabbox3d<T>, isPointTotalInside), asCALL_THISCALL); assert(r >= 0);
00174
00175 r = engine->RegisterObjectMethod(typeName, "void repair()",
00176 asMETHOD(aabbox3d<T>, repair), asCALL_THISCALL); assert(r >= 0);
00177
00178 ss.str("");
00179 ss << "void reset(const " << getVector3dName(asType) << " &in)";
00180 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00181 asMETHODPR(aabbox3d<T>, reset, (const vector3d<T>&), void), asCALL_THISCALL);
00182 assert(r >= 0);
00183
00184 ss.str("");
00185 ss << "void reset(const " << typeName << " &in)";
00186 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00187 asMETHODPR(aabbox3d<T>, reset, (const aabbox3d<T>&), void), asCALL_THISCALL);
00188 assert(r >= 0);
00189
00190 ss.str("");
00191 ss << "void reset(" << asType << ", " << asType << ", " << asType << ")";
00192 r = engine->RegisterObjectMethod(typeName, ss.str().c_str(),
00193 asMETHODPR(aabbox3d<T>, reset, (T, T, T), void), asCALL_THISCALL);
00194 assert(r >= 0);
00195
00196
00197 ss.str("");
00198 ss << getVector3dName(asType) << " MaxEdge";
00199 r = engine->RegisterObjectProperty(typeName, ss.str().c_str(), offsetof(aabbox3d<T>, MaxEdge)); assert(r >= 0);
00200
00201 ss.str("");
00202 ss << getVector3dName(asType) << " MinEdge";
00203 r = engine->RegisterObjectProperty(typeName, ss.str().c_str(), offsetof(aabbox3d<T>, MinEdge)); assert(r >= 0);
00204 }
00205
00208 void bindAabbox3d(asIScriptEngine *engine)
00209 {
00210 bindAabbox3dT<f32>(engine, "aabbox3df", "f32");
00211 bindAabbox3dT<s32>(engine, "aabbox3di", "f32");
00212
00213
00214 int r;
00215
00216 r = engine->RegisterObjectMethod("aabbox3df", "bool intersectsWithLine(line3df &in)",
00217 asMETHODPR(aabbox3d<f32>, intersectsWithLine, (const line3d<f32>&) const, bool),
00218 asCALL_THISCALL); assert(r >= 0);
00219
00220
00221 r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)",
00222 asMETHODPR(aabbox3d<f32>, intersectsWithLine, (const line3d<f32>&) const, bool),
00223 asCALL_THISCALL); assert(r >= 0);
00224 }
00225
00228 std::string getAabbox3dName(const std::string &asType)
00229 {
00230 if(asType == "f32") return std::string("aabbox3df");
00231 if(asType == "s32") return std::string("aabbox3di");
00232 else return std::string("");
00233 }
00234
00235 #endif // __COMPILE_WITH_ANGELSCRIPT__
00236
00237