From 002baf9367417604412ed19d283835c23454349e Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 12 Feb 2020 00:36:04 +0800 Subject: Measure indicators are now solid frames instead of ugly grey cubes. Fixed multiple embodiment of stupidness in the code. --- visualization/extrasmeltutils.cpp | 44 +++++++++++++++++++++++++++++-------- visualization/extrasmeltutils.hpp | 11 ++++++---- visualization/qmpvirtualpiano3d.cpp | 12 +++++----- visualization/qmpvisualization.cpp | 38 ++++++++++++++++---------------- 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;i0&&idx0&&idx0&&idx0&&idx 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)*lpttce-ctk)*lptch==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 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>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); -- cgit v1.2.3