diff options
-rw-r--r-- | visualization/extrasmeltutils.cpp | 44 | ||||
-rw-r--r-- | visualization/extrasmeltutils.hpp | 11 | ||||
-rw-r--r-- | visualization/qmpvirtualpiano3d.cpp | 12 | ||||
-rw-r--r-- | visualization/qmpvisualization.cpp | 38 | ||||
-rw-r--r-- | visualization/qmpvisualization.hpp | 2 |
5 files changed, 68 insertions, 39 deletions
diff --git a/visualization/extrasmeltutils.cpp b/visualization/extrasmeltutils.cpp index 7e766f4..c8b3446 100644 --- a/visualization/extrasmeltutils.cpp +++ b/visualization/extrasmeltutils.cpp @@ -8,7 +8,7 @@ SMELT* smParticle::sm=nullptr; SMELT* smParticleSystem::sm=nullptr; smVertex makeVertex(float x,float y,float z,DWORD color,float tx,float ty) {smVertex v;v.x=x;v.y=y;v.z=z;v.col=color;v.tx=tx;v.ty=ty;return v;} -void smEntity3D::addVerices(int n,...) +void smEntity3D::addVertices(size_t n,...) { va_list vl;va_start(vl,n); for(int i=0;i<n;++i) @@ -18,7 +18,7 @@ void smEntity3D::addVerices(int n,...) } va_end(vl); } -void smEntity3D::addIndices(int n,...) +void smEntity3D::addIndices(size_t n,...) { va_list vl;va_start(vl,n); for(int i=0;i<n;++i) @@ -28,19 +28,45 @@ void smEntity3D::addIndices(int n,...) } va_end(vl); } -smEntity3D smEntity3D::cube(smvec3d a,smvec3d b,DWORD color) +smVertex smEntity3D::vertex(size_t idx)const +{ + if(idx>0&&idx<vertices.size())return vertices[idx]; + return smVertex(); +} +WORD smEntity3D::index(size_t idx)const +{ + if(idx>0&&idx<indices.size())return indices[idx]; + return 0; +} +void smEntity3D::setVertex(size_t idx,smVertex v) +{ + if(idx>0&&idx<vertices.size())vertices[idx]=v; +} +void smEntity3D::setIndex(size_t idx,WORD i) +{ + if(idx>0&&idx<indices.size())indices[idx]=i; +} + +smEntity3D smEntity3D::cube(smvec3d a,smvec3d b,DWORD color,int faces) { - //a: top left corner b: bottom right corner smEntity3D ret; - ret.addVerices(8, + ret.addVertices(8, makeVertex(a.x,a.y,a.z,color,0,0),makeVertex(b.x,a.y,a.z,color,0,0), makeVertex(b.x,b.y,a.z,color,0,0),makeVertex(a.x,b.y,a.z,color,0,0), makeVertex(a.x,a.y,b.z,color,0,0),makeVertex(b.x,a.y,b.z,color,0,0), makeVertex(b.x,b.y,b.z,color,0,0),makeVertex(a.x,b.y,b.z,color,0,0)); - ret.addIndices(36, - 0,1,3,1,2,3, 4,5,7,5,6,7, - 0,3,7,0,4,7, 1,2,6,1,5,6, - 2,3,7,2,6,7, 0,1,4,1,4,5); + if(faces&0x1)//a.z + ret.addIndices(6, 0,1,3, 1,2,3); + if(faces&0x2)//b.z + ret.addIndices(6, 4,5,7, 5,6,7); + if(faces&0x4)//a.x + ret.addIndices(6, 0,3,7, 0,4,7); + if(faces&0x8)//b.x + ret.addIndices(6, 1,2,6, 1,5,6); + if(faces&0x10)//a.y + ret.addIndices(6, 0,1,4, 1,4,5); + if(faces&0x20)//b.y + ret.addIndices(6, 2,3,7, 2,6,7); return ret; } smEntity3DBuffer::smEntity3DBuffer() diff --git a/visualization/extrasmeltutils.hpp b/visualization/extrasmeltutils.hpp index fe9bb73..d827567 100644 --- a/visualization/extrasmeltutils.hpp +++ b/visualization/extrasmeltutils.hpp @@ -13,10 +13,13 @@ class smEntity3D std::vector<WORD> indices; public: smEntity3D(){vertices.clear();indices.clear();} - ~smEntity3D(){vertices.clear();indices.clear();} - void addVerices(int n,...); - void addIndices(int n,...); - static smEntity3D cube(smvec3d tl,smvec3d br,DWORD color); + void addVertices(size_t n,...); + void addIndices(size_t n,...); + smVertex vertex(size_t idx)const; + WORD index(size_t idx)const; + void setVertex(size_t idx,smVertex v); + void setIndex(size_t idx,WORD i); + static smEntity3D cube(smvec3d tl,smvec3d br,DWORD color,int faces=63); }; class smEntity3DBuffer { diff --git a/visualization/qmpvirtualpiano3d.cpp b/visualization/qmpvirtualpiano3d.cpp index b622dd5..0fbf75f 100644 --- a/visualization/qmpvirtualpiano3d.cpp +++ b/visualization/qmpvirtualpiano3d.cpp @@ -52,7 +52,7 @@ void qmpVirtualPiano3D::buildKeys() { wkcf=new smEntity3D();wkeb=new smEntity3D();wkd=new smEntity3D(); wkg=new smEntity3D();wka=new smEntity3D();bk=new smEntity3D(); - wkcf->addVerices(19, + wkcf->addVertices(19, makeVertex(-WK_TALWIDTH/2,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(-WK_TALWIDTH/2+WK_PREWIDTH,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(-WK_TALWIDTH/2+WK_PREWIDTH,WK_PRELEN,WK_HEIGHT,0xFFFFFFFF,0,0), @@ -78,7 +78,7 @@ void qmpVirtualPiano3D::buildKeys() 9,10,15, 10,15,16, 10,11,17, 10,16,17, 11,12,18, 11,17,18, 18,12,13, 12,13,7); - wkeb->addVerices(19, + wkeb->addVertices(19, makeVertex( WK_TALWIDTH/2,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex( WK_TALWIDTH/2-WK_PREWIDTH,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex( WK_TALWIDTH/2-WK_PREWIDTH,WK_PRELEN,WK_HEIGHT,0xFFFFFFFF,0,0), @@ -104,7 +104,7 @@ void qmpVirtualPiano3D::buildKeys() 9,10,15, 10,15,16, 10,11,17, 10,16,17, 11,12,18, 11,17,18, 18,12,13, 12,13,7); - wkd->addVerices(24, + wkd->addVertices(24, makeVertex(-WK_TALWIDTH/2+(WK_TALWIDTH-WK_PREWIDTH)/2,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex( WK_TALWIDTH/2-(WK_TALWIDTH-WK_PREWIDTH)/2,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex( WK_TALWIDTH/2-(WK_TALWIDTH-WK_PREWIDTH)/2,WK_PRELEN,WK_HEIGHT,0xFFFFFFFF,0,0), @@ -136,7 +136,7 @@ void qmpVirtualPiano3D::buildKeys() 13,14,21, 13,20,21, 14,15,21, 15,21,22, 15,11,22, 11,22,23, 11,23,8, 23,16,8); - wkg->addVerices(24, + wkg->addVertices(24, makeVertex(-WK_TALWIDTH/2+WK_WING+WK_TALWIDTH/12,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(-WK_TALWIDTH/2+WK_WING+WK_TALWIDTH/12+WK_PREWIDTH,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(-WK_TALWIDTH/2+WK_WING+WK_TALWIDTH/12+WK_PREWIDTH,WK_PRELEN,WK_HEIGHT,0xFFFFFFFF,0,0), @@ -168,7 +168,7 @@ void qmpVirtualPiano3D::buildKeys() 13,14,21, 13,20,21, 14,15,21, 15,21,22, 15,11,22, 11,22,23, 11,23,8, 23,16,8); - wka->addVerices(24, + wka->addVertices(24, makeVertex(WK_TALWIDTH/2-WK_WING-WK_TALWIDTH/24-WK_PREWIDTH,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(WK_TALWIDTH/2-WK_WING-WK_TALWIDTH/24,0,WK_HEIGHT,0xFFFFFFFF,0,0), makeVertex(WK_TALWIDTH/2-WK_WING-WK_TALWIDTH/24,WK_PRELEN,WK_HEIGHT,0xFFFFFFFF,0,0), @@ -200,7 +200,7 @@ void qmpVirtualPiano3D::buildKeys() 13,14,21, 13,20,21, 14,15,21, 15,21,22, 15,11,22, 11,22,23, 11,23,8, 23,16,8); - bk->addVerices(10, + bk->addVertices(10, makeVertex(-BK_WIDTH/2,0,BK_HEIGHT+BK_BOTTOM,0xFF000000,0,0), makeVertex( BK_WIDTH/2,0,BK_HEIGHT+BK_BOTTOM,0xFF000000,0,0), makeVertex( BK_WIDTH/2,BK_PRELEN,BK_HEIGHT+BK_BOTTOM,0xFF000000,0,0), diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp index 899597a..e725263 100644 --- a/visualization/qmpvisualization.cpp +++ b/visualization/qmpvisualization.cpp @@ -274,26 +274,26 @@ void qmpVisualization::updateVisualization3D() if(fabs((double)pool[i]->tcs-ctk)*lpt<viewdist*2||fabs((double)pool[i]->tce-ctk)*lpt<viewdist*2) { if(pool[i]->ch==999){ - if(!horizontal&&stairpiano){ - for(int ch=0;ch<16;++ch){ - smvec3d a(0.63*(-80)+.1,(stairpiano?(56-ch*7.):(64-ch*8.))-1,((double)pool[i]->tce+1-ctk)*lpt+(stairpiano&&showpiano&&!horizontal)*ch*2.); - smvec3d b(0.63*80+.7,(stairpiano?(56-ch*7.):(64-ch*8.))+4,((double)pool[i]->tcs-ctk)*lpt+(stairpiano&&showpiano&&!horizontal)*ch*2.); - if(horizontal){ - a=smvec3d(((double)pool[i]->tcs-ctk)*lpt-20,(16-ch*2.),0.63*(-64)+.1); - b=smvec3d(((double)pool[i]->tce+1-ctk)*lpt-20,(16-ch*2.)+.4,0.63*64+.7); - } - if(showmeasure)drawCube(a,b,0x80808080,0); - } + smvec3d a(0.63*(-64)+.1-10,(stairpiano?(56-0*7.):(64-0*8.))+10,((double)pool[i]->tcs-ctk)*lpt-minnotelength*.005); + smvec3d b(0.63*64+.7+10,(stairpiano?(56-15*7.):(64-15*8.))+.4-10,((double)pool[i]->tcs-ctk)*lpt+minnotelength*.005); + if(horizontal){ + a=smvec3d(((double)pool[i]->tcs-ctk)*lpt-20-minnotelength*.001,(16- 0*2.)+2.4,0.63*(-64)+.1); + b=smvec3d(((double)pool[i]->tcs-ctk)*lpt-20+minnotelength*.001,(16-15*2.)+0.4,0.63*64+.7); } - else{ - smvec3d a(0.63*(-64)+.1,(stairpiano?(56-0*7.):(64-0*8.)),((double)pool[i]->tce+1-ctk)*lpt+(stairpiano&&showpiano&&!horizontal)*0*2.); - smvec3d b(0.63*64+.7,(stairpiano?(56-15*7.):(64-15*8.))+.4,((double)pool[i]->tcs-ctk)*lpt+(stairpiano&&showpiano&&!horizontal)*15*2.); - if(horizontal){ - a=smvec3d(((double)pool[i]->tcs-ctk)*lpt-20,(16-0*2.),0.63*(-64)+.1); - b=smvec3d(((double)pool[i]->tce+1-ctk)*lpt-20,(16-15*2.)+.4,0.63*64+.7); + smMatrix I;I.loadIdentity(); + smEntity3D c=smEntity3D::cube(a,b,0xFF000000,horizontal?51:60); + if(stairpiano&&showpiano&&!horizontal) + { + std::vector<size_t> il={2,3,6,7}; + for(size_t ti:il) + { + smVertex t=c.vertex(ti); + t.z+=30; + c.setVertex(ti,t); } - if(showmeasure)drawCube(a,b,0x80808080,0); } + if(showmeasure) + nebuf->addTransformedEntity(&c,I,smvec3d(0,0,0)); continue; } if(api->getChannelMask(pool[i]->ch))continue; @@ -707,13 +707,13 @@ bool qmpVisualization::update() return shouldclose; } -void qmpVisualization::drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex) +void qmpVisualization::drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex,int faces) { smQuad q;q.blend=BLEND_ALPHABLEND; q.tex=tex;for(int i=0;i<4;++i)q.v[i].col=col; if(noteappearance==1) { - smMatrix I;I.loadIdentity();smEntity3D c=smEntity3D::cube(a,b,col); + smMatrix I;I.loadIdentity();smEntity3D c=smEntity3D::cube(a,b,col,faces); nebuf->addTransformedEntity(&c,I,smvec3d(0,0,0)); } else diff --git a/visualization/qmpvisualization.hpp b/visualization/qmpvisualization.hpp index 981ebe3..34bacc1 100644 --- a/visualization/qmpvisualization.hpp +++ b/visualization/qmpvisualization.hpp @@ -44,7 +44,7 @@ class qmpVisualization:public qmpPluginIntf,public qmpFuncBaseIntf std::vector<std::pair<uint32_t,uint32_t>>tspool; int traveld[16][128];bool notestatus[16][128],lastnotestatus[16][128]; int spectra[16][128],spectrar[16][128]; - void drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex); + void drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex,int faces=63); void showThread(); void pushNoteOn(uint32_t tc,uint32_t ch,uint32_t key,uint32_t vel); void pushNoteOff(uint32_t tc,uint32_t ch,uint32_t key); |