本文整理汇总了C++中vcg::Trackball::Apply方法的典型用法代码示例。如果您正苦于以下问题:C++ Trackball::Apply方法的具体用法?C++ Trackball::Apply怎么用?C++ Trackball::Apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcg::Trackball
的用法示例。
在下文中一共展示了Trackball::Apply方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
/* Response to a redraw event: renders the scene */
void display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40, width/(float)height, 0.01, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslate( -observerPos );
track.GetView();
track.Apply(false);
glPushMatrix();
float d=mesh.bbox.Diag();
glScale(1.5f/d);
Point3f p = glWrap.m->bbox.Center();
p[1] = glWrap.m->bbox.min[1];
glTranslate(-p);
// the trimesh drawing calls
switch(drawMode)
{
case 0: glWrap.Draw<vcg::GLW::DMSmooth, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 1: glWrap.Draw<vcg::GLW::DMWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 2: glWrap.Draw<vcg::GLW::DMFlatWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 3: glWrap.Draw<vcg::GLW::DMHidden, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 4: glWrap.Draw<vcg::GLW::DMFlat, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
default: break;
}
glPopMatrix();
RenderFloor();
track.DrawPostApply();
SDL_GL_SwapBuffers();
}
示例2: display
void display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40, width/(float)height, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,5, 0,0,0, 0,1,0);
track.center=Point3f(0, 0, 0);
track.radius= 1;
track.GetView();
track.Apply();
glPushMatrix();
float d=1.0f/mesh.bbox.Diag();
glScale(d);
glTranslate(-glWrap.m->bbox.Center());
// the trimesh drawing calls
switch(drawMode)
{
case 0: glWrap.Draw<vcg::GLW::DMSmooth, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 1: glWrap.Draw<vcg::GLW::DMPoints, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 2: glWrap.Draw<vcg::GLW::DMWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 3: glWrap.Draw<vcg::GLW::DMFlatWire, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 4: glWrap.Draw<vcg::GLW::DMHidden, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
case 5: glWrap.Draw<vcg::GLW::DMFlat, vcg::GLW::CMNone,vcg::GLW::TMNone> ();break;
default: break;
}
glPopMatrix();
track.DrawPostApply();
SDL_GL_SwapBuffers();
}
示例3: getDirFromTrackball
Point3f getDirFromTrackball(vcg::Trackball &tb){
glPushMatrix();
gluLookAt(1,-3,-5, 0,0,0, 0,1,0);
tb.center=Point3f(0, 0, 0);
tb.radius= 1;
tb.GetView();
tb.Apply(false);
float pos[4]={0.0f,0.0f,-1.0f,0.0f};
float d[16];
glGetFloatv(GL_MODELVIEW_MATRIX,d);
glPopMatrix();
Point3f res(-d[8],-d[9],-d[10]);
res.Normalize();
return res;
}
示例4: drawLightDir
void drawLightDir()
{
glPushMatrix();
lightTrack.GetView();
lightTrack.Apply(false);
#if 0
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT);
glColor3f(1,1,0);
glDisable(GL_LIGHTING);
const int lineNum=3;
glBegin(GL_LINES);
for(unsigned int i=0;i<=lineNum;++i)
for(unsigned int j=0;j<=lineNum;++j) {
glVertex3f(-1.0f+i*2.0/lineNum,-1.0f+j*2.0/lineNum,-2);
glVertex3f(-1.0f+i*2.0/lineNum,-1.0f+j*2.0/lineNum, 2);
}
glEnd();
glPopAttrib();
#endif
glPopMatrix();
}
示例5: paintGL
void GLWidget::paintGL ()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40, GLWidget::width()/(float)GLWidget::height(), 0.1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,3.5f, 0,0,0, 0,1,0);
track.center=vcg::Point3f(0, 0, 0);
track.radius= 1;
track.GetView();
glPushMatrix();
track.Apply(false);
glPushMatrix();
if(mesh.vert.size()>0)
{
vcg::glScale(2.0f/mesh.bbox.Diag());
glTranslate(-mesh.bbox.Center());
glWrap.Draw(GLW::DrawMode(drawmode),GLW::CMNone,GLW::TMNone);
}
glPopMatrix();
track.DrawPostApply();
glPopMatrix();
if(hasToPick)
{
hasToPick=false;
Point3f pp;
if(Pick<Point3f>(pointToPick[0],pointToPick[1],pp))
{
track.Translate(-pp);
track.Scale(1.25f);
QCursor::setPos(mapToGlobal(QPoint(width()/2+2,height()/2+2)));
}
}
TwDraw();
}
示例6: DisplayFunc
// Draw prime numbers pattern :
void DisplayFunc()
{
float zoom;
float X, Y;
unsigned int primeNumberCounter;
PreDisplay();
zoom = 1.0f / (greatestPrimeNumber+1.0f);
primeNumberCounter = 0;
glPointSize(3.f);
int nbParticlesLeft = 0;
std::vector<float> currentColor;
int currentIndex = 0;
std::map<int, std::vector<float> >::iterator it;
if(previousNbPositions > 0){
it = tableColorProducer.find(currentMessageTrace.at(currentIndex));
nbParticlesLeft = currentMessageTrace.at(currentIndex+1);
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,(GLfloat)glutGet(GLUT_WINDOW_WIDTH) / (GLfloat)glutGet(GLUT_WINDOW_HEIGHT), 1.0, 2000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,5, 0,0,0, 0,1,0);
track.center=vcg::Point3f(0, 0, 0);
track.radius= 1;
track.GetView();
track.Apply(false);
glPushMatrix();
float d=2.0f/(sqrt(dx*dx + dy*dy + dz*dz));
glScalef(d,d,d);
glTranslatef(-cx,-cy,-cz);
glBegin(GL_POINTS);
for(unsigned int i = 0; i < previousNbPositions; i++){
if(it != tableColorProducer.end())
glColor3f(it->second.at(0),it->second.at(1),it->second.at(2));
else
glColor3f(1.f,1.f,1.f);
glVertex3d(positions[i * 3],positions[i * 3 + 1],positions[ i * 3 + 2]);
glColor3f(1.f,1.f,1.f);
nbParticlesLeft--;
if(nbParticlesLeft <= 0 && currentIndex <( (int)(currentMessageTrace.size()) - 2)){
currentIndex+=2;
it = tableColorProducer.find(currentMessageTrace.at(currentIndex));
nbParticlesLeft = currentMessageTrace.at(currentIndex+1);
}
}
glEnd();
DrawSimulationArea();
glPopMatrix();
track.DrawPostApply();
PostDisplay();
}
示例7: drawFrame
//.........这里部分代码省略.........
Point3f lightDir;
if ( cgSettings.P_sem_effect // fixed light dir sem effect
// || mol.sticks // quick Hack: fixed light dir when bonds
)
lightDir= Point3f(0,0,1);
else
lightDir=getDirFromTrackball(lightTrack);
setLightDir( lightDir );
// gluLookAt(0,0,-3, 0,0,0, 0,1,0); original
// gluLookAt(0,0,-3, 0,0,0, 0,1,0); ok for tra
if (mol.hasDefaultView())
gluLookAt(0,0, 40, 0,0,0, 0,1,0);
else
gluLookAt(0,0,-40, 0,0,0, 0,1,0);
if(MovingLightMode)
drawLightDir();
glColor3f(1,1,1);
if (mol.hasDefaultView()) {
float angle, axisX, axisY, axisZ;
mol.getDefaultViewRotation(&angle, &axisX, &axisY, &axisZ);
glRotatef(angle, axisX, axisY, axisZ);
}
if (1) {
//track.center=Point3f(0, 0, 0);
//track.radius= 1;
//setProjection();
if (aniStep>=0) // BH: Doesn't normally seem to be aniStep>=0
{
double extraRot=360.0*aniStep;
// set extra rotation for GIF animation:
switch (hardSettings.GIF_ANIMATION_MODE) {
default:
case 0:
glRotated(-hardSettings.GIF_ROT_SIDEVIEW_ANGLE,1,0,0);
glRotated(extraRot,0,1,0);
break;
case 1:
glRotated(-extraRot,0,0,1);
glRotated(hardSettings.GIF_INSP_ANGLE,0,1,0);
glRotated(extraRot,0,0,1);
break;
case 2:{
double substep[6];
for (int i=0; i<6; i++) {
substep[i]=(aniStep*6-i)*90.0;
if (substep[i]<0) substep[i]=0;
if (substep[i]>90.0) substep[i]=90.0;
}
glRotated(-substep[5], 1,0,0);
glRotated(-substep[4], 0,1,0);
glRotated(-substep[3], 0,1,0);
glRotated(-substep[2], 1,0,0);
glRotated(-substep[1], 0,1,0);
glRotated(-substep[0], 0,1,0);
}break;
}
}
setProjection( mainCanvas.GetVideoSize() );
track.GetView();
track.Apply(false); // Set to true to see the trackball itself.
setProjection( mainCanvas.GetSoftRes() );
if (cgSettings.P_use_shadowmap()) {
shadowmap.computeAsTexture( getGlLightPos() , cgSettings.do_use_doubleshadow(), shadowmapCanvas);
//shadowmap.computeAsTexture( Point3f(0,1,0) );
}
cgSettings.BindShaders();
glEnable(GL_TEXTURE_2D);
//glBindTexture(GL_TEXTURE_2D, molTexture);
glActiveTextureARB(GL_TEXTURE1_ARB);
shadowmapCanvas.SetAsTexture();
mol.Draw();
// shadowmap.m.DrawShadowmap(false);
glDisable(GL_VERTEX_PROGRAM_ARB);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
glDisable(GL_BLEND);
if (cgSettings.UseHalo()>0) mol.DrawHalos();
}
}