예제 #1
0
void drawObject(){
  shaderProgram->use();
  glBindVertexArray(vao);
  //assignVBOtoAttribute("color", pColors, 4);
  lightsOn();
  mat4 matM1=scale(matM, vec3(2.0,2.0,2.0));
  vecZ=vec3(-globalEngine->X,-globalEngine->Y,-globalEngine->Z);
  matM1=translate(matM1, vecZ);
  vecZ=vec3(0.42,-0.57,0);//globalEngine->X, globalEngine->Y, globalEngine->Z
  matM1=translate(matM1, vecZ);

  glUniformMatrix4fv(shaderProgram->getUniformLocation("P"), 1, false, value_ptr(matP));
  glUniformMatrix4fv(shaderProgram->getUniformLocation("V"), 1, false, value_ptr(matV));
  glUniformMatrix4fv(shaderProgram->getUniformLocation("M"), 1, false, value_ptr(matM1));
 
	//mat4 matV1 = lookAt(vec3(globalCamera->X+globalEngine->X-4, globalCamera->Y+globalEngine->Y+7, -5.0f),
		//	vec3(0.0f, 0.0f, 60.0f), vec3(0.0f, 1.0f, 0.0f));

  //glUniformMatrix4fv(shaderProgram->getUniformLocation("V"), 1, false, value_ptr(matV1));
  drawMesh(loaded);

  matM = rotate(matM, globalEngine->angle, vec3(0, 1, 0));
  matM=scale(matM, vec3(0.08,0.08,0.08));
  //vecZ=vec3(-5,8,0);//globalEngine->X, globalEngine->Y, globalEngine->Z
  //matM=translate(matM, vecZ);

  
  glUniformMatrix4fv(shaderProgram->getUniformLocation("M"), 1, false, value_ptr(matM));
  
  drawMesh(model);

  glBindVertexArray(0);
}
void KinectSkeletonRigger::drawMesh(bool show_original) { 
	if (m_display_mesh.vertices.size() > 0) {
		glColor4f(0.55, 0.25, 0.25, 1.0);
		drawMesh(m_display_mesh, true, Vector3(0,0,0)); 
	}
	if(show_original && m_m.vertices.size() > 0) {
		glColor4f(0.55, 0.55, 0.55, 0.25);
		drawMesh(m_m, true, Vector3(0,0,0)); 
	}
}
예제 #3
0
void drawMeshSet(carve::mesh::MeshSet<3> *poly, float r, float g, float b, float a, int group) {
  if (group >= 0) {
    if ((size_t)group < poly->meshes.size()) {
      drawMesh(poly->meshes[group], r, g, b, a);
    }
  } else {
    for (size_t i = 0; i < poly->meshes.size(); ++i) {
      drawMesh(poly->meshes[i], r, g, b, a);
    }
  }
}
예제 #4
0
void drawPickVMModel(){

	//glDisable(GL_DITHER); //disable blending color function
	glDisable(GL_LIGHT0);
	glDisable(GL_LIGHTING);
	
	glPushMatrix();
	trackRoll();
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glBegin(GL_TRIANGLES);
	for (int i=0; i< getFaceListSize(); i++){

		//binary representative
		//0-255
		if(i < pow(2.0,8.0)){
			glColor3ub(0,0, i);	
		}
		//256-65,535
		else if(i < pow(2.0,16.0)){
			glColor3ub(0, (int)i/256, (i%256)-1 );
		}
		else printf("error: TOO MANY MASH\n");

		drawMesh(i);
		
	}
	glEnd();
	glPopMatrix();

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
}
예제 #5
0
void Object::internalDrawAll(const std::vector<std::shared_ptr<Mesh<glm::vec3>>> &meshes) const
{
    for (auto &it : meshes)
    {
        drawMesh(it);
    }
}
예제 #6
0
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST); // ensures that polygons overlap correctly
    drawMesh(globals.program, globals.meshVAO);
    glutSwapBuffers();
}
예제 #7
0
void draw_fill_model(){

	glPolygonMode(GL_FRONT, GL_FILL);

	glBegin(GL_TRIANGLES);
	for(int j=0; j< getFaceListSize(); j++){
		
		glPushName(j);

		if(sListContain(j) >= 0 || selectedID == j){
			//glColor3f(1, 0, 0);
			setMeshSelection(j);
		}
		else{
			setColorPaint(j);
		}
		
		
		//polygon
		drawMesh(j);
		glPopName();
	}
	
	glEnd();
}
예제 #8
0
파일: mesh.c 프로젝트: FelixDeng/alsaplayer
static void meshscope(Window *win)
{
	Bool configured = FALSE;
	while (running) {
		while (XPending (meshscope_dpy)) {
			XEvent event;

			XNextEvent (meshscope_dpy, &event);
			switch (event.type) {
				case ConfigureNotify:
					glViewport (0, 0, event.xconfigure.width, event.xconfigure.height);
					configured = TRUE;
					break;
				case ButtonPress:
					mousepress(event);
					break;
				case ButtonRelease:
					mouserelease(event);
					break;
				case MotionNotify:
					mousemove(event);
					break;
				default:
					printf("event %x\n", event.type);
					break;
			}
		}
		drawMesh ();
		animate();
		dosleep (25000);
	}
}
예제 #9
0
void sa::MeshRenderer::drawLine(const sa::vec3<float>& p1, const sa::vec3<float>& p2, float width, const sa::vec4<float>& color) {
	sa::Matrix4 model_;
	sa::vec3<float> mid = (p1 + p2) * 0.5f;
	model_.makeTranslationMatrix(mid.x, mid.y, mid.z);
	model_.rotate(::atan((p1.y - p2.y) / (p1.x - p2.x)), 0, 0, 1);
	model_.scale((p1 - p2).length(), width, 1.0f);
	drawMesh(*m_line, model_, "Empty", color);
}
예제 #10
0
void display(Context &ctx)
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable(GL_DEPTH_TEST); // ensures that polygons overlap correctly
    drawMesh(ctx, ctx.program, ctx.meshVAO);
}
예제 #11
0
void drawCube()
{	
	D3DXMATRIX matWorld;
    D3DXMatrixIdentity(&matWorld);
	D3DXMatrixMultiply(&matWorld, &matWorld, &gMatView);	
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    drawMesh(gCube, gCubeMaterial);
}
예제 #12
0
파일: Scene.cpp 프로젝트: shihyuli/stuff
void Scene::drawModel(){
	if(model->skeleton != NULL){
		drawSkel();
	}
	
	if(model->mesh != NULL){
		drawMesh();
	}
}
예제 #13
0
void drawModel(MODEL *psModel, int now, int selectedMesh)
{
	int i;

	assert(psModel && psModel->mesh);

	// Update animation frames
	for (i = 0; i < psModel->meshes; i++)
	{
		MESH *psMesh = &psModel->mesh[i];
		FRAME *psFrame;

		if (!psMesh->frameArray)
		{
			continue;
		}
		psFrame = &psMesh->frameArray[psMesh->currentFrame];

		assert(psMesh->currentFrame < psMesh->frames && psMesh->currentFrame >= 0);
		if (psFrame->timeSlice != 0 && psFrame->timeSlice * 1000 + psMesh->lastChange < now)
		{
			psMesh->lastChange = now;
			psMesh->currentFrame++;
			if (psMesh->currentFrame >= psMesh->frames)
			{
				psMesh->currentFrame = 0;	// loop
			}
		}
	}

	// Draw model
	glColor3f(1.0f, 1.0f, 1.0f);
	if (selectedMesh >= 0 && selectedMesh < psModel->meshes)
	{
		drawMesh(psModel, now, selectedMesh);
	}
	else
	{
		for (i = 0; i < psModel->meshes; i++)
		{
			drawMesh(psModel, now, i);
		}
	}
}
예제 #14
0
void display(void){
    int i;
    float t;
    Xyz p;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_COLOR_MATERIAL);
    glLoadIdentity();

    glRotated(g_x_angle, 1.0f, 0.0f, 0.0f);
    glRotated(g_y_angle, 0.0f, 1.0f, 0.0f);
    glScalef(g_scale, g_scale, g_scale);
    glTranslatef(g_x_pan, -g_y_pan, 0);


    glColor3f(0, 0, 0);


    if(g_display_points == 1){
        glPointSize(4);
        glBegin(GL_POINTS);
        for(i = 0; i < g_npoint; ++i){
            glVertex3fv(&movePath[i].p.x);
        }
        glEnd();
    }

    t = current_time();


    if(g_movePathType == 0){
        if(g_displaymovePath == 1){
            glBegin(GL_LINE_STRIP);
            for(i = 0; i < g_npoint; ++i){
                glVertex3fv(&movePath[i].p.x);
            }
            glEnd();
        }
        linearPoint(t, &p.x, &p.y, &p.z);
    }
    if(g_movePathType == 1){
        if( g_displaymovePath == 1)
            drawCurve(1000);
        splinePoint(t, &p.x, &p.y, &p.z);
    }
    glTranslatef(p.x, p.y, p.z);

    glScaled(.3, .3, .3);
    glColor3f(1, 0, 1);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    drawMesh();

//    g_npoint = 0;
    glutSwapBuffers();

}
예제 #15
0
//--------------------------------------------------------------
void testApp::draw()
{
	ofBackground(24);

	ofSetColor(255);
	kinect.drawDepth(ofRectangle(10,10,DEPTH_WIDTH, DEPTH_HEIGHT));
	kinect.drawBodyIndex(10, DEPTH_HEIGHT + 20);
	
	drawMesh();
}
예제 #16
0
파일: part2.cpp 프로젝트: isqb/graphics
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_DEPTH_TEST);
	//drawSkyBox(globals.program_sky_box);
	drawMesh(globals.program, globals.meshVAO);
	TwDraw();  // draw the tweak bar(s)
	glutSwapBuffers();
}
예제 #17
0
파일: MeshWarpWidget.cpp 프로젝트: jcxz/ZPO
void MeshWarpWidget::paintEvent(QPaintEvent *event)
{
  m_transform = QTransform(m_scale, 0.0f, 0.0f, m_scale,
                           (width() - m_img.width()) * 0.5f + m_offset_x,
                           (height() - m_img.height()) * 0.5f + m_offset_y);

  QPainter painter(this);

  /*
   * The following 3 lines of code should enable Qt stylesheets for this widget
   * this code was inspired by qt's documentation.
   * see: http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-reference.html
   */
  //QStyleOption opt;
  //opt.init(this);
  //style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

  painter.fillRect(0, 0, width(), height(), QColor(0x20, 0x1F, 0x1F));

  painter.setTransform(m_transform);
  painter.drawImage(0, 0, m_img);

  //drawMesh(painter);

  painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
  //painter.setCompositionMode(QPainter::RasterOp_SourceAndNotDestination);
  //painter.setCompositionMode(QPainter::CompositionMode_Xor);
  //painter.setCompositionMode(QPainter::CompositionMode_Lighten);
  //painter.setCompositionMode(QPainter::CompositionMode_Darken);
  //painter.setCompositionMode(QPainter::CompositionMode_ColorDodge);
  //painter.setCompositionMode(QPainter::CompositionMode_ColorBurn);
  //painter.setCompositionMode(QPainter::CompositionMode_Difference);
  //painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
  //painter.setCompositionMode(QPainter::CompositionMode_Screen);
  //painter.setCompositionMode(QPainter::CompositionMode_Overlay);
  //painter.setCompositionMode(QPainter::CompositionMode_Multiply);

  painter.drawImage(-(CONTROL_POINT_SIZE / 2), -(CONTROL_POINT_SIZE / 2), drawMesh());

  if (m_has_active_cp)
  {
    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);

    QPen pen;
    pen.setWidth(CONTROL_POINT_SIZE);
    pen.setColor(QColor(255, 153, 0, 255));
    //pen.setColor(QColor(185, 103, 0, 255));
    painter.setPen(pen);
    const Point p = m_mesh(m_active_cp_x, m_active_cp_y);
    painter.drawEllipse(p.x - (CONTROL_POINT_SIZE / 2), p.y - (CONTROL_POINT_SIZE / 2),
                        CONTROL_POINT_SIZE, CONTROL_POINT_SIZE);
  }

  return QWidget::paintEvent(event);
}
예제 #18
0
void drawModel(const Model& mdl)
{
    // setup world-view matrix
    auto modelView = (viewMatrix * mdl.transform.GetMatrix()).ToMatrix4();
    glLoadMatrix_T(modelView.Ptr());

    #ifdef TEST_MESH_CLIPPING

    Gm::Plane clipPlane(
        Gs::Vector3(1, 0, 0).Normalized(),
        -0.3f
    );
    clipPlane = Gm::TransformPlane(modelView.Inverse(), clipPlane);

    Gm::TriangleMesh front, back;
    Gm::MeshModifier::ClipMesh(mdl.mesh, clipPlane, front, back);

    drawMesh(front, wireframeMode);

    #ifdef TEST_SHOW_SPLIT
    auto trans2 = mdl.transform;
    trans2.MoveGlobal({ -0.1f, 0, 0 });
    modelView = (viewMatrix * trans2.GetMatrix()).ToMatrix4();
    glLoadMatrix_T(modelView.Ptr());
    #endif

    drawMesh(back, wireframeMode);

    #else

    // draw model
    drawMesh(mdl.mesh, wireframeMode);

    #endif

    #ifdef TEST_SHOW_EDGES

    // draw edges
    drawMeshEdges(mdl.mesh);

    #endif
}
예제 #19
0
파일: voxels.c 프로젝트: kyle1320/voxels
void drawWorld(World *world, mat4 viewMatrix, mat4 projectionMatrix) {
    int i;
    Chunk *chunk;

    for (i = 0; i < world->num_chunks; i++) {
        chunk = world->chunks[i];
        if (chunk->mesh->size != 0 && isVisible(chunk, viewMatrix, projectionMatrix)) {
            drawMesh(chunk->mesh);
        }
    }
}
예제 #20
0
void MeshPainter::i_paintModel3d(Viewport3dSettings *viewportSettings, GSProductModel *model, PaintLayer layer, bool root, bool background, int reflectionCount)
{
	ModelPainter::i_paintModel3d( viewportSettings, model, layer, root, background, reflectionCount );


	if ( model != NULL )
	{
		gs_assert_is_instance_of( model, GSProductMesh, "MeshPainter::i_paintModel3d()" );

		drawMesh( viewportSettings, static_cast<GSProductMesh*>( model ), layer, background, reflectionCount );
	}
}
예제 #21
0
void drawModel(const Model& mdl)
{
    // setup world-view matrix
    auto modelView = (viewMatrix * mdl.transform.GetMatrix()).ToMatrix4();
    glLoadMatrixf(modelView.Ptr());

    // draw model
    drawMesh(mdl.mesh, wireframeMode);
    drawMeshNormals(mdl.mesh, showFaceNormals, showVertNormals);
    if (showTagentSpace)
        drawMeshTangents(mdl.mesh, mdl.tangents[0], mdl.tangents[1]);
}
예제 #22
0
void display(Context &ctx)
{
    glClearColor(ctx.background_color[0], ctx.background_color[1], ctx.background_color[2], 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glDisable(GL_DEPTH_TEST);
	glDepthMask(GL_FALSE);
	drawSkybox(ctx);
	glDepthMask(GL_TRUE);

    glEnable(GL_DEPTH_TEST); // ensures that polygons overlap correctly
    drawMesh(ctx, ctx.program, ctx.meshVAO);
}
예제 #23
0
GLuint OpenGLRenderInterface::compileList(const Eigen::Vector3d& _scale, const aiScene* _mesh) {
    if(!_mesh)
        return 0;

    // Generate one list
    GLuint index = glGenLists(1);
    // Compile list
    glNewList(index, GL_COMPILE);
    drawMesh(_scale, _mesh);
    glEndList();

    return index;
}
예제 #24
0
void HalfEdgeWidget::paintEvent(QPaintEvent *event)
{
    if(m_edge != nullptr)
    {
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing);

        QSet<Face*>* mySet = new QSet<Face*>;
        drawMesh(mySet, m_edge, painter);
        mySet->clear();
        delete mySet;
    }
}
예제 #25
0
void drawNode(Blitz3DNODEChunk* node) {
    unsigned int iter;

    /* commentary: still need to apply matrix transforms per node */

    if (getMESHChunkFromNODEChunk(node) != NULL) {
        drawMesh( getMESHChunkFromNODEChunk(node) );
    }

    for (iter = 0; iter < getNODEChunkArrayCountFromNodeChunk(node); iter++) {
        drawNode( getNODEChunkArrayEntryFromNODEChunk(node, iter) );
    }
}
예제 #26
0
파일: MyWindow.cpp 프로젝트: DengzhiLiu/CG
void MyWindow::drawFloor()
{
    int i;
    Mesh floor;
    floor.vertices.resize(4);
    for(i = 0; i < 4; ++i) {
        floor.vertices[i].normal = Vector3(0, 1, 0);
        floor.vertices[i].pos = 10. * Vector3(((i + 0) % 4) / 2, 0, ((i + 1) % 4) / 2) - Vector3(4.5, 0, 4.5);
    }
    floor.edges.resize(6);
    for(i = 0; i < 6; ++i)
        floor.edges[i].vertex = (i % 3) + ((i > 3) ? 1 : 0);

    static GLfloat colrb[4] = {0.5f, .9f, .75f, 1.0f };
    static GLfloat colr[4] = {0.5f, .6f, .9f, 1.0f };
    glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colr);
    glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, colrb);

    glShadeModel(GL_SMOOTH);
	bool drawb = drawTri;
	drawTri = true;
    drawMesh(floor, false);
	drawTri = drawb;
    glShadeModel( flatShading ? GL_FLAT : GL_SMOOTH);

    glColor4d(.5, .6, .9, .3);
    glLineWidth(1.);
    int gridSize = 20;
    double y = floor.vertices[0].pos[1];
    double minX = floor.vertices[1].pos[0];
    double maxX = floor.vertices[2].pos[0];
    double minZ = floor.vertices[1].pos[2];
    double maxZ = floor.vertices[3].pos[2];
    double stepX = (maxX - minX) / double(gridSize);
    double stepZ = (maxZ - minZ) / double(gridSize);
    glEnable(GL_BLEND);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glBegin(GL_LINES);
    for(i = 0; i <= gridSize; ++i) {
        glVertex3d(minX + i * stepX, y, minZ);
        glVertex3d(minX + i * stepX, y, maxZ);
        glVertex3d(minX, y, minZ + i * stepZ);
        glVertex3d(maxX, y, minZ + i * stepZ);
    }
    glEnd();
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
}
void Renderer::draw()
{
  if (!mMesh)
    return; // nothing to do

  if (mOutputContour)
    drawContourData(mOutputContour);

  if (mCfg.mesh.mRenderMesh)
    drawMesh();

  if (mOutputVector && mOutputVector->dataSet->type() == DataSet::Vector)
    drawVectorData(mOutputVector);
}
예제 #28
0
void drawFrame()
{
	u32 i, color = 0;
	Matrix4 viewMatrix,modelViewMatrix;

	//clear screen
	rsxSetClearColor(context, color);
	//rsxSetClearDepthValue(context,0xffff);
	rsxClearSurface(context,GCM_CLEAR_R |
							GCM_CLEAR_G |
							GCM_CLEAR_B |
							GCM_CLEAR_A  //|
							//GCM_CLEAR_S |
							//GCM_CLEAR_Z
							);


	for (i = 0; i < 8; i++) {
		rsxSetViewportClip(context, i, display_width, display_height);
	}

	viewMatrix = Matrix4::lookAt(eye_pos, eye_dir, up_vec);

	//draw background image
	modelViewMatrix = transpose(viewMatrix * modelMatrix);
	setDrawEnv(0);
	setTexture(textureW, textureH, texture_buffer, texture_offset);
	drawMesh(quad, &modelViewMatrix, (float*)&scanline);

	if (showUi) {
		//draw UI
		modelViewMatrix = transpose(viewMatrix * modelMatrixUi);
		setDrawEnv(1);
		setTexture(textureW_ui, textureH_ui, texture_buffer_ui, texture_offset_ui);
		drawMesh(quad_ui, &modelViewMatrix, (float*)&scanlineUi);
	}
}
예제 #29
0
void ofxGuiInputField<Type>::render(){
	ofxGuiElement::render();

	if(hasFocus){
		drawFocusedBB();

		if(hasSelectedText()){
			drawSelectedArea();
		}else{
			drawCursor();
		}
	}

	drawMesh();
}
예제 #30
0
void HalfEdgeWidget::drawMesh(QSet<Face*>* set, HalfEdge* edge, QPainter& painter)
{
    HalfEdge* auxEdge = edge;
    //int i = 0;

    if(auxEdge == nullptr)
        return;

    //qDebug() << "Minha face: " << auxEdge->face;

    //insere no conjunto a face caso já não exista
    set->insert(auxEdge->face);

    do
    {
        //qDebug() << "Iterations: " << i++;

        if(auxEdge->vertex != nullptr)
        {
            painter.setPen(QPen(Qt::red, 8, Qt::SolidLine, Qt::RoundCap));
            painter.drawPoint(auxEdge->vertex->point.x, auxEdge->vertex->point.y);

            if((auxEdge->next != nullptr)&& (auxEdge->next->vertex != nullptr))
            {
                Point point1 = auxEdge->vertex->point;
                Point point2 = auxEdge->next->vertex->point;
                painter.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap));
                painter.drawLine(point1.x, point1.y, point2.x, point2.y);
            }
        }
        if(auxEdge->twin != nullptr)
        {
            //qDebug() << "Achei meu twin";
            if(!set->contains(auxEdge->twin->face))
            {
                //qDebug() << "Nunca vi essa face";
                 drawMesh(set, auxEdge->twin, painter);
            }
            //else
                //qDebug() << "Ja visitei esse jovem";
        }

        auxEdge = auxEdge->next;

    } while((auxEdge != nullptr) && (auxEdge != edge));

    //qDebug() << *set;
}