mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 11:26:11 +00:00
minor: rendering of laser beam is done in image space now and initial beam is propotional to screen size rather than model diagonal
This commit is contained in:
parent
60fcfe0f3e
commit
fe7f3be7f0
@ -84,6 +84,9 @@ bool VirtualScan::StartEdit(MeshDocument& md, GLArea* gla){
|
||||
connect(widget, SIGNAL(scan_requested()),
|
||||
this, SLOT(scan_requested()));
|
||||
|
||||
//--- Compute initial beam
|
||||
laser_parameter_updated();
|
||||
|
||||
return true;
|
||||
}
|
||||
// We need to refresh the laser scan completely!
|
||||
@ -91,13 +94,18 @@ void VirtualScan::laser_parameter_updated(){
|
||||
//--- Retrieve values from GUI
|
||||
int period = 1000 / widget->getSampfreq();
|
||||
int numsamp = widget->getNumsample();
|
||||
float width = widget->getScanwidth()*md->mm()->cm.bbox.Diag()/100.0;
|
||||
|
||||
qDebug("period: %d, samples: %d, width: %f", period, numsamp, width);
|
||||
// Compute start and stop coordinates in image space
|
||||
Point2f delta( widget->getScanwidth()*gla->height()/(3.0*100.0), 0 );
|
||||
Point2f str( gla->width()/2, gla->height()/2 ); str-=delta;
|
||||
Point2f sto( gla->width()/2, gla->height()/2 ); sto+=delta;
|
||||
// float width = *md->mm()->cm.bbox.MaxDim()/100.0;
|
||||
qDebug("period: %d, samples: %d", period, numsamp);
|
||||
qDebug() << toString(str) << " " << toString(sto);
|
||||
|
||||
//--- Create the geometry of the scanline
|
||||
gla->update(); // since we use gluproject
|
||||
sline = ScanLine( numsamp, width );
|
||||
sline = ScanLine( numsamp, str, sto);
|
||||
// sline = ScanLineGeom( 10, .1 ); // hardcoded parameters (GUI independent)
|
||||
|
||||
//--- Create a timer which enables scanning periodically
|
||||
@ -173,26 +181,16 @@ void VirtualScan::Decorate(MeshModel& mm, GLArea* gla){
|
||||
sline.render(gla);
|
||||
}
|
||||
|
||||
ScanLine::ScanLine(int N, float width){
|
||||
// Compute start and stop coordinates in image space
|
||||
Point2f srt = myGluProject(Point3f(-width/2,0,0));
|
||||
Point2f sto = myGluProject(Point3f(+width/2,0,0));
|
||||
float delta = width/N;
|
||||
// qDebug() << "Scanpoint list: ";
|
||||
for( float i=0; i<=1; i+=delta ){
|
||||
if( N==1 )
|
||||
i = .5;
|
||||
Point2f curr = srt*(1-i) + sto*i;
|
||||
ScanLine::ScanLine(int N, Point2f& srt, Point2f& end ){
|
||||
float delta = 1.0 / (N-1);
|
||||
qDebug() << "Scanpoint list: ";
|
||||
float alpha=0;
|
||||
for( int i=0; i<N; i++, alpha+=delta ){
|
||||
Point2f curr = srt*(1-alpha) + end*alpha;
|
||||
soff.push_back(curr);
|
||||
// qDebug() << " - " << toString( curr );
|
||||
qDebug() << " - " << toString( curr );
|
||||
Point2i currI( curr[0], curr[1] );
|
||||
bbox.Add(currI);
|
||||
// Invert samples and put them as close camera as possible
|
||||
Point3f curr_o = myGluUnProject(curr,0.01);
|
||||
soff_obj.push_back(curr_o);
|
||||
|
||||
if( N==1 )
|
||||
break;
|
||||
}
|
||||
// Retrieve a block 2 pixel larger from buffer
|
||||
bbox.Offset(2);
|
||||
@ -241,38 +239,28 @@ void ScanLine::render(GLArea* gla){
|
||||
qDebug();
|
||||
#endif
|
||||
|
||||
// since image space drawing is not working, then
|
||||
// draw in object space instead!
|
||||
// This draws directly in 2D image space
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glPointSize(SCANPOINTSIZE);
|
||||
glColor(Color4f(255,0,0,255));
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glBegin(GL_POINTS);
|
||||
for(int i=0; i<soff_obj.size(); i++){
|
||||
Point3f p = soff_obj[i];
|
||||
// TODO: correction for the -1000 offset meshlab seems to put
|
||||
p[2]-=1000;
|
||||
glVertex(p);
|
||||
}
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
// This draws directly in 2D image space
|
||||
#if 0
|
||||
// Attempts to render the scanline
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
// Now draw some 2D stuff
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0, gla->width(), gla->height(), 0, -1, 1);
|
||||
glOrtho(0, gla->width(), 0, gla->height(), -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glColor3f(1.0,0.0,0.0);
|
||||
glBegin(GL_POINTS);
|
||||
for(int i=0; i<soff.size(); i++)
|
||||
glVertex(soff[i]);
|
||||
// glVertex2f( gla->width()/2, gla->height()/2 );
|
||||
glEnd();
|
||||
// glRectf(100,100, 200, 200);
|
||||
glPopMatrix(); // restore modelview
|
||||
// The pop must be done in the projection mode
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glRectf(100,100, 200, 200);
|
||||
glPopMatrix();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Must be at the end of everything in CPP file or get segfault at plugin load
|
||||
|
||||
@ -9,19 +9,17 @@
|
||||
using namespace vcg;
|
||||
using namespace std;
|
||||
|
||||
#define SCANPOINTSIZE 5
|
||||
#define SCANPOINTSIZE 2
|
||||
|
||||
class ScanLine{
|
||||
public:
|
||||
// Screen offsets of scan points
|
||||
vector<Point2f> soff;
|
||||
// Object space locations (for rendering)
|
||||
vector<Point3f> soff_obj;
|
||||
Box2i bbox;
|
||||
bool isScanning;
|
||||
|
||||
ScanLine(){}
|
||||
ScanLine(int N, float aperture);
|
||||
ScanLine(int N, Point2f&, Point2f& );
|
||||
void render(GLArea* gla);
|
||||
};
|
||||
|
||||
|
||||
@ -72,15 +72,15 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render</value>
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render</value>
|
||||
<value type="QString">COMMAND_MODE=unix2003</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-nJGktF/:0</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-6Z6Ywn/:0</value>
|
||||
<value type="QString">HOME=/Users/ata2</value>
|
||||
<value type="QString">LOGNAME=ata2</value>
|
||||
<value type="QString">PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin</value>
|
||||
<value type="QString">QTDIR=/usr/local/Qt4.6</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners</value>
|
||||
<value type="QString">TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/</value>
|
||||
<value type="QString">USER=ata2</value>
|
||||
<value type="QString">__CF_USER_TEXT_ENCODING=0x1F7:0:0</value>
|
||||
@ -101,15 +101,15 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render</value>
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render</value>
|
||||
<value type="QString">COMMAND_MODE=unix2003</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-nJGktF/:0</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-6Z6Ywn/:0</value>
|
||||
<value type="QString">HOME=/Users/ata2</value>
|
||||
<value type="QString">LOGNAME=ata2</value>
|
||||
<value type="QString">PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin</value>
|
||||
<value type="QString">QTDIR=/usr/local/Qt4.6</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners</value>
|
||||
<value type="QString">TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/</value>
|
||||
<value type="QString">USER=ata2</value>
|
||||
<value type="QString">__CF_USER_TEXT_ENCODING=0x1F7:0:0</value>
|
||||
@ -128,15 +128,15 @@
|
||||
<valuemap type="QVariantMap">
|
||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-qYm1RP/Render</value>
|
||||
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-HB6srV/Render</value>
|
||||
<value type="QString">COMMAND_MODE=unix2003</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-nJGktF/:0</value>
|
||||
<value type="QString">DISPLAY=/tmp/launch-6Z6Ywn/:0</value>
|
||||
<value type="QString">HOME=/Users/ata2</value>
|
||||
<value type="QString">LOGNAME=ata2</value>
|
||||
<value type="QString">PATH=/Developer/Tools/Qt:/usr/bin:/bin:/usr/sbin:/sbin</value>
|
||||
<value type="QString">QTDIR=/usr/local/Qt4.6</value>
|
||||
<value type="QString">SHELL=/bin/bash</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-riNXRq/Listeners</value>
|
||||
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-JDaVUl/Listeners</value>
|
||||
<value type="QString">TMPDIR=/var/folders/nT/nTstT998GAStacv9t5mUAk+++TQ/-Tmp-/</value>
|
||||
<value type="QString">USER=ata2</value>
|
||||
<value type="QString">__CF_USER_TEXT_ENCODING=0x1F7:0:0</value>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user