1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkOpenGLActor.cxx,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkOpenGLActor.h"
#include "vtkMapper.h"
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLRenderer.h"
#include "vtkProperty.h"
#include "vtkOpenGL.h"
#include <math.h>
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLActor, "$Revision: 1.29 $");
vtkStandardNewMacro(vtkOpenGLActor);
#endif
// Actual actor render method.
void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
{
float opacity;
// get opacity
opacity = this->GetProperty()->GetOpacity();
if (opacity == 1.0)
{
glDepthMask (GL_TRUE);
}
else
{
// add this check here for GL_SELECT mode
// If we are not picking, then don't write to the zbuffer
// because we probably haven't sorted the polygons. If we
// are picking, then translucency doesn't matter - we want to
// pick the thing closest to us.
GLint param[1];
glGetIntegerv(GL_RENDER_MODE, param);
if(param[0] == GL_SELECT )
{
glDepthMask(GL_TRUE);
}
else
{
glDepthMask (GL_FALSE);
}
}
// build transformation
if (!this->IsIdentity)
{
double *mat = this->GetMatrix()->Element[0];
double mat2[16];
mat2[0] = mat[0];
mat2[1] = mat[4];
mat2[2] = mat[8];
mat2[3] = mat[12];
mat2[4] = mat[1];
mat2[5] = mat[5];
mat2[6] = mat[9];
mat2[7] = mat[13];
mat2[8] = mat[2];
mat2[9] = mat[6];
mat2[10] = mat[10];
mat2[11] = mat[14];
mat2[12] = mat[3];
mat2[13] = mat[7];
mat2[14] = mat[11];
mat2[15] = mat[15];
// insert model transformation
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glMultMatrixd(mat2);
}
// send a render to the mapper; update pipeline
mapper->Render(ren,this);
// pop transformation matrix
if (!this->IsIdentity)
{
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
}
if (opacity != 1.0)
{
glDepthMask (GL_TRUE);
}
}
//----------------------------------------------------------------------------
void vtkOpenGLActor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
|