From 156751d77b2c6746b9daba1257cabdc168312fdd Mon Sep 17 00:00:00 2001 From: GeneralGuy4872 Date: Mon, 11 Jan 2021 01:56:52 -0600 Subject: [PATCH] added gravity; broke camera colors bitrotted --- geography.txt | 6 +- ...130d7a07e406f0288f065391f7e4dd3030).carray | 4 + src/alpha/NOTE | 32 ++++ src/alpha/modularized/eventloop.incplusplus | 8 + src/alpha/modularized/globals.incplusplus | 5 + src/alpha/modularized/irrcontext.incplusplus | 39 ++++ src/alpha/modularized/main.cc | 46 +++-- .../modularized/maineventloop.incplusplus | 20 ++ .../modularized/ncursesthread.incplusplus | 68 ++++--- src/alpha/sandbox/ode_physics_new.cc | 171 ++++++++++++++++++ 10 files changed, 348 insertions(+), 51 deletions(-) create mode 100644 monster0_(commit#4b1594130d7a07e406f0288f065391f7e4dd3030).carray create mode 100644 src/alpha/NOTE create mode 100644 src/alpha/sandbox/ode_physics_new.cc diff --git a/geography.txt b/geography.txt index c2e371a..64dd25f 100644 --- a/geography.txt +++ b/geography.txt @@ -132,6 +132,6 @@ that converts solar wind into an antigravity ridge which keeps the ring centered (antigravity, of course being the technical term for the force exerted by matter with negitive mass...no?). elemental planes and the prime plane are connected by wormholes, whose apetures travel forward in time -at 1m/s/s, and are also always in the same 3-dimensional moment-slice of -the universe; these usually contain a bridge so that objects traversing -them do not get tidally shredded by straying from a safe path. +at 1s/s and are also always in the same moment-slice of the multiverse; +these usually contain a bridge so that objects traversing them do not get +tidally shredded by straying from a safe path. diff --git a/monster0_(commit#4b1594130d7a07e406f0288f065391f7e4dd3030).carray b/monster0_(commit#4b1594130d7a07e406f0288f065391f7e4dd3030).carray new file mode 100644 index 0000000..09b17b4 --- /dev/null +++ b/monster0_(commit#4b1594130d7a07e406f0288f065391f7e4dd3030).carray @@ -0,0 +1,4 @@ +{"human","","s"},{"el","f","ves"},{"dwarf","","s"},{"gnome","","s"},{"hobbit","","s"},{"half el","f","ves"},{"drow","",""},{"or,"c","ks"},{"half or","c","ks"},{"half dragon","","s"},/*half celestial*/,{"tiefling","","s"},{"half air elemental","","s"},{"half water elemental","","s"},{"half earth elemental","","s"},{"half fire elemental","","s"}, +{"merfolk","",""},{"sea el","f","ves"},{"satyr","","es"},{"fair","y","ies"},{"pixie","","s"},{"naiad","","s"},{"wood el","f","ves"},{"dryad","","s"},{"naga","","s"},{"kobald","","s"},{"centaur","","s"},{"sphinx","","es"},{"half electric elemental","","s"},{"half ice elemental","","s"},{"half nature elemental","","s"},{"half metal elemental","","s"}, +{"siren","","s"},{"harp","y","ies"},{"eriny","s","es"},{"ker","r","es"},{"cecaelia","","e"},{"drider","","s"},{"scorpio","","nes"},{"manticore","",""}, + diff --git a/src/alpha/NOTE b/src/alpha/NOTE new file mode 100644 index 0000000..eaa506c --- /dev/null +++ b/src/alpha/NOTE @@ -0,0 +1,32 @@ +SOLID BODY (NOT ELASTIC) FOR PLAYER + +--- + +Drop voxel-style terrain use geom-style terrain and offload live +organization to Irrlicht; static data file for a geom is: + +unsigned char : red +unsigned char : green +unsigned char : blue +unsigned char : alpha +unsigned char : metallic +unsigned char : softness +unsigned char : lightsource +unsigned q16.16 : size x +unsigned q16.16 : size y +unsigned q16.16 : size z +unsigned char : x resolution +unsigned char : y resolution +unsigned char : z resolution +unsigned q16.16 [x res][y res] +unsigned q16.16 [x res][z res] +unsigned q16.16 [y res][z res] + +data file is read into memory as needed just like a texture would be + +--- + +characters and entities should display as sprites for now (set of 24); low- +poly hitbox can be added + + diff --git a/src/alpha/modularized/eventloop.incplusplus b/src/alpha/modularized/eventloop.incplusplus index 0a8b082..90f4b06 100644 --- a/src/alpha/modularized/eventloop.incplusplus +++ b/src/alpha/modularized/eventloop.incplusplus @@ -91,6 +91,14 @@ class MainEventReciever : public irr::IEventReceiver { CHECKPOINT(THREAD__EVENT,__LINE__); } break; + case irr::KEY_KEY_Q : { + CHECKPOINT(THREAD__EVENT,__LINE__); + pthread_mutex_lock(&CAMLOCK); + puts("working"); + pthread_mutex_unlock(&CAMLOCK); + CHECKPOINT(THREAD__EVENT,__LINE__); + } break; + case irr::KEY_KEY_S : { CHECKPOINT(THREAD__EVENT,__LINE__); pthread_mutex_lock(&CAMLOCK); diff --git a/src/alpha/modularized/globals.incplusplus b/src/alpha/modularized/globals.incplusplus index eae43af..26d19b8 100644 --- a/src/alpha/modularized/globals.incplusplus +++ b/src/alpha/modularized/globals.incplusplus @@ -7,6 +7,10 @@ pthread_mutex_t JITTER_ADV_LOCK = PTHREAD_MUTEX_INITIALIZER; float JITTER_ADVERAGE; typedef std::map NODES_t; NODES_t NODES; +double (*PLAYER_VELOCITY)[4]; +irr::core::vector3df PLAYER_POS_BUFFER; +irr::core::vector3df CAMERA_POS_BUFFER; +bool * CAMERA_MANUAL_OVERRIDE; #define THREAD__MAIN 0 #define THREAD__EVENT 1 @@ -19,6 +23,7 @@ std::atomic_int EXELINE[THREADCOUNT]; #define CHECKPOINT(X,Y) EXELINE[X] = Y irr::scene::ICameraSceneNode * CAMERA; +irr::scene::IMeshSceneNode * PLAYER; pthread_mutex_t CAMLOCK = PTHREAD_MUTEX_INITIALIZER; std::atomic_bool STEALCURSOR; std::atomic_bool YINVERT; diff --git a/src/alpha/modularized/irrcontext.incplusplus b/src/alpha/modularized/irrcontext.incplusplus index a8cff96..a5b169e 100644 --- a/src/alpha/modularized/irrcontext.incplusplus +++ b/src/alpha/modularized/irrcontext.incplusplus @@ -7,8 +7,47 @@ namespace irrcontext { irr::gui::IGUIEnvironment * guienv; irr::scene::IMeshManipulator * meshmanipr; irr::gui::ICursorControl * cursctrl; + irr::scene::IMetaTriangleSelector * trisel; + irr::scene::ISceneNodeAnimator * colresanim; + std::map dictionary; irr::ITimer * timer; double deltatime; uint32_t then; uint32_t now; } + +namespace IWF { +namespace FUNC { + +::irr::scene::IMeshSceneNode * initcube (float size = 10,::irr::scene::ISceneNode * parent = NULL,::irr::core::vector3df position = ::irr::core::vector3df(0,0,0),::irr::core::vector3df rotation = ::irr::core::vector3df(0,0,0),::irr::core::vector3df scale = ::irr::core::vector3df(1,1,1)) { + irr::scene::IMeshSceneNode * retval = ::irrcontext::smgr->addCubeSceneNode(size,parent,-1,position,rotation,scale); + irr::scene::ITriangleSelector * tri = ::irrcontext::smgr->createTriangleSelector(retval->getMesh(),retval); + retval->setTriangleSelector(tri); + ::irrcontext::trisel->addTriangleSelector(tri); + ::irrcontext::dictionary[retval] = tri; + return retval; + } + +::irr::scene::IMeshSceneNode * initcubef (float size = 10,::irr::scene::ISceneNode * parent = NULL,float positionx = 0, float positiony = 0, float positionz = 0,float rotationx = 0, float rotationy = 0, float rotationz = 0,float scalex = 1, float scaley = 1, float scalez = 1) { + irr::core::vector3df position = {positionx,positiony,positionz}; + irr::core::vector3df rotation = {rotationx,rotationy,rotationz}; + irr::core::vector3df scale = {scalex,scaley,scalez}; + return ::IWF::FUNC::initcube(size,parent,position,rotation,scale); + } + +::irr::scene::IMeshSceneNode * initidcube (float size = 10,::irr::scene::ISceneNode * parent = NULL,int32_t id = -1,::irr::core::vector3df position = ::irr::core::vector3df(0,0,0),::irr::core::vector3df rotation = ::irr::core::vector3df(0,0,0),::irr::core::vector3df scale = ::irr::core::vector3df(1,1,1)) { + irr::scene::IMeshSceneNode * retval = ::irrcontext::smgr->addCubeSceneNode(size,parent,id,position,rotation,scale); + irr::scene::ITriangleSelector * tri = ::irrcontext::smgr->createTriangleSelector(retval->getMesh(),retval); + retval->setTriangleSelector(tri); + ::irrcontext::trisel->addTriangleSelector(tri); + ::irrcontext::dictionary[retval] = tri; + return retval; + } + +::irr::scene::IMeshSceneNode * initidcubef (float size = 10,::irr::scene::ISceneNode * parent = NULL,int32_t id = -1,float positionx = 0, float positiony = 0, float positionz = 0,float rotationx = 0, float rotationy = 0, float rotationz = 0,float scalex = 1, float scaley = 1, float scalez = 1) { + irr::core::vector3df position = {positionx,positiony,positionz}; + irr::core::vector3df rotation = {rotationx,rotationy,rotationz}; + irr::core::vector3df scale = {scalex,scaley,scalez}; + return ::IWF::FUNC::initidcube(size,parent,id,position,rotation,scale); + } +}} diff --git a/src/alpha/modularized/main.cc b/src/alpha/modularized/main.cc index 4762dee..6808f93 100644 --- a/src/alpha/modularized/main.cc +++ b/src/alpha/modularized/main.cc @@ -4,7 +4,7 @@ * prealpha * **************/ -#define SNAPSHOT "AFTERNOON/07/AUG/2020" +#define SNAPSHOT "NIGHT/10/JAN/2021" /* this program currently requires a second terminal to be used; this is * done by passing the terminal's device file (which can be obtained with @@ -78,6 +78,8 @@ SYSINT initialize (char *argv[]) { setvbuf(stdout, NULL, _IONBF, 0); SCRAM = 0; JITTERMAX = 0xF; + PLAYER_VELOCITY = calloc(3,sizeof(double)); + CAMERA_MANUAL_OVERRIDE = calloc(1,sizeof(bool)); pthread_create(&iwf$$threads$$curses,NULL,iwf$$threads$$curses$$function,argv); pthread_create(&iwf$$threads$$jitterbug,NULL,iwf$$threads$$jitterbug$$loop,NULL); @@ -91,23 +93,21 @@ SYSINT initialize (char *argv[]) { irrcontext::meshmanipr = irrcontext::smgr->getMeshManipulator(); irrcontext::cursctrl = irrcontext::device->getCursorControl(); irrcontext::timer = irrcontext::device->getTimer(); + irrcontext::trisel = irrcontext::smgr->createMetaTriangleSelector(); irrcontext::guienv->addStaticText(L"IWannaFly Devtest prealpha snapshot " SNAPSHOT,irr::core::rect(10,10,260,22),1); CAMERA = irrcontext::smgr->addCameraSceneNode(NULL,irr::core::vector3df(0,0,0),irr::core::vector3df(1,1,1)); CAMERA->setUpVector(irr::core::vector3df(0,0,1)); + PLAYER = IWF::FUNC::initidcube(.4,NULL,20); + irrcontext::colresanim = irrcontext::smgr->createCollisionResponseAnimator(irrcontext::trisel,CAMERA,irr::core::vector3df(.2,.2,.2),irr::core::vector3df(0,0,-0.98),irr::core::vector3df(0,0,0.001)); + PLAYER->addAnimator(irrcontext::colresanim); + irrcontext::meshmanipr->setVertexColors(PLAYER->getMesh(),RGBColor(0x55,0x55,0xFF)); for (int x = -1;x < 2;x += 1) { for (int y = -1;y < 2;y += 1) { for (int z = -1;z < 2;z += 1) { if (x || y || z) { - irr::scene::IMeshSceneNode * tmp = irrcontext::smgr->addCubeSceneNode( - 10.0, - NULL, - ((z * 9) + (y * 3) + x), - irr::core::vector3df( - (x * 25), - (y * 25), - (z * 25))); + irr::scene::IMeshSceneNode * tmp = IWF::FUNC::initidcubef(10.0,NULL,((z * 9) + (y * 3) + x),(x * 25),(y * 25),(z * 25)); NODES[(z * 9) + (y * 3) + x] = tmp; }}}} irrcontext::smgr->addLightSceneNode(); @@ -125,23 +125,31 @@ main (int argc, char *argv[]) { while (irrcontext::device->run()) { JITTER = 0; if (SCRAM) exit(0); - CHECKPOINT(THREAD__MAIN,__LINE__); pthread_mutex_lock(&CAMLOCK); + if (*CAMERA_MANUAL_OVERRIDE) { + CAMERA->setPosition(irr::core::vector3df(0,0,0)); + (*CAMERA_MANUAL_OVERRIDE) = false; + } CAMERA->setTarget(CAMCOORD.euclid()); + CAMERA_POS_BUFFER = CAMERA->getPosition(); + PLAYER_POS_BUFFER = PLAYER->getPosition(); + { + irr::core::vector3df tmp = PLAYER->getPosition(); + tmp.X = tmp.X + (*PLAYER_VELOCITY)[0]; + tmp.Y = tmp.Y + (*PLAYER_VELOCITY)[1]; + tmp.Z = tmp.Z + (*PLAYER_VELOCITY)[2]; + PLAYER->setPosition(tmp); + CAMERA->setPosition(tmp); + } pthread_mutex_unlock(&CAMLOCK); - CHECKPOINT(THREAD__MAIN,__LINE__); - irrcontext::driver->beginScene(true, true, RGBAColor(0,0,0xAA,0xF0)); - CHECKPOINT(THREAD__MAIN,__LINE__); + irrcontext::driver->beginScene(true, true, RGBAColor(0,0,0x55,0xEE)); irrcontext::smgr->drawAll(); - CHECKPOINT(THREAD__MAIN,__LINE__); irrcontext::guienv->drawAll(); - CHECKPOINT(THREAD__MAIN,__LINE__); irrcontext::driver->endScene(); - CHECKPOINT(THREAD__MAIN,__LINE__); + (*PLAYER_VELOCITY)[0] = ((int)(((*PLAYER_VELOCITY)[0] / 2) * 1000000)) / 1000000.0; //if this underflows, then the optimizer is screwing you + (*PLAYER_VELOCITY)[1] = ((int)(((*PLAYER_VELOCITY)[1] / 2) * 1000000)) / 1000000.0; + (*PLAYER_VELOCITY)[2] = ((int)(((*PLAYER_VELOCITY)[2] / 2) * 1000000)) / 1000000.0; irrcontext::now = irrcontext::timer->getTime(); - CHECKPOINT(THREAD__MAIN,__LINE__); irrcontext::deltatime = (irrcontext::now - irrcontext::then) / 1000.0; - CHECKPOINT(THREAD__MAIN,__LINE__); irrcontext::then = irrcontext::now; - CHECKPOINT(THREAD__MAIN,__LINE__); }} diff --git a/src/alpha/modularized/maineventloop.incplusplus b/src/alpha/modularized/maineventloop.incplusplus index 31885b7..9f9b937 100644 --- a/src/alpha/modularized/maineventloop.incplusplus +++ b/src/alpha/modularized/maineventloop.incplusplus @@ -57,6 +57,26 @@ class MainEventReciever : public irr::IEventReceiver { CHECKPOINT(THREAD__EVENT,__LINE__); switch (event.KeyInput.Key) { + case irr::KEY_SPACE : { + CHECKPOINT(THREAD__EVENT,__LINE__); + pthread_mutex_lock(&CAMLOCK); + if ((*PLAYER_VELOCITY)[2]) { + (*PLAYER_VELOCITY)[2] = 1 + (1 / (*PLAYER_VELOCITY)[2]); + } else { + (*PLAYER_VELOCITY)[2] = 1; + } + pthread_mutex_unlock(&CAMLOCK); + CHECKPOINT(THREAD__EVENT,__LINE__); + } break; + + case irr::KEY_KEY_Q : { + CHECKPOINT(THREAD__EVENT,__LINE__); + pthread_mutex_lock(&CAMLOCK); + (*CAMERA_MANUAL_OVERRIDE) = true; + pthread_mutex_unlock(&CAMLOCK); + CHECKPOINT(THREAD__EVENT,__LINE__); + } break; + case irr::KEY_KEY_W : { CHECKPOINT(THREAD__EVENT,__LINE__); pthread_mutex_lock(&CAMLOCK); diff --git a/src/alpha/modularized/ncursesthread.incplusplus b/src/alpha/modularized/ncursesthread.incplusplus index 4176d25..944f286 100644 --- a/src/alpha/modularized/ncursesthread.incplusplus +++ b/src/alpha/modularized/ncursesthread.incplusplus @@ -21,10 +21,10 @@ void * iwf$$threads$$curses$$function (void * input) { noecho(); keypad(NULL,1); - mvprintw(3,3,"IWannaFly"); - mvprintw(4,4,"prealpha devtest"); - mvprintw(5,5,"revision snapshot:"); - mvprintw(6,5,SNAPSHOT); + mvprintw(2,3,"IWannaFly"); + mvprintw(3,4,"prealpha devtest"); + mvprintw(4,5,"revision snapshot:"); + mvprintw(4,5,SNAPSHOT); irr::core::vector3df placeholder; float placeholder2; @@ -36,37 +36,47 @@ void * iwf$$threads$$curses$$function (void * input) { int tmp5; for (;;sleep(1)) { - CHECKPOINT(THREAD__NCURSES,__LINE__); pthread_mutex_lock(&CAMLOCK); - mvprintw(8,8,"camera azimuth : % 15.10f°",CAMCOORD.az * (180 / M_PI)); - mvprintw(9,8,"camera elevation : % 15.10f°",CAMCOORD.el * (180 / M_PI)); - mvprintw(11,8,"camera basis vector:"); + mvprintw(6,8,"camera azimuth : % 15.10f°",CAMCOORD.az * (180 / M_PI)); + mvprintw(7,8,"camera elevation : % 15.10f°",CAMCOORD.el * (180 / M_PI)); + + mvprintw(8,8,"camera basis vector:"); placeholder = CAMCOORD.euclid(); pthread_mutex_unlock(&CAMLOCK); - CHECKPOINT(THREAD__NCURSES,__LINE__); - mvprintw(12,10,"% 12.10fx",placeholder.X); - mvprintw(13,10,"% 12.10fy",placeholder.Y); - mvprintw(14,10,"% 12.10fz",placeholder.Z); - mvprintw(16,8,"cursor grabbed? >%s",STEALCURSOR ? "yes" : "no "); - CHECKPOINT(THREAD__NCURSES,__LINE__); + mvprintw(9,10,"% 12.10fx",placeholder.X); + mvprintw(9,35,"% 12.10fy",placeholder.Y); + mvprintw(9,60,"% 12.10fz",placeholder.Z); + + mvprintw(11,8,"camera position:"); + pthread_mutex_lock(&CAMLOCK); + placeholder = CAMERA_POS_BUFFER; + pthread_mutex_unlock(&CAMLOCK); + mvprintw(12,10,"% 15.10fx",placeholder.X); + mvprintw(12,35,"% 15.10fy",placeholder.Y); + mvprintw(12,60,"% 15.10fz",placeholder.Z); + + mvprintw(14,8,"player position:"); + pthread_mutex_lock(&CAMLOCK); + placeholder = PLAYER_POS_BUFFER; + pthread_mutex_unlock(&CAMLOCK); + mvprintw(15,10,"% 15.10fx",placeholder.X); + mvprintw(15,35,"% 15.10fy",placeholder.Y); + mvprintw(15,60,"% 15.10fz",placeholder.Z); + + mvprintw(17,8,"player velocity:"); + pthread_mutex_lock(&CAMLOCK); + mvprintw(18,10,"% 15.10fx",(*PLAYER_VELOCITY)[0]); + mvprintw(18,35,"% 15.10fy",(*PLAYER_VELOCITY)[1]); + mvprintw(18,60,"% 15.10fz",(*PLAYER_VELOCITY)[2]); + pthread_mutex_unlock(&CAMLOCK); + + mvprintw(20,8,"cursor grabbed? >%s",STEALCURSOR ? "yes" : "no "); + pthread_mutex_lock(&JITTER_ADV_LOCK); - mvprintw(17,8,"adverage jitter : %4.4f",JITTER_ADVERAGE); + mvprintw(21,8,"adverage jitter : %4.4f",JITTER_ADVERAGE); pthread_mutex_unlock(&JITTER_ADV_LOCK); - - CHECKPOINT(THREAD__NCURSES,__LINE__); tmp = JITTERMAX; - mvprintw(18,8,"(max jitter : %3i)",tmp); - CHECKPOINT(THREAD__NCURSES,__LINE__); - - tmp0 = EXELINE[0]; - tmp1 = EXELINE[1]; - tmp2 = EXELINE[2]; - tmp4 = EXELINE[4]; - tmp5 = EXELINE[5]; - CHECKPOINT(THREAD__NCURSES,__LINE__); - mvprintw(20,8,"line of execution : % 4i % 4i % 4i SELF % 4i % 4i",tmp0,tmp1,tmp2,tmp4,tmp5); + mvprintw(22,8,"(max jitter : %3i)",tmp); - CHECKPOINT(THREAD__NCURSES,__LINE__); refresh(); - CHECKPOINT(THREAD__NCURSES,__LINE__); }}; diff --git a/src/alpha/sandbox/ode_physics_new.cc b/src/alpha/sandbox/ode_physics_new.cc new file mode 100644 index 0000000..0b3edb5 --- /dev/null +++ b/src/alpha/sandbox/ode_physics_new.cc @@ -0,0 +1,171 @@ +std::atomic_bool ODE_FINISH_SYNC; +std::atomic_bool ODE_INTREQ; +std::atomic_bool ODE_IACK; + +std::atomic_bool IRR_FINISH_SYNC; +std::atomic_bool IRR_INTREQ; +std::atomic_bool IRR_IACK; + +dWorldID WORLD; +dSpaceID SPACE; +dJointGroupID COLLISIONGROUP; + +struct BlockTag { + IMeshSceneNode * node; + dGeomID geom; + }; + +std::vector BLOCKBANK; + +struct CounterweightsInternalData { + dJointGroupID group; + dJointID bolts[6]; + } + +struct Counterweights { + CounterweightsInternalData data; + dBodyID body[6]; + double upvector[3]; + double rightfactor; + } + +iwf$$physics$$update_counterweights_direct (Counterweights * object) { + dMass tmp; + + dMassSetTotalSphere(&tmp, + (object->upvector[0] * object->rightfactor * -1), + 0.00001); + dBodySetMass(object->body[0] , &tmp); + + dMassSetTotalSphere(&tmp, + (object->upvector[0] * object->rightfactor) + 0.00001); + dBodySetMass(object->body[1] , &tmp); + + dMassSetTotalSphere(&tmp, + (object->upvector[1] * object->rightfactor * -1), + 0.00001); + dBodySetMass(object->body[2] , &tmp); + + dMassSetTotalSphere(&tmp, + (object->upvector[1] * object->rightfactor), + 0.00001); + dBodySetMass(object->body[3] , &tmp); + + dMassSetTotalSphere(&tmp, + (object->upvector[2] * object->rightfactor * -1), + 0.00001); + dBodySetMass(object->body[4] , &tmp); + + dMassSetTotalSphere(&tmp, + (object->upvector[2] * object->rightfactor), + 0.00001); + dBodySetMass(object->body[5] , &tmp); + + return 0; + } + +struct EntTag { + IMeshSceneNode * irrnode; + dBodyID body; + dGeomID geom; + Counterweights cwt; + }; + +#define IWF__PHYSICS__SET_COUNTERWEIGHT_MASS(O,F) O->cwt->rightfactor = F +#define IWF__PHYSICS__SET_COUNTERWEIGHT_DIRECTION(O,X,Y,Z) O->cwt->upvector[0] = X,O->cwt->upvector[1] = Y,O->cwt->upvector[2] = Z +#define IWF__PHYSICS__UPDATE_COUNTERWEIGHT(O) iwf$$physics$$update_counterweights_direct(O->cwt) + +iwf$$physics$$create_entity (IMeshSceneNode * node,double x,double y,double z,double r,double l,double m,int ode_direction) { + EntTag * nova = calloc(1,sizeof(EntTag)); + nova->irrnode = node; + nova->body = dBodyCreate(WORLD); + dBodySetPosition(nova->body,x,y,z); + { + dMass tmp; + dMassSetCappedCylinderTotal(&tmp,m,ode_direction,r,l); + dBodySetMass(nova->body,mass); + } + nova->geom = dCreateCCylinder(SPACE,r,l); + dGeomSetBody(nova->geom,nova->body); + + nova->cwt->data->group = dJointGroupCreate(0); + { + dMass tmp; + dMassSetTotalSphere(&tmp,0,0.00001); + for (int i = 0;i < 6;i++) { + nova->cwt->body[i] = dBodyCreate(WORLD); + dBodySetMass(&tmp); + }} + + dBodySetPosition(nova->cwt->body[0] , 0.9 * r , 0.0 , 0.0); + dBodySetPosition(nova->cwt->body[1] ,-0.9 * r , 0.0 , 0.0); + dBodySetPosition(nova->cwt->body[2] , 0.0 , 0.9 * r , 0.0); + dBodySetPosition(nova->cwt->body[3] , 0.0 ,-0.9 * r , 0.0); + dBodySetPosition(nova->cwt->body[4] , 0.0 , 0.0 , 0.9 * r); + dBodySetPosition(nova->cwt->body[5] , 0.0 , 0.0 ,-0.9 * r); + for (int i = 0;i < 6;i++) { + nova->cwt->data->bolt[i] = dJointCreateFixed(WORLD,nova->cwt->data->group); + dJointAttatch(nova->cwt->data->bolt[i] , nova->body , nova->cwt->body[i]); + } + + ENTITIES.push_back(nova); + return 0; + } + +std::vector ENTITIES; +//will be seperated into different kinds of entities later + +initialize () { + dInitODE2(0); + WORLD = dWorldCreate(); + dWorldSetGravity(WORLD,0,0,-1.5); + SPACE = dSimpleSpaceCreate(0); + COLLISION = dJointGroupCreate(0); + … + + +//add to main +for (;;) { + if (ODE_IREQ) { + ODE_IACK = true; + while (ODE_IREQ); + ODE_IACK = false; + } + + ODE_FINISH_SYNC = true; + while (IRR_FINISH_SYNC != ODE_FINISH_SYNC); + { + dReal * tmp; + dMatrix3 ident; + dRSetIdentity(ident); + for (std::map::iterator i = ENTITIES.begin();i != ENTITIES.end();i++) { + tmp = dGeomGetPosition(i->geom); + i->node->SetPosition(irr::core::vector3df(tmp[0],tmp[1],tmp[2])); + dGeomSetRotation(i->geom,ident); + }}} + + +iwf$$DEBUGcreatevoxel() { + BlockTag nova; + { + dReal tmpX = iwf$$raw16$$coord3$$get$x(coord); + dReal tmpY = iwf$$raw16$$coord3$$get$y(coord); + dReal tmpZ = iwf$$raw16$$coord3$$get$z(coord); + dGeomID tmp = dCreateBox(SPACE, 2.5 , 2.5 , 2.5); + dGeomSetPosition(tmp,tmpX,tmpY,tmpZ); + nova.geom = tmp; + }{ + irr::scene::IMeshSceneNode * tmp = irrcontext::addCubeSceneNode( + 2.5f, + NULL, + 0, + irr::core::vector3df( + iwf$$raw16$$coord$$get$x(coord), + iwf$$raw16$$coord$$get$y(coord), + iwf$$raw16$$coord$$get$z(coord) + ); + nova.node = tmp; + } + BLOCKBANK.push_back(nova); + }