#define _IRR_STATIC_LIB_ #define IRRLICHT_STATIC #define IRRLICHT_EXPORTS #include #include #include #include #include #include #include #include "emscripten.h" #include "SDL.h" using namespace std; using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; int demostate;int lasttime;int now; const int numrfs=81; const int numrfi=50; ITexture *rfs[numrfs]; float rfstimes[numrfi]; int rfstexnums[numrfi]; ISceneNode* rfslist[numrfi]; IVideoDriver* driver; IrrlichtDevice *device ; IGUIEnvironment* guienv ; s32 kmattype; ITexture *astzeug1; EM_JS(int, canvas_get_width, (), { return document.documentElement.scrollWidth; }); EM_JS(int, canvas_get_height, (), { return document.documentElement.scrollHeight; }); EM_JS(int, jstime, (), { var ccc=document.getElementById('ccc'); if (ccc && ccc.currentTime>0){ return (document.getElementById('ccc').currentTime+0.9)*1000.0; } return 0; }); EM_JS(int, duration, (), { var ccc=document.getElementById('ccc'); if (ccc && ccc.currentTime>0){ return ccc.duration*1000; } return 183000; }); EM_JS(int, isplaying, (), { var ccc=document.getElementById('ccc'); if (ccc && ccc.currentTime>0){ return !ccc.paused}else{return false;}}); float spreadlens[330]={ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,6.5/2.0,0.25,0.25,0.25, 1,1,1,1,6.5/2.0,0.25,0.25,0.25,20,20,20,40, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//unneccessary int spreadlensidx=0; int numspreadlens=33; float takt=1972.222222222; vector3df POI; float aspect=16.0/9.0; IMeshBuffer *trimb; IAnimatedMesh *mySphereMesh; IAnimatedMesh *molSphereMesh; wchar_t *convt(wchar_t *in){ wchar_t *out=new wchar_t[200]; for (int i=0;in[i]!=0;i++){ out[i]=in[i]-L'A'; } return out; } int durmul=0; uint32_t getTick() { if ((isplaying()==true)&&(durmul*duration()+jstime()getVertices())[0]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->setMaterial(matdraw); driver->drawMeshBuffer(trimb); matrix4 transmat; transmat.setTranslation(ep); transmat.setScale(vector3df(0.04)); driver->setTransform(video::ETS_WORLD,transmat); s32 oldmt=matdraw.MaterialType; matdraw.MaterialType=EMT_SOLID; driver->setMaterial(matdraw); driver->drawMeshBuffer(molSphereMesh->getMesh(0)->getMeshBuffer(0)); matdraw.MaterialType=EMT_SOLID; } virtual void spread(float now); virtual void addTime(float now){ curtime=now-starttime; if (curtime>=lifetime){ if (!hasSpread){ spread(now); hasSpread=true; } curtime=lifetime; } } Turtle(float now,vector3df startpoint,vector3df dir,float _lifetime){ starttime=now; isPOI=false; speed=0.001; curtime=0; hasSpread=false; direction=dir; sp=startpoint; ep=sp; lifetime=_lifetime; maxlen=lifetime*speed; curtime=0; } Turtle(){ } ~Turtle(){ } }; class BTurtle:public Turtle{ public: virtual void draw(video::IVideoDriver* driver){ matdraw.setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); matdraw.MaterialType=E_MATERIAL_TYPE::EMT_SOLID; matdraw.setTexture(0,astzeug1); vector3df ep=getEP(); vector3df dir=ep-sp; dir=dir.normalize(); vector3df viewdir=vector3df(0,0,1); vector3df norm=dir.crossProduct(viewdir); float thickness=0.05+isPOI*0.05; vector3df p[4]; p[0]=sp-thickness*norm; p[1]=ep-thickness*norm; p[2]=ep+thickness*norm; p[3]=sp+thickness*norm; SColor color; vector2df tc(0,0); ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->setMaterial(matdraw); driver->drawMeshBuffer(trimb); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->setMaterial(matdraw); driver->drawMeshBuffer(trimb); matrix4 transmat; transmat.setTranslation(ep); transmat.setScale(vector3df(0.04)); driver->setTransform(video::ETS_WORLD,transmat); driver->setMaterial(matdraw); driver->drawMeshBuffer(molSphereMesh->getMesh(0)->getMeshBuffer(0)); } BTurtle(float now,vector3df startpoint,vector3df dir,float _lifetime):Turtle(now,startpoint,dir,_lifetime){ } void spread(float now); }; class Bird:public Turtle{ public: vector3df up; float ffact,foffs,speed; float lasttime; virtual void draw(video::IVideoDriver* driver){ matdraw.setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); matdraw.MaterialType=E_MATERIAL_TYPE::EMT_SOLID; matdraw.setTexture(0,astzeug1); driver->setMaterial(matdraw); vector3df sidedir=direction.crossProduct(up); vector3df realnorm=sidedir.crossProduct(direction); vector3df norm=(sidedir+ffact*realnorm).normalize(); vector3df norm2=(-sidedir+ffact*realnorm).normalize(); vector3df viewdir=up; float thickness=0.4; ep=sp+0.3*direction.normalize(); vector3df p[4]; p[0]=sp; p[1]=ep; p[2]=ep+thickness*norm; p[3]=sp+thickness*norm; SColor color(255,255,255,128); vector2df tc(0,0); ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->drawMeshBuffer(trimb); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->drawMeshBuffer(trimb); norm=norm2; p[0]=sp; p[1]=ep; p[2]=ep+thickness*norm; p[3]=sp+thickness*norm; ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->drawMeshBuffer(trimb); ((S3DVertex*)trimb->getVertices())[3]=S3DVertex(p[0],viewdir,color,vector2df(p[0].X,p[0].Y)); ((S3DVertex*)trimb->getVertices())[2]=S3DVertex(p[1],viewdir,color,vector2df(p[1].X,p[1].Y)); ((S3DVertex*)trimb->getVertices())[1]=S3DVertex(p[2],viewdir,color,vector2df(p[2].X,p[2].Y)); ((S3DVertex*)trimb->getVertices())[0]=S3DVertex(p[3],viewdir,color,vector2df(p[3].X,p[3].Y)); driver->setTransform(video::ETS_WORLD,matrix4()); driver->drawMeshBuffer(trimb); matrix4 transmat; transmat.setTranslation(ep); transmat.setScale(vector3df(0.015)); driver->setTransform(video::ETS_WORLD,transmat); driver->drawMeshBuffer(molSphereMesh->getMesh(0)->getMeshBuffer(0)); } Bird(float now,vector3df startpoint,vector3df dir,vector3df up,float _lifetime):Turtle(now,startpoint,dir,10000000){ foffs=500.0f*rand()/(float)RAND_MAX; lasttime=now; this->up=up; speed=0.001+0.0002*rand()/(float)RAND_MAX; } void addTime(float now); void spread(float now){} }; class Turtles{ public: static aabbox3df getAABB(){ aabbox3df ret; if (numturtles>0) ret=aabbox3df(turtles[0]->sp,turtles[0]->sp); for (int i=0;isp); } return ret; } static bool turtleson; static Turtle* turtles[]; static int numturtles; static void clear(){ for (int i=0;i<100000;i++){ turtles[i]=0; } numturtles=0; } static void add(Turtle *tur){ turtles[numturtles]=tur; numturtles++; } static void add(BTurtle *tur){ turtles[numturtles]=tur; numturtles++; } static void add(Bird *tur){ turtles[numturtles]=tur; numturtles++; } static void draw(){ for (int i=0;idraw(driver); } } static void update(float delt){ for (int i=0;iaddTime(delt); } if (numturtles>0){ POI=turtles[Turtles::numturtles-1]->ep; turtles[Turtles::numturtles-1]->isPOI=true; } } }; void Bird::addTime(float now){ float elapsed=now-lasttime; ffact=sin((now+foffs)/100.0); lasttime=now; float dist=99999999; Bird *minTurt; for (int i=0;isp)-sp).getLength(); if (curdistsp-sp; vector3df target; float whishdist=1; vector3df whishover=vector3df(0,0.1,-1.5); if (transformed.X>0){ target=minTurt->sp-(minTurt->up.crossProduct(minTurt->direction)).normalize()*whishdist+whishover; }else{ target=minTurt->sp+(minTurt->up.crossProduct(minTurt->direction)).normalize()*whishdist+whishover; } this->direction=(this->direction+0.01*(target-sp).normalize()).normalize(); } void BTurtle::spread(float now){ if (Turtles::numturtles>0) Turtles::turtles[Turtles::numturtles-1]->isPOI=true; if (maxlen<1.0) return; for (int i=0;i<4;i++){ vector3df unit(0,1,0); unit.rotateXYBy(360.0f*rand()/(float)RAND_MAX,vector3df(0,0,0)); unit.rotateYZBy(360.0f*rand()/(float)RAND_MAX,vector3df(0,0,0)); vector3df newdir=direction+unit; newdir+=vector3df(0,0.1,0); newdir=newdir.normalize(); BTurtle *newt=new BTurtle(now,getEP(),newdir,lifetime/1.2); Turtles::add(newt); } spreadlensidx=(spreadlensidx+1)%numspreadlens; } bool Turtles::turtleson=false; Turtle* Turtles::turtles[100000]; int Turtles::numturtles=0; #pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "opengl32.lib") class MyEventReceiver : public IEventReceiver { public: virtual bool OnEvent(const SEvent& event) { return false; } }; int texnum=40; IAnimatedMeshSceneNode *createQ(ITexture * tex,dimension2df size,ISceneManager *smgr,int repx=1,int repy=1,ISceneNode *parent=0){ SMaterial *mat=new SMaterial(); mat->setTexture(0,tex); mat->setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); std::stringstream ss; ss<<"test"<addHillPlaneMesh(ss.str().c_str(),size,dimension2d(1,1),mat,0,dimension2d(0,0),dimension2d(repx,repy)); return smgr->addAnimatedMeshSceneNode(hillplane,parent!=0?parent:smgr->getRootSceneNode()); } ITexture *loadTex(char *fn){ ITexture *tex; IFileSystem *fs=device->getFileSystem(); FILE* hrsrc = fopen(fn,"r"); long lSize; fseek (hrsrc , 0 , SEEK_END); lSize = ftell (hrsrc); rewind (hrsrc); char *hbytes=(char*)malloc(lSize); fread(hbytes,sizeof(char),lSize,hrsrc); IReadFile *rf=fs->createMemoryReadFile(hbytes,lSize,fn); tex=driver->getTexture(rf); return tex; } float wxsz=100; float wysz=10; float bzsz=20; ISceneNode *createExhibition(ISceneManager *smgr,ITexture **wandpics,int numwandpics){ ISceneNode *root=smgr->addDummyTransformationSceneNode(); root->grab(); root->remove(); rfs[0]= loadTex("./media/000.png"); rfs[1]= loadTex("./media/001.png"); rfs[2]= loadTex("./media/002.png"); rfs[3]= loadTex("./media/003.png"); rfs[4]= loadTex("./media/004.png"); rfs[5]= loadTex("./media/005.png"); rfs[6]= loadTex("./media/006.png"); rfs[7]= loadTex("./media/007.png"); rfs[8]= loadTex("./media/008.png"); rfs[9]= loadTex("./media/009.png"); rfs[10]= loadTex("./media/010.png"); rfs[11]= loadTex("./media/011.png"); rfs[12]= loadTex("./media/012.png"); rfs[13]= loadTex("./media/013.png"); rfs[14]= loadTex("./media/014.png"); rfs[15]= loadTex("./media/015.png"); rfs[16]= loadTex("./media/016.png"); rfs[17]= loadTex("./media/017.png"); rfs[18]= loadTex("./media/018.png"); rfs[19]= loadTex("./media/019.png"); rfs[20]= loadTex("./media/020.png"); rfs[21]= loadTex("./media/021.png"); rfs[22]= loadTex("./media/022.png"); rfs[23]= loadTex("./media/023.png"); rfs[24]= loadTex("./media/024.png"); rfs[25]= loadTex("./media/025.png"); rfs[26]= loadTex("./media/026.png"); rfs[27]= loadTex("./media/027.png"); rfs[28]= loadTex("./media/028.png"); rfs[29]= loadTex("./media/029.png"); rfs[30]= loadTex("./media/030.png"); rfs[31]= loadTex("./media/031.png"); rfs[32]= loadTex("./media/032.png"); rfs[33]= loadTex("./media/033.png"); rfs[34]= loadTex("./media/034.png"); rfs[35]= loadTex("./media/035.png"); rfs[36]= loadTex("./media/036.png"); rfs[37]= loadTex("./media/037.png"); rfs[38]= loadTex("./media/038.png"); rfs[39]= loadTex("./media/039.png"); rfs[40]= loadTex("./media/040.png"); rfs[41]= loadTex("./media/041.png"); rfs[42]= loadTex("./media/042.png"); rfs[43]= loadTex("./media/043.png"); rfs[44]= loadTex("./media/044.png"); rfs[45]= loadTex("./media/045.png"); rfs[46]= loadTex("./media/046.png"); rfs[47]= loadTex("./media/047.png"); rfs[48]= loadTex("./media/048.png"); rfs[49]= loadTex("./media/049.png"); rfs[50]= loadTex("./media/050.png"); rfs[51]= loadTex("./media/051.png"); rfs[52]= loadTex("./media/052.png"); rfs[53]= loadTex("./media/053.png"); rfs[54]= loadTex("./media/054.png"); rfs[55]= loadTex("./media/055.png"); rfs[56]= loadTex("./media/056.png"); rfs[57]= loadTex("./media/057.png"); rfs[58]= loadTex("./media/058.png"); rfs[59]= loadTex("./media/059.png"); rfs[60]= loadTex("./media/060.png"); rfs[61]= loadTex("./media/061.png"); rfs[62]= loadTex("./media/062.png"); rfs[63]= loadTex("./media/063.png"); rfs[64]= loadTex("./media/064.png"); rfs[65]= loadTex("./media/065.png"); rfs[66]= loadTex("./media/066.png"); rfs[67]= loadTex("./media/067.png"); rfs[68]= loadTex("./media/068.png"); rfs[69]= loadTex("./media/069.png"); rfs[70]= loadTex("./media/070.png"); rfs[71]= loadTex("./media/071.png"); rfs[72]= loadTex("./media/072.png"); rfs[73]= loadTex("./media/073.png"); rfs[74]= loadTex("./media/074.png"); rfs[75]= loadTex("./media/075.png"); rfs[76]= loadTex("./media/076.png"); rfs[77]= loadTex("./media/077.png"); rfs[78]= loadTex("./media/078.png"); rfs[79]= loadTex("./media/079.png"); rfs[80]= loadTex("./media/080.png"); ITexture *boden= loadTex("./media/boden.jpg"); ITexture *tapete= loadTex("./media/tapete.jpg"); ITexture *decke= loadTex("./media/boden.jpg"); IAnimatedMeshSceneNode *bodenn,*decken,*wandn; wandn=createQ(tapete,dimension2df(wxsz,wysz),smgr,10,1,root); wandn->setPosition(vector3df(0,0,0)); wandn->setRotation(vector3df(90,180,0)); decken=createQ(decke,dimension2df(wxsz,bzsz),smgr,10,2,root); decken->setPosition(vector3df(0,wysz/2,-bzsz/2)); decken->setRotation(vector3df(180,180,0)); bodenn=createQ(boden,dimension2df(wxsz,bzsz),smgr,10,2,root); bodenn->setPosition(vector3df(0,-wysz/2,-bzsz/2)); bodenn->setRotation(vector3df(0,0,0)); float picdist=8; float picxs=6; float picys=8; float py=0; int curwpic=0; for (float px=-wxsz/2;pxsetRotation(vector3df(90,180,180)); pic->setPosition(vector3df(px,py,-0.01)); curwpic=(curwpic+1)%numwandpics; } for (int i=0;isetName("jomani"); rf->setMaterialType(E_MATERIAL_TYPE::EMT_TRANSPARENT_ALPHA_CHANNEL); rf->setPosition(vector3df(wxsz*rand()/(float)RAND_MAX-wxsz/2,-2.5,-(bzsz/2)*rand()/(float)RAND_MAX)); rf->setRotation(vector3df(90,180,180)); rfslist[i]=rf; } return root; } unsigned int cx = 0; unsigned int cy = 0; MyEventReceiver evrc; scene::ISceneManager* smgr; ICameraSceneNode* cam; ITexture *tex; ITexture *tex2; ITexture *tex3; ITexture *tex4; ITexture *tex5; ITexture *tex6; ITexture *tex7; ITexture *tex8; ITexture *tex9; ITexture *tex14; ITexture *tex10; ITexture *tex11; ITexture *tex12; ITexture *tex13; ITexture *baumback1; ITexture *wandpics[100]; ISceneNode *exhib; ISceneNode* sn; scene::ISceneNodeAnimator* anim; video::ITexture* normalMap; scene::IMesh* tangentMesh; scene::IAnimatedMesh *atangentMesh; IAnimatedMeshSceneNode *amsn; IMeshSceneNode *explnode; IMesh *unwelded; S3DVertex *vertices; S3DVertex *origvertices; vector3df * trispeeds; int demooffset=0*takt; IMeshManipulator *mm; dimension2d oldtnsz; int inittime; int elapsed=0; u32 frames=0; wchar_t *buf; IBillboardSceneNode *bbtn2; IBillboardSceneNode *bbtn3; extern "C" { int playable=0; float playit(int u) { float ct=floor(now/1000.0)+1; while(ct>getTick()/1000.0){device->run();} return ct; } } const char* nowstr2="var vid=document.createElement(\"\");document.appendChild(vid);"; IAnimatedMeshSceneNode *back; void main_loop() { int width = canvas_get_width(); int height = canvas_get_height(); if (cx!=width||cy!=height){ cx=width; cy=height; aspect=(float)cx/(float)cy; cam->setAspectRatio(aspect); } if (now==-1) { inittime=getTick(); lasttime=getTick(); now=getTick(); elapsed=0; frames=0; demostate=0; } device->run(); now=getTick()-inittime; if (now0){ elapsed=now-lasttime; } lasttime=now; if (now>6*takt && now <12*takt){ dimension2d cursz=oldtnsz; float fakt=((float)(8.0*takt-now))/((float)(2.0*takt)); cursz.set((float)oldtnsz.Width*fakt,(float)oldtnsz.Height*fakt); } if (now>8*takt && demostate<21){ demostate+=10; sn->setMaterialTexture(0,tex2); amsn->setMaterialTexture(0,tex2); } if (now>10*takt && demostate<31){ demostate+=10; sn->setMaterialTexture(0,tex3); amsn->setMaterialTexture(0,tex3); } int explbegin=12*takt; int outcount; if (now>explbegin && demostate<41){ demostate+=10; explnode=smgr->addMeshSceneNode(unwelded,smgr->getRootSceneNode()); explnode->setPosition(amsn->getPosition()); explnode->setRotation(amsn->getRotation()); explnode->setMaterialTexture(0,amsn->getMaterial(0).TextureLayer->Texture); explnode->setMaterialTexture(1,amsn->getMaterial(0).getTexture(1)); explnode->setMaterialType(amsn->getMaterial(0).MaterialType); explnode->setMaterialFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); amsn->setPosition(vector3df(5000,0,5000)); IMeshBuffer *mb=explnode->getMesh()->getMeshBuffer(0); vertices=(S3DVertex*)(mb->getVertices()); outcount=mb->getVertexCount(); origvertices=new S3DVertex[outcount]; for (int i=0;iaddAnimator(anim); } if (now>explbegin && nowsetRotation(amsn->getRotation()); if (now>explbegin && nowexplbegin+2*takt && now<=explbegin+3*takt){ for (int i=0;iexplbegin+3*takt && now<=explbegin+4*takt){ for (int i=0;iexplbegin+4*takt && now<=explbegin+6*takt){ for (int i=0;iexplbegin+6*takt && nowexplbegin+8*takt && nowexplbegin+10*takt && now<=explbegin+12*takt){ for (int i=0;iexplbegin+12*takt && demostate<51){ amsn->setVisible(false); amsn->remove(); amsn=0; demostate+=10; SMaterial *mat=new SMaterial(); mat->setTexture(0,tex4); mat->setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); IAnimatedMesh* hillplane=smgr->addHillPlaneMesh("hp1",dimension2df(1000,1000),dimension2d(1,1),mat,0,dimension2d(1,1),dimension2d(100,100)); explnode->remove(); plane=smgr->addAnimatedMeshSceneNode(hillplane,smgr->getRootSceneNode()); plane->setPosition(vector3df(0,-30,0)); } if (now>explbegin+12*takt && nowgetRelativeTransformation().rotateVect(uv); plane->setPosition(uv*90.0*((float)now-explbegin-12.0*takt)/(4.0*takt)+vector3df(0,-30,0)); plane->setRotation(vector3df(180,0,90.0*((float)now-explbegin-12.0*takt)/(4.0*takt))); } IAnimatedMeshSceneNode *billrot; if (now>explbegin+16*takt && demostate<61){ demostate+=10; SMaterial *mat=new SMaterial(); mat->setTexture(0,tex5); mat->setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); IAnimatedMesh* hillplane=smgr->addHillPlaneMesh("hp2",dimension2df(10,10),dimension2d(1,1),mat,0,dimension2d(1,1),dimension2d(1,1)); billrot=smgr->addAnimatedMeshSceneNode(hillplane,smgr->getRootSceneNode()); billrot->setPosition(vector3df(0,-30,0)); billrot->setRotation(vector3df(180,0,0)); billrot->setMaterialType(E_MATERIAL_TYPE::EMT_TRANSPARENT_ALPHA_CHANNEL); plane->remove(); } if (now>explbegin+16*takt && nowsetPosition(vector3df(0,-30,0)+vector3df(0,-8*(now%(int)(8*takt))/(8*takt),0)); billrot->setRotation(billrot->getRotation()-vector3df(0,elapsed*((now%(int)(takt/8)/(float)(takt/8)))/5.0,0)); } if (now>explbegin+20*takt && demostate<71){ billrot->remove(); demostate+=10; SMaterial *mat=new SMaterial(); mat->setTexture(0,tex6); mat->setFlag(E_MATERIAL_FLAG::EMF_LIGHTING,false); } if (now>=explbegin+20*takt && demostate<81){ demostate+=10; smgr->clear(); amsn=0; cam=smgr->addCameraSceneNode(smgr->getRootSceneNode(), core::vector3df(-wxsz/3,0,-bzsz/2), core::vector3df(0,0,100000));sn=smgr->addSkyBoxSceneNode(tex,tex2,tex3,tex4,tex5,tex11,0,0); cam->bindTargetAndRotation(false); cam->setUpVector(vector3df(0,1,0)); cam->setAspectRatio(aspect); smgr->getRootSceneNode()->addChild(exhib); } if (now>=explbegin+20*takt && now<56*takt){ for ( int iii=0;iiitakt/32.0f ){ rfstimes[iii]=0.0f; rfstexnums[iii]=(rfstexnums[iii]+1)%numrfs; rfslist[iii]->setMaterialTexture(0,rfs[rfstexnums[iii]]); }} int unit=takt/8; int nowd=now-250<0?now:now-250; cam->setPosition(cam->getPosition()+vector3df(elapsed/650.0,0,0)); } if (now>=56*takt && demostate<91){ demostate+=10; smgr->clear(); amsn=0; cam=smgr->addCameraSceneNode(smgr->getRootSceneNode(),vector3df(0,0,0),vector3df(0,0,100000000));sn=smgr->addSkyBoxSceneNode(tex,tex2,tex3,tex4,tex10,tex9,0,0); cam->setUpVector(vector3df(0,1,0)); cam->setAspectRatio(aspect); Turtles::turtleson=true; Turtles::add((new Turtle(now,vector3df(0,-10,20),vector3df(0,1,0),1))); back=createQ(baumback1,dimension2df(10000,10000),smgr,3000,3000,smgr->getRootSceneNode()); back->setRotation(vector3df(90,180,180)); back->setPosition(vector3df(0,0,21)); } if (now>=56*takt && now <72*takt){ cam->setPosition(POI+vector3df(0,0,-1.5)); cam->setTarget(POI); } if (now>=72*takt && demostate<101){ Turtles::clear(); demostate+=10; amsn=0; Turtles::turtleson=true; cam=smgr->addCameraSceneNode(smgr->getRootSceneNode(),vector3df(0,5,-5)); cam->setUpVector(vector3df(0,1,0)); cam->setAspectRatio(aspect); Turtles::add((new BTurtle(now,vector3df(0,2,0),vector3df(0,1,0),takt))); } if (now>=72*takt && now <88*takt){ cam->setPosition(vector3df(sin(now/1000.0)*5,5,cos(now/1000.0)*5)); cam->setTarget(vector3df(0,5,0)); } if (now>88*takt){ aabbox3df box=Turtles::getAABB(); vector3df center=Turtles::getAABB().getCenter(); cam->setPosition(center-vector3df(0,0,-1)); cam->setTarget(center); } if (now>=88*takt && demostate<121){ back->setVisible(false); demostate+=10; Turtles::clear(); for (int i=0;i<50;i++){ Turtles::add((new Bird((float)now+rand()*500/(float)RAND_MAX,vector3df(-5+10*rand()/(float)RAND_MAX,5+10*rand()/(float)RAND_MAX,-5+10*rand()/(float)RAND_MAX),vector3df(0.1,0,-1),vector3df(0,1,0),0))); } cam->setPosition(vector3df(0,0,-5)); IAnimatedMeshSceneNode *boden=createQ(tex4,dimension2df(10000,10000),smgr,1000,1000,smgr->getRootSceneNode()); boden->setPosition(vector3df(0,0,0)); boden->setRotation(vector3df(0,0,0)); } if (sn) sn->setRotation(sn->getRotation()+vector3df(elapsed/200.0,0,0)); if (amsn && amsn->getPosition().Y>-30) amsn->setPosition(amsn->getPosition()+vector3df(0,-4*elapsed/1000.0,0)); driver->beginScene(true, true, SColor(255,255,255,255)); smgr->drawAll(); if (Turtles::turtleson){ driver->setTransform(video::ETS_WORLD,matrix4()); Turtles::draw(); Turtles::update(now); } driver->endScene(); } int main(int,char**){ int width = canvas_get_width(); int height = canvas_get_height(); lasttime=0;inittime=0; cx=width; cy=height; aspect=(float)cx/(float)cy; buf=new wchar_t(1000); for (int i=0;i(cx,cy), 16, false); guienv = device->getGUIEnvironment(); device->getCursorControl()->setVisible(false); device->setWindowCaption(L"SOUNDBRETT.DE"); device->setEventReceiver(&evrc); driver = device->getVideoDriver(); smgr = device->getSceneManager(); driver->beginScene(); smgr->drawAll(); guienv->drawAll(); driver->endScene(); trimb=new SMeshBuffer(); S3DVertex triverts[4]; u16 triinds[6]={0,1,2,2,3,0}; trimb->append(triverts,4,triinds,6); cam=smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0)); cam->setUpVector(vector3df(1,0,0)); cam->setAspectRatio(aspect); mySphereMesh = smgr->addSphereMesh("sphere1",5,32,32); molSphereMesh = smgr->addSphereMesh("spheremol",3,3,3); tex= loadTex("./media/1.jpg"); tex2= loadTex("./media/2.jpg"); tex3= loadTex("./media/3.jpg"); tex4= loadTex("./media/4.jpg"); tex5= loadTex("./media/5.png"); tex6= loadTex("./media/6.jpg"); tex7= loadTex("./media/7.jpg"); tex8= loadTex("./media/8.jpg"); tex9= loadTex("./media/9.jpg"); tex10= loadTex("./media/10.jpg"); tex11= loadTex("./media/11.jpg"); tex12= loadTex("./media/12.jpg"); tex13= loadTex("./media/13.jpg"); baumback1= loadTex("./media/12.jpg"); astzeug1= loadTex("./media/as1.jpg"); ITexture *wandpics[10]; int numwandpics=10; wandpics[0]=tex; wandpics[1]=tex2; wandpics[2]=tex3; wandpics[3]=tex4; wandpics[4]=tex9; wandpics[5]=tex6; wandpics[6]=tex7; wandpics[7]=tex8; wandpics[8]=tex10; wandpics[9]=tex13; exhib=createExhibition(smgr,wandpics,numwandpics); sn=smgr->addSkyDomeSceneNode(tex,(u32)40,(u32)40,(f32)1,(f32)2,1000,0,0); anim = smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f)); tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(mySphereMesh->getMesh(0)); atangentMesh=smgr->getMeshManipulator()->createAnimatedMesh(tangentMesh); amsn = smgr->addAnimatedMeshSceneNode(atangentMesh); amsn->getMaterial(0).SpecularColor.set(255,255,255,128); amsn->getMaterial(0).DiffuseColor.set(255,255,255,128); amsn->setMaterialFlag(video::EMF_LIGHTING, false); amsn->setMaterialType(E_MATERIAL_TYPE::EMT_SOLID); amsn->getMaterial(0).MaterialTypeParam = 0.035f; // adjust height for parallax effect amsn->setMaterialTexture(0, tex); sn->setMaterialTexture(0, tex); amsn->addAnimator(anim); demostate=0; sn->setRotation(vector3df(0,90,0)); mm=smgr->getMeshManipulator(); unwelded=mm->createMeshUniquePrimitives(mySphereMesh->getMesh(0)); now=-1; emscripten_set_main_loop(main_loop, 0, 1); return 0; } void Turtle::spread(float now){ if (Turtles::numturtles>0) Turtles::turtles[Turtles::numturtles-1]->isPOI=true; if ( !isPOI) return; for (int i=0;i<4;i++){ vector3df unit(0,1,0); unit.rotateXYBy(360.0f*rand()/(float)RAND_MAX,vector3df(0,0,0)); vector3df newdir=direction+unit; if (i==3) newdir+=vector3df(0,0,-0.1); newdir=newdir.normalize(); Turtle *newt=new Turtle(now,getEP(),newdir,spreadlens[spreadlensidx]*takt/2.0f); Turtles::add(newt); } spreadlensidx=(spreadlensidx+1)%numspreadlens; }