00001 #ifdef USE_LUGRE_LIB_CADUNE_TREE
00002
00003 #include "lugre_prefix.h"
00004 #include "lugre_gfx3D.h"
00005 #include "lugre_scripting.h"
00006 #include "lugre_ogrewrapper.h"
00007 #include "lugre_input.h"
00008 #include "lugre_robstring.h"
00009 #include "lugre_luabind.h"
00010 #include <Ogre.h>
00011
00012 #include "CTParameters.h"
00013 #include "CTStem.h"
00014 #include "CTSection.h"
00015
00016 extern "C" {
00017 #include "lua.h"
00018 #include "lauxlib.h"
00019 #include "lualib.h"
00020 }
00021
00022 using namespace Ogre;
00023
00024 namespace Lugre {
00025 class cCaduneTreeParameters_L : public cLuaBind<CaduneTree::Parameters> { public:
00026 virtual void RegisterMethods (lua_State *L) { PROFILE
00027 lua_register(L,"CreateCaduneTreeParameters", &cCaduneTreeParameters_L::CreateCaduneTreeParameters);
00028
00029 #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cCaduneTreeParameters_L::methodname));
00030
00031 REGISTER_METHOD(Destroy);
00032
00033 REGISTER_METHOD(SetDefault);
00034 REGISTER_METHOD(CreateCopy);
00035 REGISTER_METHOD(SetShape);
00036 REGISTER_METHOD(SetBaseSize);
00037 REGISTER_METHOD(SetScale);
00038 REGISTER_METHOD(SetScaleV);
00039 REGISTER_METHOD(SetNumLevels);
00040 REGISTER_METHOD(SetRatio);
00041 REGISTER_METHOD(SetRatioPower);
00042 REGISTER_METHOD(SetNumLobes);
00043 REGISTER_METHOD(SetLobeDepth);
00044 REGISTER_METHOD(SetFlare);
00045 REGISTER_METHOD(SetScale0);
00046 REGISTER_METHOD(SetScale0V);
00047 REGISTER_METHOD(SetBarkMaterial);
00048 REGISTER_METHOD(SetLeafScale);
00049 REGISTER_METHOD(SetLeafScaleX);
00050 REGISTER_METHOD(SetNumLeaves);
00051 REGISTER_METHOD(SetLeafQuality);
00052 REGISTER_METHOD(SetLeafLayoutExp);
00053 REGISTER_METHOD(SetLeafMaterial);
00054 REGISTER_METHOD(SetFrondScale);
00055 REGISTER_METHOD(SetFrondScaleX);
00056 REGISTER_METHOD(SetNumFronds);
00057 REGISTER_METHOD(SetFrondQuality);
00058 REGISTER_METHOD(SetFrondMaterial);
00059 REGISTER_METHOD(SetAttractionUp);
00060 REGISTER_METHOD(SetNumVertices);
00061 REGISTER_METHOD(SetNumBranches);
00062 REGISTER_METHOD(SetDownAngle);
00063 REGISTER_METHOD(SetDownAngleV);
00064 REGISTER_METHOD(SetRotate);
00065 REGISTER_METHOD(SetRotateV);
00066 REGISTER_METHOD(SetLength);
00067 REGISTER_METHOD(SetLengthV);
00068 REGISTER_METHOD(SetCurve);
00069 REGISTER_METHOD(SetCurveBack);
00070 REGISTER_METHOD(SetCurveV);
00071 REGISTER_METHOD(SetCurveRes);
00072 REGISTER_METHOD(GetMaxLevels);
00073 REGISTER_METHOD(GetShape);
00074 REGISTER_METHOD(GetBaseSize);
00075 REGISTER_METHOD(GetScale);
00076 REGISTER_METHOD(GetScaleV);
00077 REGISTER_METHOD(GetNumLevels);
00078 REGISTER_METHOD(GetRatio);
00079 REGISTER_METHOD(GetRatioPower);
00080 REGISTER_METHOD(GetNumLobes);
00081 REGISTER_METHOD(GetLobeDepth);
00082 REGISTER_METHOD(GetFlare);
00083 REGISTER_METHOD(GetScale0);
00084 REGISTER_METHOD(GetScale0V);
00085 REGISTER_METHOD(GetBarkMaterial);
00086 REGISTER_METHOD(GetLeafScale);
00087 REGISTER_METHOD(GetLeafScaleX);
00088 REGISTER_METHOD(GetNumLeaves);
00089 REGISTER_METHOD(GetLeafQuality);
00090 REGISTER_METHOD(GetLeafLayoutExp);
00091 REGISTER_METHOD(GetLeafMaterial);
00092 REGISTER_METHOD(GetFrondScale);
00093 REGISTER_METHOD(GetFrondScaleX);
00094 REGISTER_METHOD(GetNumFronds);
00095 REGISTER_METHOD(GetFrondQuality);
00096 REGISTER_METHOD(GetFrondMaterial);
00097 REGISTER_METHOD(GetAttractionUp);
00098 REGISTER_METHOD(GetTaper);
00099 REGISTER_METHOD(GetNumVertices);
00100 REGISTER_METHOD(GetNumBranches);
00101 REGISTER_METHOD(GetDownAngle);
00102 REGISTER_METHOD(GetDownAngleV);
00103 REGISTER_METHOD(GetRotate);
00104 REGISTER_METHOD(GetRotateV);
00105 REGISTER_METHOD(GetLength);
00106 REGISTER_METHOD(GetLengthV);
00107 REGISTER_METHOD(GetCurve);
00108 REGISTER_METHOD(GetCurveBack);
00109 REGISTER_METHOD(GetCurveV);
00110 REGISTER_METHOD(GetCurveRes);
00111
00112 #undef REGISTER_METHOD
00113
00114 #define RegisterClassConstant(name,constant) cScripting::SetGlobal(L,#name,constant)
00115 RegisterClassConstant(CT_CONICAL,CaduneTree::CONICAL);
00116 RegisterClassConstant(CT_SPHERICAL,CaduneTree::SPHERICAL);
00117 RegisterClassConstant(CT_HEMISPHERICAL,CaduneTree::HEMISPHERICAL);
00118 RegisterClassConstant(CT_CYLINDRICAL,CaduneTree::CYLINDRICAL);
00119 RegisterClassConstant(CT_TAPERED_CYLINDRICAL,CaduneTree::TAPERED_CYLINDRICAL);
00120 RegisterClassConstant(CT_FLAME,CaduneTree::FLAME);
00121 RegisterClassConstant(CT_INVERSE_CONICAL,CaduneTree::INVERSE_CONICAL);
00122 RegisterClassConstant(CT_TEND_FLAME,CaduneTree::TEND_FLAME);
00123 #undef RegisterClassConstant
00124 }
00125 virtual const char* GetLuaTypeName () { return "lugre.cadune.parameters"; }
00126
00127 static int CreateCaduneTreeParameters (lua_State *L) { PROFILE
00128 return CreateUData(L,new CaduneTree::Parameters());
00129 }
00130
00132 static int Destroy (lua_State *L) { PROFILE
00133 delete checkudata_alive(L);
00134 return 0;
00135 }
00136
00138 static int SetDefault (lua_State *L) { PROFILE
00139
00140
00141 checkudata_alive(L)->setDefault();
00142
00143 return 0;
00144 }
00145
00147 static int CreateCopy (lua_State *L) { PROFILE
00148
00149
00150 CaduneTree::Parameters* r = checkudata_alive(L)->createCopy();
00151
00152 cLuaBind<CaduneTree::Parameters>::CreateUData(L,r);
00153 return 1;
00154 }
00155
00157 static int SetShape (lua_State *L) { PROFILE
00158
00159 CaduneTree::ShapeEnum p0 = (CaduneTree::ShapeEnum)luaL_checkint(L, 2);
00160
00161 checkudata_alive(L)->setShape(p0);
00162
00163 return 0;
00164 }
00165
00167 static int SetBaseSize (lua_State *L) { PROFILE
00168
00169 float p0 = luaL_checknumber(L, 2);
00170
00171 checkudata_alive(L)->setBaseSize(p0);
00172
00173 return 0;
00174 }
00175
00177 static int SetScale (lua_State *L) { PROFILE
00178
00179 float p0 = luaL_checknumber(L, 2);
00180
00181 checkudata_alive(L)->setScale(p0);
00182
00183 return 0;
00184 }
00185
00187 static int SetScaleV (lua_State *L) { PROFILE
00188
00189 float p0 = luaL_checknumber(L, 2);
00190
00191 checkudata_alive(L)->setScaleV(p0);
00192
00193 return 0;
00194 }
00195
00197 static int SetNumLevels (lua_State *L) { PROFILE
00198
00199 unsigned char p0 = luaL_checkint(L, 2);
00200
00201 checkudata_alive(L)->setNumLevels(p0);
00202
00203 return 0;
00204 }
00205
00207 static int SetRatio (lua_State *L) { PROFILE
00208
00209 float p0 = luaL_checknumber(L, 2);
00210
00211 checkudata_alive(L)->setRatio(p0);
00212
00213 return 0;
00214 }
00215
00217 static int SetRatioPower (lua_State *L) { PROFILE
00218
00219 float p0 = luaL_checknumber(L, 2);
00220
00221 checkudata_alive(L)->setRatioPower(p0);
00222
00223 return 0;
00224 }
00225
00227 static int SetNumLobes (lua_State *L) { PROFILE
00228
00229 unsigned char p0 = luaL_checkint(L, 2);
00230
00231 checkudata_alive(L)->setNumLobes(p0);
00232
00233 return 0;
00234 }
00235
00237 static int SetLobeDepth (lua_State *L) { PROFILE
00238
00239 float p0 = luaL_checknumber(L, 2);
00240
00241 checkudata_alive(L)->setLobeDepth(p0);
00242
00243 return 0;
00244 }
00245
00247 static int SetFlare (lua_State *L) { PROFILE
00248
00249 float p0 = luaL_checknumber(L, 2);
00250
00251 checkudata_alive(L)->setFlare(p0);
00252
00253 return 0;
00254 }
00255
00257 static int SetScale0 (lua_State *L) { PROFILE
00258
00259 float p0 = luaL_checknumber(L, 2);
00260
00261 checkudata_alive(L)->setScale0(p0);
00262
00263 return 0;
00264 }
00265
00267 static int SetScale0V (lua_State *L) { PROFILE
00268
00269 float p0 = luaL_checknumber(L, 2);
00270
00271 checkudata_alive(L)->setScale0V(p0);
00272
00273 return 0;
00274 }
00275
00277 static int SetBarkMaterial (lua_State *L) { PROFILE
00278
00279 Ogre::String p0 = luaL_checkstring(L, 2);
00280
00281 checkudata_alive(L)->setBarkMaterial(p0);
00282
00283 return 0;
00284 }
00285
00287 static int SetLeafScale (lua_State *L) { PROFILE
00288
00289 float p0 = luaL_checknumber(L, 2);
00290
00291 checkudata_alive(L)->setLeafScale(p0);
00292
00293 return 0;
00294 }
00295
00297 static int SetLeafScaleX (lua_State *L) { PROFILE
00298
00299 float p0 = luaL_checknumber(L, 2);
00300
00301 checkudata_alive(L)->setLeafScaleX(p0);
00302
00303 return 0;
00304 }
00305
00307 static int SetNumLeaves (lua_State *L) { PROFILE
00308
00309 unsigned char p0 = luaL_checkint(L, 2);
00310
00311 checkudata_alive(L)->setNumLeaves(p0);
00312
00313 return 0;
00314 }
00315
00317 static int SetLeafQuality (lua_State *L) { PROFILE
00318
00319 float p0 = luaL_checknumber(L, 2);
00320
00321 checkudata_alive(L)->setLeafQuality(p0);
00322
00323 return 0;
00324 }
00325
00327 static int SetLeafLayoutExp (lua_State *L) { PROFILE
00328
00329 float p0 = luaL_checknumber(L, 2);
00330
00331 checkudata_alive(L)->setLeafLayoutExp(p0);
00332
00333 return 0;
00334 }
00335
00337 static int SetLeafMaterial (lua_State *L) { PROFILE
00338
00339 Ogre::String p0 = luaL_checkstring(L, 2);
00340
00341 checkudata_alive(L)->setLeafMaterial(p0);
00342
00343 return 0;
00344 }
00345
00347 static int SetFrondScale (lua_State *L) { PROFILE
00348
00349 float p0 = luaL_checknumber(L, 2);
00350
00351 checkudata_alive(L)->setFrondScale(p0);
00352
00353 return 0;
00354 }
00355
00357 static int SetFrondScaleX (lua_State *L) { PROFILE
00358
00359 float p0 = luaL_checknumber(L, 2);
00360
00361 checkudata_alive(L)->setFrondScaleX(p0);
00362
00363 return 0;
00364 }
00365
00367 static int SetNumFronds (lua_State *L) { PROFILE
00368
00369 unsigned char p0 = luaL_checkint(L, 2);
00370
00371 checkudata_alive(L)->setNumFronds(p0);
00372
00373 return 0;
00374 }
00375
00377 static int SetFrondQuality (lua_State *L) { PROFILE
00378
00379 float p0 = luaL_checknumber(L, 2);
00380
00381 checkudata_alive(L)->setFrondQuality(p0);
00382
00383 return 0;
00384 }
00385
00387 static int SetFrondMaterial (lua_State *L) { PROFILE
00388
00389 Ogre::String p0 = luaL_checkstring(L, 2);
00390
00391 checkudata_alive(L)->setFrondMaterial(p0);
00392
00393 return 0;
00394 }
00395
00397 static int SetAttractionUp (lua_State *L) { PROFILE
00398
00399 float p0 = luaL_checknumber(L, 2);
00400
00401 checkudata_alive(L)->setAttractionUp(p0);
00402
00403 return 0;
00404 }
00405
00407 static int SetNumVertices (lua_State *L) { PROFILE
00408
00409 unsigned int p0 = luaL_checkint(L, 2);
00410 unsigned char p1 = luaL_checkint(L, 3);
00411
00412 checkudata_alive(L)->setNumVertices(p0, p1);
00413
00414 return 0;
00415 }
00416
00418 static int SetNumBranches (lua_State *L) { PROFILE
00419
00420 unsigned int p0 = luaL_checkint(L, 2);
00421 unsigned char p1 = luaL_checkint(L, 3);
00422
00423 checkudata_alive(L)->setNumBranches(p0, p1);
00424
00425 return 0;
00426 }
00427
00429 static int SetDownAngle (lua_State *L) { PROFILE
00430
00431 unsigned int p0 = luaL_checkint(L, 2);
00432 float p1 = luaL_checknumber(L, 3);
00433
00434 checkudata_alive(L)->setDownAngle(p0, p1);
00435
00436 return 0;
00437 }
00438
00440 static int SetDownAngleV (lua_State *L) { PROFILE
00441
00442 unsigned int p0 = luaL_checkint(L, 2);
00443 float p1 = luaL_checknumber(L, 3);
00444
00445 checkudata_alive(L)->setDownAngleV(p0, p1);
00446
00447 return 0;
00448 }
00449
00451 static int SetRotate (lua_State *L) { PROFILE
00452
00453 unsigned int p0 = luaL_checkint(L, 2);
00454 float p1 = luaL_checknumber(L, 3);
00455
00456 checkudata_alive(L)->setRotate(p0, p1);
00457
00458 return 0;
00459 }
00460
00462 static int SetRotateV (lua_State *L) { PROFILE
00463
00464 unsigned int p0 = luaL_checkint(L, 2);
00465 float p1 = luaL_checknumber(L, 3);
00466
00467 checkudata_alive(L)->setRotateV(p0, p1);
00468
00469 return 0;
00470 }
00471
00473 static int SetLength (lua_State *L) { PROFILE
00474
00475 unsigned int p0 = luaL_checkint(L, 2);
00476 float p1 = luaL_checknumber(L, 3);
00477
00478 checkudata_alive(L)->setLength(p0, p1);
00479
00480 return 0;
00481 }
00482
00484 static int SetLengthV (lua_State *L) { PROFILE
00485
00486 unsigned int p0 = luaL_checkint(L, 2);
00487 float p1 = luaL_checknumber(L, 3);
00488
00489 checkudata_alive(L)->setLengthV(p0, p1);
00490
00491 return 0;
00492 }
00493
00495 static int SetCurve (lua_State *L) { PROFILE
00496
00497 unsigned int p0 = luaL_checkint(L, 2);
00498 float p1 = luaL_checknumber(L, 3);
00499
00500 checkudata_alive(L)->setCurve(p0, p1);
00501
00502 return 0;
00503 }
00504
00506 static int SetCurveBack (lua_State *L) { PROFILE
00507
00508 unsigned int p0 = luaL_checkint(L, 2);
00509 float p1 = luaL_checknumber(L, 3);
00510
00511 checkudata_alive(L)->setCurveBack(p0, p1);
00512
00513 return 0;
00514 }
00515
00517 static int SetCurveV (lua_State *L) { PROFILE
00518
00519 unsigned int p0 = luaL_checkint(L, 2);
00520 float p1 = luaL_checknumber(L, 3);
00521
00522 checkudata_alive(L)->setCurveV(p0, p1);
00523
00524 return 0;
00525 }
00526
00528 static int SetCurveRes (lua_State *L) { PROFILE
00529
00530 unsigned int p0 = luaL_checkint(L, 2);
00531 unsigned char p1 = luaL_checkint(L, 3);
00532
00533 checkudata_alive(L)->setCurveRes(p0, p1);
00534
00535 return 0;
00536 }
00537
00539 static int GetMaxLevels (lua_State *L) { PROFILE
00540
00541
00542 int r = checkudata_alive(L)->getMaxLevels();
00543
00544 lua_pushnumber(L, r);
00545 return 1;
00546 }
00547
00549 static int GetShape (lua_State *L) { PROFILE
00550
00551
00552 CaduneTree::ShapeEnum r = checkudata_alive(L)->getShape();
00553
00554 lua_pushnumber(L, r);
00555 return 1;
00556 }
00557
00559 static int GetBaseSize (lua_State *L) { PROFILE
00560
00561
00562 float r = checkudata_alive(L)->getBaseSize();
00563
00564 lua_pushnumber(L, r);
00565 return 1;
00566 }
00567
00569 static int GetScale (lua_State *L) { PROFILE
00570
00571
00572 float r = checkudata_alive(L)->getScale();
00573
00574 lua_pushnumber(L, r);
00575 return 1;
00576 }
00577
00579 static int GetScaleV (lua_State *L) { PROFILE
00580
00581
00582 float r = checkudata_alive(L)->getScaleV();
00583
00584 lua_pushnumber(L, r);
00585 return 1;
00586 }
00587
00589 static int GetNumLevels (lua_State *L) { PROFILE
00590
00591
00592 char r = checkudata_alive(L)->getNumLevels();
00593
00594 lua_pushnumber(L, r);
00595 return 1;
00596 }
00597
00599 static int GetRatio (lua_State *L) { PROFILE
00600
00601
00602 float r = checkudata_alive(L)->getRatio();
00603
00604 lua_pushnumber(L, r);
00605 return 1;
00606 }
00607
00609 static int GetRatioPower (lua_State *L) { PROFILE
00610
00611
00612 float r = checkudata_alive(L)->getRatioPower();
00613
00614 lua_pushnumber(L, r);
00615 return 1;
00616 }
00617
00619 static int GetNumLobes (lua_State *L) { PROFILE
00620
00621
00622 char r = checkudata_alive(L)->getNumLobes();
00623
00624 lua_pushnumber(L, r);
00625 return 1;
00626 }
00627
00629 static int GetLobeDepth (lua_State *L) { PROFILE
00630
00631
00632 float r = checkudata_alive(L)->getLobeDepth();
00633
00634 lua_pushnumber(L, r);
00635 return 1;
00636 }
00637
00639 static int GetFlare (lua_State *L) { PROFILE
00640
00641
00642 float r = checkudata_alive(L)->getFlare();
00643
00644 lua_pushnumber(L, r);
00645 return 1;
00646 }
00647
00649 static int GetScale0 (lua_State *L) { PROFILE
00650
00651
00652 float r = checkudata_alive(L)->getScale0();
00653
00654 lua_pushnumber(L, r);
00655 return 1;
00656 }
00657
00659 static int GetScale0V (lua_State *L) { PROFILE
00660
00661
00662 float r = checkudata_alive(L)->getScale0V();
00663
00664 lua_pushnumber(L, r);
00665 return 1;
00666 }
00667
00669 static int GetBarkMaterial (lua_State *L) { PROFILE
00670
00671
00672 Ogre::String r = checkudata_alive(L)->getBarkMaterial();
00673
00674 lua_pushstring(L, r.c_str());
00675 return 1;
00676 }
00677
00679 static int GetLeafScale (lua_State *L) { PROFILE
00680
00681
00682 float r = checkudata_alive(L)->getLeafScale();
00683
00684 lua_pushnumber(L, r);
00685 return 1;
00686 }
00687
00689 static int GetLeafScaleX (lua_State *L) { PROFILE
00690
00691
00692 float r = checkudata_alive(L)->getLeafScaleX();
00693
00694 lua_pushnumber(L, r);
00695 return 1;
00696 }
00697
00699 static int GetNumLeaves (lua_State *L) { PROFILE
00700
00701
00702 char r = checkudata_alive(L)->getNumLeaves();
00703
00704 lua_pushnumber(L, r);
00705 return 1;
00706 }
00707
00709 static int GetLeafQuality (lua_State *L) { PROFILE
00710
00711
00712 float r = checkudata_alive(L)->getLeafQuality();
00713
00714 lua_pushnumber(L, r);
00715 return 1;
00716 }
00717
00719 static int GetLeafLayoutExp (lua_State *L) { PROFILE
00720
00721
00722 float r = checkudata_alive(L)->getLeafLayoutExp();
00723
00724 lua_pushnumber(L, r);
00725 return 1;
00726 }
00727
00729 static int GetLeafMaterial (lua_State *L) { PROFILE
00730
00731
00732 Ogre::String r = checkudata_alive(L)->getLeafMaterial();
00733
00734 lua_pushstring(L, r.c_str());
00735 return 1;
00736 }
00737
00739 static int GetFrondScale (lua_State *L) { PROFILE
00740
00741
00742 float r = checkudata_alive(L)->getFrondScale();
00743
00744 lua_pushnumber(L, r);
00745 return 1;
00746 }
00747
00749 static int GetFrondScaleX (lua_State *L) { PROFILE
00750
00751
00752 float r = checkudata_alive(L)->getFrondScaleX();
00753
00754 lua_pushnumber(L, r);
00755 return 1;
00756 }
00757
00759 static int GetNumFronds (lua_State *L) { PROFILE
00760
00761
00762 char r = checkudata_alive(L)->getNumFronds();
00763
00764 lua_pushnumber(L, r);
00765 return 1;
00766 }
00767
00769 static int GetFrondQuality (lua_State *L) { PROFILE
00770
00771
00772 float r = checkudata_alive(L)->getFrondQuality();
00773
00774 lua_pushnumber(L, r);
00775 return 1;
00776 }
00777
00779 static int GetFrondMaterial (lua_State *L) { PROFILE
00780
00781
00782 Ogre::String r = checkudata_alive(L)->getFrondMaterial();
00783
00784 lua_pushstring(L, r.c_str());
00785 return 1;
00786 }
00787
00789 static int GetAttractionUp (lua_State *L) { PROFILE
00790
00791
00792 float r = checkudata_alive(L)->getAttractionUp();
00793
00794 lua_pushnumber(L, r);
00795 return 1;
00796 }
00797
00799 static int GetTaper (lua_State *L) { PROFILE
00800
00801
00802 float r = checkudata_alive(L)->getTaper();
00803
00804 lua_pushnumber(L, r);
00805 return 1;
00806 }
00807
00809 static int GetNumVertices (lua_State *L) { PROFILE
00810
00811 unsigned int p0 = luaL_checkint(L, 2);
00812
00813 char r = checkudata_alive(L)->getNumVertices(p0);
00814
00815 lua_pushnumber(L, r);
00816 return 1;
00817 }
00818
00820 static int GetNumBranches (lua_State *L) { PROFILE
00821
00822 unsigned int p0 = luaL_checkint(L, 2);
00823
00824 char r = checkudata_alive(L)->getNumBranches(p0);
00825
00826 lua_pushnumber(L, r);
00827 return 1;
00828 }
00829
00831 static int GetDownAngle (lua_State *L) { PROFILE
00832
00833 unsigned int p0 = luaL_checkint(L, 2);
00834
00835 float r = checkudata_alive(L)->getDownAngle(p0);
00836
00837 lua_pushnumber(L, r);
00838 return 1;
00839 }
00840
00842 static int GetDownAngleV (lua_State *L) { PROFILE
00843
00844 unsigned int p0 = luaL_checkint(L, 2);
00845
00846 float r = checkudata_alive(L)->getDownAngleV(p0);
00847
00848 lua_pushnumber(L, r);
00849 return 1;
00850 }
00851
00853 static int GetRotate (lua_State *L) { PROFILE
00854
00855 unsigned int p0 = luaL_checkint(L, 2);
00856
00857 float r = checkudata_alive(L)->getRotate(p0);
00858
00859 lua_pushnumber(L, r);
00860 return 1;
00861 }
00862
00864 static int GetRotateV (lua_State *L) { PROFILE
00865
00866 unsigned int p0 = luaL_checkint(L, 2);
00867
00868 float r = checkudata_alive(L)->getRotateV(p0);
00869
00870 lua_pushnumber(L, r);
00871 return 1;
00872 }
00873
00875 static int GetLength (lua_State *L) { PROFILE
00876
00877 unsigned int p0 = luaL_checkint(L, 2);
00878
00879 float r = checkudata_alive(L)->getLength(p0);
00880
00881 lua_pushnumber(L, r);
00882 return 1;
00883 }
00884
00886 static int GetLengthV (lua_State *L) { PROFILE
00887
00888 unsigned int p0 = luaL_checkint(L, 2);
00889
00890 float r = checkudata_alive(L)->getLengthV(p0);
00891
00892 lua_pushnumber(L, r);
00893 return 1;
00894 }
00895
00897 static int GetCurve (lua_State *L) { PROFILE
00898
00899 unsigned int p0 = luaL_checkint(L, 2);
00900
00901 float r = checkudata_alive(L)->getCurve(p0);
00902
00903 lua_pushnumber(L, r);
00904 return 1;
00905 }
00906
00908 static int GetCurveBack (lua_State *L) { PROFILE
00909
00910 unsigned int p0 = luaL_checkint(L, 2);
00911
00912 float r = checkudata_alive(L)->getCurveBack(p0);
00913
00914 lua_pushnumber(L, r);
00915 return 1;
00916 }
00917
00919 static int GetCurveV (lua_State *L) { PROFILE
00920
00921 unsigned int p0 = luaL_checkint(L, 2);
00922
00923 float r = checkudata_alive(L)->getCurveV(p0);
00924
00925 lua_pushnumber(L, r);
00926 return 1;
00927 }
00928
00930 static int GetCurveRes (lua_State *L) { PROFILE
00931
00932 unsigned int p0 = luaL_checkint(L, 2);
00933
00934 char r = checkudata_alive(L)->getCurveRes(p0);
00935
00936 lua_pushnumber(L, r);
00937 return 1;
00938 }
00939 };
00940
00941
00942
00943
00944
00945
00946 class cCaduneTreeStem_L : public cLuaBind<CaduneTree::Stem> { public:
00947 virtual void RegisterMethods (lua_State *L) { PROFILE
00948 lua_register(L,"CreateCaduneTreeStem", &cCaduneTreeStem_L::CreateCaduneTreeStem);
00949
00950 #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cCaduneTreeStem_L::methodname));
00951
00952 REGISTER_METHOD(Grow);
00953 REGISTER_METHOD(CreateGeometry);
00954 REGISTER_METHOD(CreateLeaves);
00955 REGISTER_METHOD(GetNumVerticesChildren);
00956 REGISTER_METHOD(GetNumTrianglesChildren);
00957
00958 REGISTER_METHOD(Destroy);
00959
00960 #undef REGISTER_METHOD
00961 }
00962 virtual const char* GetLuaTypeName () { return "lugre.cadune.stem"; }
00963
00965 static int CreateCaduneTreeStem (lua_State *L) { PROFILE
00966 int argc = lua_gettop(L);
00967
00968 CaduneTree::Stem *parent = 0;
00969 CaduneTree::Parameters *parameters = 0;
00970
00971 parameters = cLuaBind<CaduneTree::Parameters>::checkudata_alive(L,1);
00972
00973 assert(parameters && "parameters necessary");
00974
00975 return CreateUData(L,new CaduneTree::Stem(parameters, parent));
00976 }
00977
00980 static int Grow (lua_State *L) { PROFILE
00981 CaduneTree::Stem *stem = checkudata_alive(L);
00982 int argc = lua_gettop(L) - 1;
00983
00984 Ogre::Quaternion orientation;
00985 Ogre::Vector3 origin;
00986
00987 float radius = 1.0f;
00988 float length = 1.0f;
00989 float offset = 0.0f;
00990 unsigned char level = 0;
00991
00992 if(argc >= 4 && !lua_isnil(L,2)){
00993 orientation.w = luaL_checknumber(L,2);
00994 orientation.x = luaL_checknumber(L,3);
00995 orientation.y = luaL_checknumber(L,4);
00996 orientation.z = luaL_checknumber(L,5);
00997 }
00998
00999 if(argc >= 4+3 && !lua_isnil(L,6)){
01000 origin.x = luaL_checknumber(L,6);
01001 origin.y = luaL_checknumber(L,7);
01002 origin.z = luaL_checknumber(L,8);
01003 }
01004
01005 if(argc >= 4+3+1 && !lua_isnil(L,9)){ radius = luaL_checknumber(L,9); }
01006 if(argc >= 4+3+2 && !lua_isnil(L,10)){ length = luaL_checknumber(L,10); }
01007 if(argc >= 4+3+3 && !lua_isnil(L,11)){ offset = luaL_checknumber(L,11); }
01008 if(argc >= 4+3+4 && !lua_isnil(L,12)){ level = static_cast<unsigned char>(myround(luaL_checknumber(L,12))); }
01009
01010 stem->grow( orientation , origin, radius, length, offset, level );
01011
01012 return 0;
01013 }
01014
01017 static int CreateGeometry (lua_State *L) { PROFILE
01018 CaduneTree::Stem *stem = checkudata_alive(L);
01019
01020 int argc = lua_gettop(L) - 1;
01021
01022
01023 Ogre::SceneManager* pSceneMgr = cOgreWrapper::GetSingleton().GetSceneManager("main");
01024
01025 assert(pSceneMgr && "no scene manager with name main");
01026
01027 cGfx3D* gfx = cGfx3D::NewChildOfRoot(pSceneMgr);
01028
01029 gfx->SetManualObject(pSceneMgr->createManualObject(cOgreWrapper::GetSingleton().GetUniqueName()));
01030
01031 stem->createGeometry(gfx->mpManualObject);
01032
01033 return cLuaBind<cGfx3D>::CreateUData(L,gfx);
01034 }
01035
01038 static int CreateLeaves (lua_State *L) { PROFILE
01039 CaduneTree::Stem *stem = checkudata_alive(L);
01040
01041 int argc = lua_gettop(L) - 1;
01042
01043
01044 Ogre::SceneManager* pSceneMgr = cOgreWrapper::GetSingleton().GetSceneManager("main");
01045
01046 assert(pSceneMgr && "no scene manager with name main");
01047
01048 cGfx3D* gfx = cGfx3D::NewChildOfRoot(pSceneMgr);
01049
01050 gfx->SetBillboardSet(pSceneMgr->createBillboardSet(cOgreWrapper::GetSingleton().GetUniqueName()));
01051
01052 stem->createLeaves(gfx->mpBillboardSet);
01053
01054 return cLuaBind<cGfx3D>::CreateUData(L,gfx);
01055 }
01056
01058 static int GetNumVerticesChildren (lua_State *L) { PROFILE
01059 CaduneTree::Stem *stem = checkudata_alive(L);
01060
01061 int argc = lua_gettop(L) - 1;
01062
01063 lua_pushnumber(L,stem->getNumVerticesChildren());
01064
01065 return 1;
01066 }
01067
01069 static int GetNumTrianglesChildren (lua_State *L) { PROFILE
01070 CaduneTree::Stem *stem = checkudata_alive(L);
01071
01072 int argc = lua_gettop(L) - 1;
01073
01074 lua_pushnumber(L,stem->getNumTrianglesChildren());
01075
01076 return 1;
01077 }
01078
01079
01081 static int Destroy (lua_State *L) { PROFILE
01082 delete checkudata_alive(L);
01083 return 0;
01084 }
01085 };
01086
01087
01088
01089
01090
01091 class cCaduneTreeSection_L : public cLuaBind<CaduneTree::Section> { public:
01092 virtual void RegisterMethods (lua_State *L) { PROFILE
01093 lua_register(L,"CreateCaduneTreeSection", &cCaduneTreeSection_L::CreateCaduneTreeSection);
01094
01095 #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cCaduneTreeSection_L::methodname));
01096
01097 REGISTER_METHOD(Destroy);
01098
01099 REGISTER_METHOD(Create);
01100 REGISTER_METHOD(SetOrientation);
01101 REGISTER_METHOD(SetGlobalOrigin);
01102 REGISTER_METHOD(SetOrigin);
01103 REGISTER_METHOD(SetTexVCoord);
01104 REGISTER_METHOD(GetOrientation);
01105 REGISTER_METHOD(GetOrigin);
01106 REGISTER_METHOD(GetGlobalOrigin);
01107 REGISTER_METHOD(GetTexVCoord);
01108
01109 #undef REGISTER_METHOD
01110 }
01111 virtual const char* GetLuaTypeName () { return "lugre.cadune.section"; }
01112
01113 static int CreateCaduneTreeSection (lua_State *L) { PROFILE
01114 return CreateUData(L,new CaduneTree::Section());
01115 }
01116
01118 static int Destroy (lua_State *L) { PROFILE
01119 delete checkudata_alive(L);
01120 return 0;
01121 }
01122
01124 static int Create (lua_State *L) { PROFILE
01125
01126 unsigned int p0 = static_cast<unsigned int>(luaL_checknumber(L, 2));
01127 float p1 = luaL_checknumber(L, 3);
01128 float p2 = luaL_checknumber(L, 4);
01129 unsigned int p3 = static_cast<unsigned int>(luaL_checknumber(L, 5));
01130
01131 checkudata_alive(L)->create(p0, p1, p2, p3);
01132
01133 return 0;
01134 }
01135
01137 static int SetOrientation (lua_State *L) { PROFILE
01138
01139 const Ogre::Quaternion p0(luaL_checknumber(L, 2),luaL_checknumber(L, 3),luaL_checknumber(L, 4),luaL_checknumber(L, 5));
01140
01141 checkudata_alive(L)->setOrientation(p0);
01142
01143 return 0;
01144 }
01145
01147 static int SetGlobalOrigin (lua_State *L) { PROFILE
01148
01149 Ogre::Vector3 p0(luaL_checknumber(L, 2),luaL_checknumber(L, 3),luaL_checknumber(L, 4));
01150
01151 checkudata_alive(L)->setGlobalOrigin(p0);
01152
01153 return 0;
01154 }
01155
01157 static int SetOrigin (lua_State *L) { PROFILE
01158
01159 Ogre::Vector3 p0(luaL_checknumber(L, 2),luaL_checknumber(L, 3),luaL_checknumber(L, 4));
01160
01161 checkudata_alive(L)->setOrigin(p0);
01162
01163 return 0;
01164 }
01165
01167 static int SetTexVCoord (lua_State *L) { PROFILE
01168
01169 float p0 = luaL_checknumber(L, 2);
01170
01171 checkudata_alive(L)->setTexVCoord(p0);
01172
01173 return 0;
01174 }
01175
01177 static int GetOrientation (lua_State *L) { PROFILE
01178
01179
01180 Ogre::Quaternion r = checkudata_alive(L)->getOrientation();
01181
01182 lua_pushnumber(L, r.w);
01183 lua_pushnumber(L, r.x);
01184 lua_pushnumber(L, r.y);
01185 lua_pushnumber(L, r.z);
01186 return 4;
01187 }
01188
01190 static int GetOrigin (lua_State *L) { PROFILE
01191
01192
01193 Ogre::Vector3 r = checkudata_alive(L)->getOrigin();
01194
01195 lua_pushnumber(L, r.x);
01196 lua_pushnumber(L, r.y);
01197 lua_pushnumber(L, r.z);
01198 return 3;
01199 }
01200
01202 static int GetGlobalOrigin (lua_State *L) { PROFILE
01203
01204
01205 Ogre::Vector3 r = checkudata_alive(L)->getGlobalOrigin();
01206
01207 lua_pushnumber(L, r.x);
01208 lua_pushnumber(L, r.y);
01209 lua_pushnumber(L, r.z);
01210 return 3;
01211 }
01212
01214 static int GetTexVCoord (lua_State *L) { PROFILE
01215
01216
01217 float r = checkudata_alive(L)->getTexVCoord();
01218
01219 lua_pushnumber(L, r);
01220 return 1;
01221 }
01222 };
01223
01224
01225
01227 void LuaRegisterCaduneTree (lua_State *L) { PROFILE
01228 cLuaBind<CaduneTree::Section>::GetSingletonPtr(new cCaduneTreeSection_L())->LuaRegister(L);
01229 cLuaBind<CaduneTree::Stem>::GetSingletonPtr(new cCaduneTreeStem_L())->LuaRegister(L);
01230 cLuaBind<CaduneTree::Parameters>::GetSingletonPtr(new cCaduneTreeParameters_L())->LuaRegister(L);
01231 }
01232 }
01233
01234
01235 #endif