Example #1
0
void CTriangleObj::DrawPickingObjectFace(const int objid)
{
	int i, name = objid;
	Vector3i* m_pTriangle = (Vector3i*)m_pPolygon;
	Vector3i *ptri;
    Vector3d *v;

	//draw the triangles 
	SETUP_PICKING_GLENV();
	for (i=0; i<m_nPolygonCount; i++, name++){
		ptri = &m_pTriangle[i];
	    glPushName(name);
			glBegin(GL_TRIANGLES);
				v = &m_pVertex[ptri->x];
				glVertex3dv(&v->x);
				v = &m_pVertex[ptri->y];
				glVertex3dv(&v->x);
				v = &m_pVertex[ptri->z];
				glVertex3dv(&v->x);
			glEnd();
	    glPopName();
	}
}
Example #2
0
//only draws the GL polygon face without normals and colors
//dir implyes if it is in inverse or direct order (false==inverse)
void Face::drawPrimitive(bool dir)
{
	int num=(int)(vertex.size());
	int i;

	if(convex){
		glBegin(GL_POLYGON);
		if(clockwise==dir){
			for(i=0;i<num;i++)
				glVertex3dv(vertex[i].values);
		}
		else{
			for(i=num-1;i>=0;i--)
				glVertex3dv(vertex[i].values);
		}
		glEnd();
	}
	else{
		GLUtesselator *TESS=gluNewTess();
		gluTessCallback(TESS,GLU_BEGIN,MR_TESS glBegin);
		gluTessCallback(TESS,GLU_VERTEX,MR_TESS glVertex3dv);
		gluTessCallback(TESS,GLU_END, glEnd);
		
		gluTessBeginPolygon(TESS, NULL);
		gluTessBeginContour(TESS);

		if(clockwise==dir){
			for(i=0;i<num;i++)gluTessVertex(TESS,vertex[i].values,vertex[i].values);		
		}
		else{ 		
			for(i=num-1;i>=0;i--)gluTessVertex(TESS,vertex[i].values,vertex[i].values);
		}
		gluTessEndContour(TESS);
		gluTessEndPolygon(TESS);
		gluDeleteTess(TESS);
	}
}
Example #3
0
static void displayTria (pScene sc, pMesh mesh, Color *c) {
	pTriangle pt;
	pPoint p0, p1, p2;
	int m;
	unsigned int kk;

	glBegin(GL_TRIANGLES);

	for (m = 0; m < sc->par.nbmat; m++) {
		pMaterial pm;
		unsigned int k;

		pm = &sc->material[m];
		k = pm->depmat[LTria];
		if (!k || pm->flag) continue;

		while (k != 0) {
			pt = &mesh->tria[k];
			if (pt->v[0]) {
				p0 = &mesh->point[pt->v[0]];
				p1 = &mesh->point[pt->v[1]];
				p2 = &mesh->point[pt->v[2]];

				kk = 2 * k + 1;
				glColor4ub((kk & c->rMask) >> c->rShift << c->rBits,
				           (kk & c->gMask) >> c->gShift << c->gBits,
				           (kk & c->bMask) >> c->bShift << c->bBits,
				           (kk & c->aMask) << c->aBits);

				glVertex3dv(p0->c);
				glVertex3dv(p1->c);
				glVertex3dv(p2->c);
			}

			k = pt->nxt;
		}
	}
Example #4
0
/*
** 箱の描画
*/
static void box(double x, double y, double z)
{
  /* 頂点データ */
  const GLdouble vertex[][3] = {
    { 0.0, 0.0, 0.0 },
    {   x, 0.0, 0.0 },
    {   x,   y, 0.0 },
    { 0.0,   y, 0.0 },
    { 0.0, 0.0,   z },
    {   x, 0.0,   z },
    {   x,   y,   z },
    { 0.0,   y,   z },
  };
  
  /* 面データ */
  static const GLdouble *face[][4] = {
    { vertex[0], vertex[1], vertex[2], vertex[3] },
    { vertex[1], vertex[5], vertex[6], vertex[2] },
    { vertex[5], vertex[4], vertex[7], vertex[6] },
    { vertex[4], vertex[0], vertex[3], vertex[7] },
    { vertex[4], vertex[5], vertex[1], vertex[0] },
    { vertex[3], vertex[2], vertex[6], vertex[7] },
  };
  
  /* 面の法線ベクトル */
  static const GLdouble normal[][3] = {
    { 0.0, 0.0,-1.0 },
    { 1.0, 0.0, 0.0 },
    { 0.0, 0.0, 1.0 },
    {-1.0, 0.0, 0.0 },
    { 0.0,-1.0, 0.0 },
    { 0.0, 1.0, 0.0 },
  };
  
  /* 箱の色 */
  static const GLfloat color[] = { 0.8, 0.8, 0.2, 1.0 };
  
  int i, j;
  
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
  glBegin(GL_QUADS);
  for (j = 0; j < 6; j++) {
    glNormal3dv(normal[j]);
    for (i = 4; --i >= 0;) {
      glVertex3dv(face[j][i]);
    }
  }
  glEnd();
}
	void operator()(DM::System *s, const DM::View& v, DM::Component* cmp, DM::Vector3* point, DM::Vector3* color, iterator_pos pos) 
	{
		if (pos == in_between)
		{
			double current_tex = 0;
			if (attr_span != 0)
			{
				const ViewMetaData &vmd = l.getViewMetaData();
				Attribute *a = cmp->getAttribute(l.getAttribute());
				if (a)
				{
					if (a->getType() == Attribute::DOUBLEVECTOR || a->getType() == Attribute::TIMESERIES)
						current_tex = (a->getDoubleVector()[l.getAttributeVectorName()] - vmd.attr_min) / attr_span;
					else
						current_tex = (a->getDouble() - vmd.attr_min) / attr_span;
				}
			}
			else
				current_tex = 0.0;

			current_tex *= 255;

			if (color)
				glColor3dv(&color->x);
			else if (current_tex <= 0)
				glColor3f(0, 0, 0);
			else
			{
				float r = l.LayerColor[(int)current_tex][0] / 255.;
				float g = l.LayerColor[(int)current_tex][1] / 255.;
				float b = l.LayerColor[(int)current_tex][2] / 255.;
				//float a = l.LayerColor[(int)current_tex][3]/255.;
				glColor3f(r, g, b);
			}

			glVertex3dv(&point->x);
		}
		else if (pos == before) 
		{
			glPushName(name_start);
			glBegin(SD_GL_PRIMITIVE);
		} 
		else if (pos == after) 
		{
			glEnd();
			glPopName();
			name_start++;
		}
	}
Example #6
0
void SimpleDraw::IdentifyArrow( const Vec3d  & start, const Vec3d  & end, float lineWidth /*= 2.0*/, float r /*= 1.0*/, float g /*= 0.2f*/, float b /*= 0.2f*/ )
{
	glDisable(GL_LIGHTING);

	// Transparency
	glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glLineWidth(lineWidth);

	glBegin(GL_LINES);

	glColor4f(r/2, g/2, b/2, 0.2f);
	glVertex3dv(start);

	glColor4f(r, g, b, 1.0);
	glVertex3dv(end);

	glEnd();

	glDisable(GL_BLEND);
	glEnable(GL_LIGHTING);
	glLineWidth(1.0);
}
Example #7
0
/* 長方形を表示 引数:x,y,z座標,高さ,幅,x-z平面となす角 */
void myPalse(double x, double y, double z, double h, double w, int angle){
	double v[][3] = {
		{ x - w / 2, y + h / 2 * sin(angle / 180 * PI), z + h / 2 * cos(angle / 180 * PI) },
		{ x - w / 2, y - h / 2 * sin(angle / 180 * PI), z - h / 2 * cos(angle / 180 * PI) },
		{ x + w / 2, y - h / 2 * sin(angle / 180 * PI), z - h / 2 * cos(angle / 180 * PI) },
		{ x + w / 2, y - h / 2 * sin(angle / 180 * PI), z + h / 2 * cos(angle / 180 * PI) }
	};
	glMaterialfv(GL_FRONT, GL_DIFFUSE, deep_green);
	glNormal3d(0.0, sin((90 - angle) / 180 * PI), cos((90 - angle) / 180 * PI));
	glBegin(GL_QUADS);
	for (int i = 0; i < 4; i++){
		glVertex3dv(v[i]);
	}
	glEnd();
}
Example #8
0
void SimpleDraw::IdentifyArrows( StdVector<Vec3d > & starts, StdVector<Vec3d > & ends, float lineWidth /*= 2.0*/, float r /*= 1.0*/, float g /*= 0.2f*/, float b /*= 0.2f*/ )
{
	glDisable(GL_LIGHTING);

	// Transparency
	glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glLineWidth(lineWidth);

	glBegin(GL_LINES);
	for(unsigned int i = 0; i < starts.size(); i++)
	{
		glColor4f(r, g, b, 0.0);
		glVertex3dv(starts[i]);

		glColor4f(r, g, b, 1.0);
		glVertex3dv(ends[i]);
	}
	glEnd();

	glDisable(GL_BLEND);
	glEnable(GL_LIGHTING);
}
void FsGui3DInterface::DrawRectMarker(const YsVec3 &o,const double lng) const
{
	YsVec3 scrnO;
	YsTransform3DCoordToScreenCoord(scrnO,o,viewport,projViewModelTfm);

	YsVec3 quad[4]=
	{
		YsVec3(scrnO.x()-markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()-markerSize,scrnO.z()),
		YsVec3(scrnO.x()+markerSize,scrnO.y()+markerSize,scrnO.z()),
		YsVec3(scrnO.x()-markerSize,scrnO.y()+markerSize,scrnO.z())
	};
	YsTransformScreenCoordTo3DCoord(quad[0],quad[0],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[1],quad[1],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[2],quad[2],viewport,projViewModelTfm);
	YsTransformScreenCoordTo3DCoord(quad[3],quad[3],viewport,projViewModelTfm);

	glBegin(GL_LINE_LOOP);
	glVertex3dv(quad[0]);
	glVertex3dv(quad[1]);
	glVertex3dv(quad[2]);
	glVertex3dv(quad[3]);
	glEnd();
}
Example #10
0
void AABB::draw()
{
    //Shows center for debug propose

    glPushMatrix();
    //glTranslated(-center[0], -center[1], -center[2]);
    //glScaled(zoom_val,zoom_val,zoom_val);;
    glColor3d(color[0],color[1],color[2]);
    glPointSize(25);
    glBegin(GL_POINTS);
    for (int i = 0; i < this->point.size(); ++i) {
        glVertex3dv(this->point[i].ptr());
    }
    glEnd();
    glPopMatrix();

    glColor4d(box_color[0],box_color[1],box_color[2],0.2);

    glBegin(GL_QUADS);
    for(unsigned int j=0;j<this->quad.size();++j) {
        glVertex3dv(quad[j].ptr());
    }
    glEnd();
}
Example #11
0
void DrawPolygon(int nv,YsVec3 v[],YsColor &col,int type)
{
	int i;
	double r,g,b;

	col.GetDoubleRGB(r,g,b);
	glColor3d(r,g,b);

	glEnable(GL_LIGHTING);
	glBegin(type);
	for(i=0; i<nv; i++)
	{
		glVertex3dv(v[i].GetValue());
	}
	glEnd();
}
Example #12
0
void KinectHelper::drawCloud(){
    // qDebug() << "KinectHelper::drawCloud()" << QThread::currentThreadId();
    Q_ASSERT(!mutex()->tryLock());
    if(!data_ready()) return;

    /// The lock allows us to just use a reference to the buffer
    PImage& data = (*points_front_buffer);
    glDisable(GL_LIGHTING);
    glColor3d(1.0,0.0,0.0);
    glBegin(GL_POINTS);
    for(int c=0; c<data.cols(); c++)
        for(int r=0; r<data.rows(); r++)
            glVertex3dv( data(r,c).data() );
    glEnd();
    glEnable(GL_LIGHTING);
}
Example #13
0
static void drawCube()
{
	// キューブの材質パラメータを設定。
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, aCubeMaterial);
	// キューブの頂点を描画。
	glBegin(GL_QUADS);
	for (size_t i = 0; i < 6; ++i)
	{
		glNormal3dv(aCubeNormal[i]);// 法線ベクトルをキューブに当てる。
		for (size_t j = 0; j < 4; ++j)
		{
			glVertex3dv(aCubeVertex[aCubeFace[i][j]]);
		}
	}
	glEnd();
}
Example #14
0
void forceHit(){
    static GLdouble point[4];
    point[0] = pick_x;
    point[1] = pick_y;
    point[2] = current_view->bounds[4];
    point[3] = 1.0;
    
    glPushMatrix();
    glLoadIdentity ();
    
    glBegin(GL_POINTS);
        glVertex3dv(point);//draw a single point to force a hit
    glEnd();    
    
    glPopMatrix();
}
Example #15
0
void
J3DTriangle::Render
(
    J3DPainter& p
)
{
    glBegin(GL_TRIANGLES);

    for (JIndex i=0; i<3; i++)
    {
        p.SetVertexColor(itsVertexColor[i]);
        glVertex3dv(itsVertex[i]->GetElements());
    }

    glEnd();
}
Example #16
0
void SimpleDraw::DrawPoly( const std::vector<Vec3d> & poly, float r, float g, float b)
{	
	glDisable(GL_LIGHTING);

	glColor3f(r, g, b);

	float lineWidth = 15.0f;
	glLineWidth(lineWidth);

	glBegin(GL_LINE_STRIP);
	for(uint i = 0; i <= poly.size(); i++)
		glVertex3dv(poly[i%poly.size()]);
	glEnd();

	glEnable(GL_LIGHTING);
}
Example #17
0
/*
** 箱の描画
*/
void box(double x, double y, double z)
{
  /* 頂点の座標値 */
  const GLdouble vertex[][4][3] = {
    {{ -x, -y, -z }, {  x, -y, -z }, {  x, -y,  z }, { -x, -y,  z }},
    {{ -x, -y, -z }, { -x,  y, -z }, {  x,  y, -z }, {  x, -y, -z }},
    {{  x, -y, -z }, {  x,  y, -z }, {  x,  y,  z }, {  x, -y,  z }},
    {{  x, -y,  z }, {  x,  y,  z }, { -x,  y,  z }, { -x, -y,  z }},
    {{ -x, -y,  z }, { -x,  y,  z }, { -x,  y, -z }, { -x, -y, -z }},
    {{ -x,  y,  z }, {  x,  y,  z }, {  x,  y, -z }, { -x,  y, -z }},
  };
  
  /* 頂点のテクスチャ座標 */
  static const GLdouble texcoord[][4][2] = {
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
    {{ 0.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }},
  };
  
  /* 面の法線ベクトル */
  static const GLdouble normal[][3] = {
    {  0.0, -1.0,  0.0 },
    {  0.0,  0.0, -1.0 },
    {  1.0,  0.0,  0.0 },
    {  0.0,  0.0,  1.0 },
    { -1.0,  0.0,  0.0 },
    {  0.0,  1.0,  0.0 },
  };

  int i, j;
  
  /* 四角形6枚で箱を描く */
  glBegin(GL_QUADS);
  for (j = 0; j < 6; ++j) {
    glNormal3dv(normal[j]);
    for (i = 0; i < 4; ++i) {
      /* テクスチャ座標の指定 */
      glTexCoord2dv(texcoord[j][i]);
      /* 対応する頂点座標の指定 */
      glVertex3dv(vertex[j][i]);
    }
  }
  glEnd();
}
Example #18
0
/* 直方体を描画する関数(横幅w, 高さh, 深さd, X座標x, Y座標y, Z座標z) */
static void myBox(double w, double h, double d, double x, double y, double z){
  GLdouble vertex[][3] = {
    { -w + x, y, -d + z },
    {  w + x, y, -d + z },
    {  w + x,  h + y, -d + z },
    { -w + x,  h + y, -d + z },
    { -w + x, y, d + z },
    {  w + x, y, d + z },
    {  w + x,  h + y, d + z },
    { -w + x,  h + y, d + z }
  };

  const static int face[][4] = {
    { 0, 1, 2, 3 },
    { 1, 5, 6, 2 },
    { 5, 4, 7, 6 },
    { 4, 0, 3, 7 },
    { 4, 5, 1, 0 },
    { 3, 2, 6, 7 }
  };

  const static GLdouble normal[][3] = {
    { 0.0, 0.0,-1.0 },
    { 1.0, 0.0, 0.0 },
    { 0.0, 0.0, 1.0 },
    {-1.0, 0.0, 0.0 },
    { 0.0,-1.0, 0.0 },
    { 0.0, 1.0, 0.0 }
  };

  const static GLfloat red[] = { 0.8, 0.2, 0.2, 1.0 };

  int i, j;

  /* 材質を設定する */
  glMaterialfv(GL_FRONT, GL_DIFFUSE, red);

  glBegin(GL_QUADS);
  for (j = 0; j < 6; ++j) {
    glNormal3dv(normal[j]);
    for (i = 4; --i >= 0;) {
      glVertex3dv(vertex[face[j][i]]);
    }
  }
  glEnd();
}
Example #19
0
/* ホームベースの描画 */
void base(){
	double base_v[][3] = {
		{ 0.0, 0.6, 18.8 },
		{ -0.3, 0.6, 18.4 },
		{ -0.3, 0.6, 18.0 },
		{ 0.3, 0.6, 18.0 },
		{ 0.3, 0.6, 18.4 }
	};

	glNormal3d(0.0, 1.0, 18.0);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, white);
	glBegin(GL_LINE_LOOP);
	for (int i = 0; i < 5; i++) {
		glVertex3dv(base_v[i]);
	}
	glEnd();
}
   # Dessin du squelette
   ############################################################################################################################ */

void DrawSkelet(void)
{
/* **************************************************************************************************************************** */
	int			 i;
	MDFloat		 tempT[4][4];
	MDFloat		 ZTi[4][4];
	MDFloat		*ptrZTi		 = (MDFloat*)ZTi;
	MDFloat		*ptrtempT	 = (MDFloat*)tempT;
/* **************************************************************************************************************************** */
	MoveToOrigin();
/* **************************************************************************************************************************** */

	glLoadName(_DESIRED_EE_ID_);

	glDisable(GL_LIGHTING);
	glMatrixMode(GL_MODELVIEW);
	glBegin(GL_POINTS);
		glColor3f(1.0f, 1.0f, 0.2f);
		glVertex3dv(PNew);
	glEnd();
	glEnable(GL_LIGHTING);
/* **************************************************************************************************************************** */
	glMatrixMode(GL_MODELVIEW);
/* **************************************************************************************************************************** */
	glPushMatrix();
/* **************************************************************************************************************************** */
	LoadIdentity(ptrZTi);
	for (i=0; i<_NO_OF_LINKS_; i++) {

		Skelet[i].Draw();

		glPopMatrix();
		glPushMatrix();

		MultMatrix4x4((MDFloat(*)[4])Skelet[i].Get_im1Ti(), ZTi, tempT);
		CopyMatrix4x4(ptrtempT, ptrZTi);

		glMultTransposeMatrixd(ptrZTi);
	}
/* **************************************************************************************************************************** */
	DrawEE();
/* **************************************************************************************************************************** */
Example #21
0
void drawSolidShape (double a, double b, double c, double x, double y, double z) {
  GLdouble vertex[][3] = {
    { -a/2.0, -b/2.0, -c/2.0 },
    {  a/2.0, -b/2.0, -c/2.0 },
    {  a/2.0,  b/2.0, -c/2.0 },
    { -a/2.0,  b/2.0, -c/2.0 },
    { -a/2.0, -b/2.0,  c/2.0 },
    {  a/2.0, -b/2.0,  c/2.0 },
    {  a/2.0,  b/2.0,  c/2.0 },
    { -a/2.0,  b/2.0,  c/2.0 }
  };
  int face[][4] = {
    { 3, 2, 1, 0 },
    { 1, 2, 6, 5 },
    { 4, 5, 6, 7 },
    { 0, 4, 7, 3 },
    { 0, 1, 5, 4 },
    { 2, 3, 7, 6 }
  };
  GLdouble normal[][3] = {
    { 0.0, 0.0, -1.0 },
    { 1.0, 0.0, 0.0 },
    { 0.0, 0.0, 1.0 },
    {-1.0, 0.0, 0.0 },
    { 0.0,-1.0, 0.0 },
    { 0.0, 1.0, 0.0 }
  };
  glPushMatrix();
  glMaterialfv(GL_FRONT_AND_BACK,
               GL_SPECULAR, specularcolor);
  glMaterialfv(GL_FRONT_AND_BACK,
               GL_SHININESS, shininess);
  glMaterialfv(GL_FRONT_AND_BACK,
               GL_DIFFUSE, teapotColor);
  glTranslated( x, y, z);
  glBegin(GL_QUADS);
  for (int j = 0; j < 6; ++j) {
    glNormal3dv(normal[j]);
    for (int i = 0; i < 4; ++i) {
      glVertex3dv(vertex[face[j][i]]);
    }
  }
  glEnd();
  glPopMatrix();
}
void ParticleRenderer::_drawPoints(bool color)
{
    if (!m_pbo)
    {
        glBegin(GL_POINTS);
        {
            int k = 0;
            for (int i = 0; i < m_numParticles; ++i)
            {
                if (m_bFp64Positions)
                    glVertex3dv(&m_pos_fp64[k]);
                else
                {
                    glVertex3fv(&m_pos[k]);
                }
                k += 4;
            }
        }
        glEnd();
    }
    else
    {
        glEnableClientState(GL_VERTEX_ARRAY);                
        
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_pbo);
        
        if (m_bFp64Positions)
            glVertexPointer(4, GL_DOUBLE, 0, 0);
        else
            glVertexPointer(4, GL_FLOAT, 0, 0);

        if (color)
        {
            glEnableClientState(GL_COLOR_ARRAY);
            glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboColor);
            //glActiveTexture(GL_TEXTURE1);
            //glTexCoordPointer(4, GL_FLOAT, 0, 0);
            glColorPointer(4, GL_FLOAT, 0, 0);
        }
        glDrawArrays(GL_POINTS, 0, m_numParticles);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
        glDisableClientState(GL_VERTEX_ARRAY); 
        glDisableClientState(GL_COLOR_ARRAY); 
    }
}
Example #23
0
/* ストライクゾーンの描画 */
void zone() {
	double vertices[][3] = { /* ゾーンの座標 */
		{ -0.3, 1.0, 18.0 },
		{ 0.3, 1.0, 18.0 },
		{ 0.3, 1.7, 18.0 },
		{ -0.3, 1.7, 18.0 }
	};

	GLfloat zone_color[] = { 1, 0.1, 0.4, 1 }; /* ゾーンの色 */

	glNormal3f(0.0, 0.0, 1.0);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, zone_color);
	glBegin(GL_LINE_LOOP);
	for (int i = 0; i < 4; i++) {
		glVertex3dv(vertices[i]);
	}
	glEnd();
}
Example #24
0
/*
*  Display the scene
*/
void display()
{
  // Lorenz dat shit
  lorenz();
  //  Clear the image
  glClear(GL_COLOR_BUFFER_BIT);
  //  Reset previous transforms
  glLoadIdentity();
  //  Set view angle
  glRotated(ph,1,0,0);
  glRotated(th,0,1,0);
  int i;
  glBegin(GL_LINE_STRIP);
  for (i=0;i<N;i++)
  {
    glColor3dv(pa[i]);
    glVertex3dv(pa[i]);
  }
  glEnd();
  //  Draw axes in white
  glColor3f(1,1,1);
  glBegin(GL_LINES);
  glVertex3d(0,0,0);
  glVertex3d(1,0,0);
  glVertex3d(0,0,0);
  glVertex3d(0,1,0);
  glVertex3d(0,0,0);
  glVertex3d(0,0,1);
  glEnd();
  //  Label axes
  glRasterPos3d(1,0,0);
  Print("X");
  glRasterPos3d(0,1,0);
  Print("Y");
  glRasterPos3d(0,0,1);
  Print("Z");
  //  Display parameters
  glWindowPos2i(5,5);
  Print("View Angle=%d,%d",th,ph);

  //  Flush and swap
  glFlush();
  glutSwapBuffers();
}
Example #25
0
void mgTLData::draw_texture_image_tri_with_trim(
	const MGBox& image_box,//The image box to draw.
	const mgTLTriangle& triangle,
	const MGBox& trim_box//The trimming box of the triangle.
)const{
	size_t nv=triangle.size();
	if(nv<3) return;

	double w=image_box[0].length().value();//image width.
	double h=image_box[1].length().value();//image height

	MGPosition st_tri[3];
	MGPosition world_tri[3];
	MGPosition base=image_box.low();
	/*std::cout<<" draw_texture_image_tri_with_trim::Base="
		<<base<<std::endl<<", imageBox="<<image_box<<std::endl
		<<", trim_box="<<trim_box<<std::endl;*/
	get_texcoord_world(triangle[0],st_tri[0],world_tri[0],base);
	get_texcoord_world(triangle[1],st_tri[1],world_tri[1],base);

	MGBox trim_box2=trim_box-base;
	for(size_t i=2; i<nv; i++){
		std::vector<MGPosition> st_polygon;
		std::vector<MGPosition> world_polygon;
		get_texcoord_world(triangle[i],st_tri[2],world_tri[2],base);
		int nvertices=trim_triangle(trim_box2,st_tri,world_tri,st_polygon,world_polygon);
		if(nvertices){
			glBegin(GL_POLYGON);
			for(int j=0; j<nvertices; j++){
				//std::cout<<st_polygon[j]<<",";
				glTexCoord2d(st_polygon[j][0]/w,st_polygon[j][1]/h);
				glVertex3dv(world_polygon[j].data());
			}
			//std::cout<<std::endl;
			glEnd();
		}
		if(triangle.getGeometryType()==mgTESTRIANG_STRIP){
			st_tri[0]=st_tri[1];
			world_tri[0]=world_tri[1];
		}
		st_tri[1]=st_tri[2];
		world_tri[1]=world_tri[2];
	}
}
Example #26
0
void PointSet::draw() {
	
	if(coordinate!=NULL) {
		coordinate->follow();
	}

	if(color!=NULL) {
		color->follow();
	}
	
	glPointSize(1);
	
	glDisable(GL_TEXTURE_2D);
		
	glBegin(GL_POINTS);
	for(f=0;f<coordinateNumber;f=f+3) {
		
		if(colorNumber>3) {
			//#ifdef JINX_DOUBLE
				//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, tmpDiffuseColor);   // trocar em oportunidade
				glColor3d(color->value->data[f],color->value->data[f+1],color->value->data[f+2]);
			//#else
			//	glColor3f(color->value->data[f],color->value->data[f+1],color->value->data[f+2]);
			//#endif
		} else
		if(colorNumber==3) { 
			//#ifdef JINX_DOUBLE
				//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, tmpDiffuseColor);   // trocar em oportunidade
				glColor3d(color->value->data[0],color->value->data[1],color->value->data[2]); 
			//#else
			//	glColor3f(color->value->data[0],color->value->data[1],color->value->data[2]); 
			//#endif
		}
		//#ifdef JINX_DOUBLE
			glVertex3dv(&coordinate->value->data[f]);
		//#else
		//	glVertex3fv(&coordinate->value->data[f]);
		//#endif
	}
	glEnd();
		
}
   //******** TRI STRIPS ********
   virtual void faceCB(CBvert* v, CBface* f) {
  
      assert(v && f);
      
	  glNormal3dv(f->norm().data());

	  if (v->has_color()) 
	  {
			GL_COL(v->color(), alpha*v->alpha());
	  }
	   

	 //pass texture coordinates to opengl
	  glTexCoord2dv(att_function->get_attrib(v,f).data());

	  send_d(v,f);
	 
   
      glVertex3dv(v->loc().data());     // vertex coordinates
   }
Example #28
0
void surf3::drawGL( const levelset3 *solid, uint kind ) const {
	for( int i=0; i<faces.size(); i++ ) {
		if( kind == 0 ) glBegin(GL_LINES);
		else glBegin(GL_POLYGON);
		bool clear = true;
		for( int idx=0; idx<3; idx++ ) {
			int face = faces[i][idx];
			if( solid->evalLevelset(vertices[face]) < -0.5*dx ) {
				clear = false;
				break;
			}
		}
		if( clear ) {
			for( int idx=0; idx<3; idx++ ) {
				int face = faces[i][idx];
				glVertex3dv(vertices[face].v);
			}
		}
		glEnd();
	}
}
Example #29
0
LineFieldRenderer::LineFieldRenderer(const Manifold& m, bool smooth, VertexAttributeVector<Vec3d>& lines, float _r):
    SimpleShaderRenderer(vss,fss), r(_r)
{
    float noise_scale = 10.0f/r;
    float line_scale = 0.003f;

    GLint old_prog;
    glGetIntegerv(GL_CURRENT_PROGRAM, &old_prog);
    glUseProgram(prog);
    glUniform1fARB(glGetUniformLocationARB(prog, "scale_line"),line_scale*noise_scale);
    glUniform1fARB(glGetUniformLocationARB(prog, "noise_scale"),noise_scale);
    glUniform1iARB(glGetUniformLocationARB(prog, "noise_tex"),0);
    GLuint direction = glGetAttribLocation(prog, "direction");
    glNewList(display_list,GL_COMPILE);
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f) {
        if(!smooth)
            glNormal3dv(normal(m, *f).get());
        if(no_edges(m, *f) == 3)
            glBegin(GL_TRIANGLES);
        else
            glBegin(GL_POLYGON);

        for(Walker w = m.walker(*f); !w.full_circle(); w = w.circulate_face_ccw()) {
            Vec3d n(normal(m, w.vertex()));
            if(smooth)
                glNormal3dv(n.get());

            Vec3d d = lines[w.vertex()];
            d = normalize(d-n*dot(n,d));
            glVertexAttrib3dv(direction, d.get());
            glVertex3dv(m.pos(w.vertex()).get());
        }
        glEnd();
    }

    glBindTexture(GL_TEXTURE_3D, 0);
    glEndList();
    glUseProgram(old_prog);

}
Example #30
0
ScalarFieldRenderer::ScalarFieldRenderer(const Manifold& m,
        bool smooth,
        VertexAttributeVector<double>& field,
        double max_val, float gamma): SimpleShaderRenderer(vss, fss)
{

    GLint old_prog;
    glGetIntegerv(GL_CURRENT_PROGRAM, &old_prog);
    glUseProgram(prog);

    GLuint scalar_attrib = glGetAttribLocation(prog, "scalar");
    glUniform1fARB(glGetUniformLocationARB(prog, "scalar_max"), max_val);

    //    static float& gamma = CreateCVar("display.scalar_field_renderer.gamma",2.2f);
    glUniform1fARB(glGetUniformLocationARB(prog, "gamma"), gamma);
    glNewList(display_list,GL_COMPILE);

    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f) {
        if(!smooth)
            glNormal3dv(normal(m, *f).get());
        if(no_edges(m, *f)== 3)
            glBegin(GL_TRIANGLES);
        else
            glBegin(GL_POLYGON);


        for(Walker w = m.walker(*f); !w.full_circle(); w = w.circulate_face_ccw()) {
            Vec3d n(normal(m, w.vertex()));
            if(smooth)
                glNormal3dv(n.get());
            glVertexAttrib1d(scalar_attrib, field[w.vertex()]);
            glVertex3dv(m.pos(w.vertex()).get());
        }
        glEnd();
    }
    glEndList();
    glUseProgram(old_prog);

}