void Scene::draw() { GLfloat m[4][4]; recalcModelView(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (showAxis) { drawRotationAxis(); } if (modelsMode) { glScalef(6, 6, 6); for (unsigned i=0; i < models.size(); i++) { models[i]->render(); } } else { if (game) { drawObject(vertexes, exluded); drawExcluded(); } else { drawObject(vertexes, -1); } if (skeleton) { drawSkeleton(); } } glutSwapBuffers(); }
void Scene::draw(sf::RenderTarget &target, sf::RenderStates states) const { if (player) { drawObject(*player, target, states); } for(const auto &object : m_objects) drawObject(object, target, states); }
void renderGame() { drawBackground(bgX, bgY, bgClip); drawObject(&player, player.clip); if(someObject != NULL) { drawObject(someObject, someObject->clip); } writeText(0, 0, "r37r0 v0.0"); if(msgTime>0) writeText((SCREENW>>1)-(TILEW*SDL_strlen(message)>>1), SCREENH-TILEH, message); }
void GL42Renderer::drawScene(Scene& scene) { for (auto& i : scene.objects) { drawObject(i); } for (Entity *entity : scene.entities) { drawObject(&(entity->renderObject())); } //glfwSwapBuffers(); }
void rotateRow( int x, int y, int z, int v, int s) { // rotate all objects matching x, y, z mask with value v // s verse of rotation int j, i, ix, iy, iz; // animation loop 0-90 deg for(j = 0; j <= 90; j+= STEP) { // clear painting scren gClearScreen(); // clear the hidden screen // search all objects for matching pattern for( iz=0; iz<3; iz++) for( iy=0; iy<3; iy++) for(ix=0; ix<3; ix++) { if ( ix*iy*iz == 1) continue; // ignore c[1][1][1] i = c[ix][iy][iz]; // check if requires rotation if (( (ix+1)*x == v+1) || ((iy+1)*y == v+1) || ((iz+1)*z == v+1)) { // rotate the corresponding axis // transform and draw the object initMatrix( mo, x*s*j, y*s*j, z*s*j, 0, 0, 0); drawObject( mo, i); // if final rotation if ( j == 90) rotateObject( mo, i); } else { // transform and draw the object initMatrix( mo, 0, 0, 0, 0, 0, 0); drawObject( mo, i); } } // update visible screen copyV(); } // for j steps // update pointer matrix c[][][] rotateC( x, y, z, v, s); } // animate rotation of one row/face
void display (void) { glClearDepth (1); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(120.0, 20.0, 140.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0); float pos[]={10.0,90.0,-110.0,1.0}; //set the position glLightfv(GL_LIGHT0,GL_POSITION,pos); glEnable(GL_COLOR_MATERIAL); camera(); glPushMatrix(); glTranslatef(0, -30, 0); //glScalef(10,10,10); //glCallList(cube); glPopMatrix(); drawGrid(); //createHabitat(); drawWalls(); drawHabitat(); drawFood(); drawObject(); drawPredator(); //saveToDisk(); glutSwapBuffers(); }
void App::drawFrame() { mat4 projection = perspectiveMatrixX(1.5f, width, height, 0.001f, 1.0f); mat4 mvRotate = rotateXY(-wx, -wy); mat4 modelview = mvRotate * translate(-camPos); glMatrixMode(GL_PROJECTION); glLoadTransposeMatrixf(projection); glMatrixMode(GL_MODELVIEW); glLoadTransposeMatrixf(modelview); // Determine the shader selections radialSelect = 0; if(doRadialEnvMap->isChecked()) { radialSelect = 1; } constMipSelect = 0; if(constantMipLevel->isChecked()) { constMipSelect = 1; } // Clear only depth renderer->clear(false, true, false); // Draw the background environment drawEnvironment(projection * mvRotate); // Draw the object drawObject(); }
void DrawFlashlight() { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex2); glm::vec3 dir = m_center - m_eye; matM = glm::translate(glm::mat4(1.0f), m_eye+dir); glm::vec4 temp; temp = glm::rotate(glm::mat4(1.0f), angleLR, m_up) * glm::vec4 (m_eye+dir,0);// *glm::vec4(m_center - m_eye, 0); glm::vec4 temp2; glm::vec3 look = glm::normalize(m_center - m_eye); glm::vec3 vert_rot = glm::cross(m_up, look); temp2 = glm::rotate(glm::mat4(1.0f), rely*mouse_speed, vert_rot)*glm::vec4(m_center - m_eye, 0); m_center = m_eye + glm::vec3(temp2); angleUD += rely*mouse_speed; if (angleUD > 360)angleUD -= 360; if (angleUD < -360)angleUD += 360; //matM = glm::scale(matM, glm::vec3(1.0, 1.0, 1.0)); drawObject(); }
void cScene::render() { // Draw model if (data->front == 1) { for (int i = 0; i < (int)map.size(); i++) { int k = (int)map.size() - 1 - i; for (int j = 0; j <= i; j++) { drawTile(j, k); if (objmap[j][k] != 0) drawObject(j, k); k++; } } for (int i = 1; i < (int)map.size(); i++) { int k = 0; for (int j = i; j < (int)map.size(); j++) { drawTile(j, k); if (objmap[j][k] != 0) drawObject(j, k); k++; } } } else { for (int i = 0; i < (int)map.size(); i++) { int j = (int)map.size() - 1; for (int k = i; k >= 0; k--) { drawTile(j, k); if (objmap[j][k] != 0) drawObject(j, k); j--; } } for (int i = 1; i < (int)map.size(); i++) { int k = (int)map.size() - 1; for (int j = (int)map.size() - 1 - i; j >= 0; j--) { drawTile(j, k); if (objmap[j][k] != 0) drawObject(j, k); k--; } } } if (DEBUG_MODE) { drawHighlightTile((int)playerx,-(int)playerz); drawHighlightTile((int)playerx +1,-(int)playerz); drawHighlightTile((int)playerx,-(int)playerz +1); drawHighlightTile((int)playerx +1,-(int)playerz +1); } }
void Renderer::drawBackground(const std::string& name) { SDL_RenderClear(sRenderer); loadTexture(name); const ObjRenderable background {name, 0, 0, 0, 0, SCREEN_HEIGHT, SCREEN_WIDTH}; drawObject(background); }
void drawIronman() { glColor3f(0.7, 0.7, 0.3); glPushMatrix(); glTranslatef(0.0, 0.0, 0.0); glScalef(1.0, 1.0, 1.0); drawObject(&ironman); glPopMatrix(); }
//------------------------------------------------------------------------- // This function is passed to glutDisplayFunc in order to display // OpenGL contents on the window. //------------------------------------------------------------------------- void display (void) { glClear (GL_COLOR_BUFFER_BIT); drawObject(); drawFPS(); glutSwapBuffers (); }
void Rasterization::drawScene(SceneRenderer * sceneRenderer, Zone & renderingZone) { CameraScreen * cameraScreen = sceneRenderer->getCameraScreen(); Screen * screen = cameraScreen->getScreen(); this->zbuffer = new ZBuffer(screen->getWidth(), screen->getHeight()); std::vector<Object3D *> objects = sceneRenderer->getScene()->getObjects3D(); for(std::vector<Object3D *>::iterator it = objects.begin(); it != objects.end(); it++) { drawObject(sceneRenderer->getObject3DRenderer(*it), renderingZone); } delete zbuffer; }
void ImageWidget::paintEvent(QPaintEvent *event) { QWidget::paintEvent(event); QPainter painter(this); painter.drawImage(QPoint(0, 0), image); foreach (const QRect &object, curObjects) { drawObject(painter, (zoomSet ? Util::scaleRect(object, zoomFactor) : object)); }
void Render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3d(7,7,7); drawObject(Object_1); glutSwapBuffers(); glutPostRedisplay(); }
void CCubeZoom::renderChild(int nDepth) { if (nDepth > 3) return; if ( (m_vCubes[nDepth].m_fScale >= fCUBE_RING_START) && (nDepth < nMAX_CUBE_DEPTH - 1) ) { glPushMatrix(); renderChild(nDepth + 1); glNewList(m_glDispStartIndex + nDepth, GL_COMPILE); // Render the center object drawObject(nDepth); // Render the orbiting objects for (int nChild = 0; nChild < nCUBE_CHILDREN; nChild++) { glPushMatrix(); glRotatef(fROTATE_ANGLE * nChild, 0.0f, 1.0f, 0.0f); glTranslatef(0.0f, 0.0f, -4.5f); glCallList(m_glDispStartIndex + nDepth + 1); glPopMatrix(); } glEndList(); glPopMatrix(); } else { glNewList(m_glDispStartIndex + nDepth, GL_COMPILE); drawObject(nDepth); glEndList(); #ifdef _DEBUG m_nDepth = nDepth; #endif // _DEBUG } glColor3f(1.0f, 1.0f, 1.0f); }
void Model::drawModel(void) { if(!objectLoaded) return; if(displayList != 0) { glCallList(displayList); return; } displayList = glGenLists(1); glNewList(displayList, GL_COMPILE); drawObject(false); drawObject(true); glEndList(); }
/*-------------------------------------------------------------------------------- Function : Display::drawLevelItems Description : Draws the Items found in the given level. This function is called after the Level's map has been drawn in the drawPlayfield() function. Inputs : Level object Outputs : None Return : void --------------------------------------------------------------------------------*/ void Display::drawLevelItems(const LevelPtr level) { vector<ItemPtr> items = level->getItems(); vector<ItemPtr>::const_iterator it, end; it = items.begin(); end = items.end(); for(; it!=end; ++it) { drawObject(*it); } }
/*------------------------------------------------------------*/ void drawCurrent( void ) { #if defined(SHOW_TEXT_STEPS) printf( "Drawing the current item.\n"); #endif // Draw a point so that the user may edit the object. drawObject( current ); drawPoint( current->x0, current->y0 ); drawPoint( current->x1, current->y1 ); }
void trackFilteredObject(Object theObject,Mat threshold,Mat HSV, Mat &cameraFeed) { vector <Object> objects; Mat temp; threshold.copyTo(temp); //these two vectors needed for output of findContours vector< vector<Point> > contours; vector<Vec4i> hierarchy; //find contours of filtered image using openCV findContours function findContours(temp,contours,hierarchy,CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE ); //use moments method to find our filtered object bool objectFound = false; if (hierarchy.size() > 0) { int numObjects = hierarchy.size(); //if number of objects greater than MAX_NUM_OBJECTS we have a noisy filter if(numObjects<MAX_NUM_OBJECTS){ for (int index = 0; index >= 0; index = hierarchy[index][0]) { Moments moment = moments((cv::Mat)contours[index]); double area = moment.m00; //if the area is less than 20 px by 20px then it is probably just noise //if the area is the same as the 3/2 of the image size, probably just a bad filter //we only want the object with the largest area so we safe a reference area each //iteration and compare it to the area in the next iteration. if(area>MIN_OBJECT_AREA) { Object object; object.setXPos(moment.m10/area); object.setYPos(moment.m01/area); object.setType(theObject.getType()); object.setColor(theObject.getColor()); objects.push_back(object); objectFound = true; }else objectFound = false; } //let user know you found an object if(objectFound ==true) { //draw object location on screen drawObject(objects,cameraFeed,temp,contours,hierarchy); } } else putText(cameraFeed,"TOO MUCH NOISE! ADJUST FILTER",Point(0,50),1,2,Scalar(0,0,255),2); } }
void drawEnemySet(LEVEL level) { unsigned int i = 0; for (i = 0; i < level.enemyNumber; i++) { if ((level.enemyset+i)->visible) { drawObject(level.enemyset+i); } else if ((level.enemyset+i)->explosion_delay) { drawExplosion(level.enemyset+i); } } }
// Fonction executer void display(void) { // Clear the window or more specifically the frame buffer... // This happens by replacing all the contents of the frame // buffer by the clear color (black in our case) glClear(GL_COLOR_BUFFER_BIT); // Draw object glOrtho(-9, 9, -5, 5, -10, 10); drawObject(); // Swap contents of backward and forward frame buffers glutSwapBuffers(); }
/**************************************************************************//** * @author Daniel Andrus, Johnny Ackerman * * @par Description: * Constructor - initilizes data, and creates a window from information * * @param[in] x - left coordinate of window * @param[in] y - bottom coordinate of window * @param[in] w - width of window * @param[in] h - height of window *****************************************************************************/ GeneratorView::GeneratorView(double x, double y, double w, double h) : View(x, y, w, h), endx(0), endy(0), leftButton(false), clear_button("Clear Generator", Fractals::button_x, Fractals::button_y, Fractals::button_w * 2, Fractals::button_h) { // Initialize button with its action clear_button.setAction([](){ Fractals::getInstance()->generatorView->generator.clear(); Fractals::getInstance()->generatorView->draw(); glFlush(); }); drawObject(&clear_button); }
void OtherScene::renderScene(Camera3D * camera) { glEnable(GL_DEPTH_TEST); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Matrix4 cameraInverse = camera->getTransformation().Inverse(); Vector3 lightPosInCamera = cameraInverse * mSun.origin(); mDiffuseShader.bind(); mDiffuseShader.setMatrix4x4Uniform("worldcamera", cameraInverse); mDiffuseShader.setMatrix4x4Uniform("projection", camera->getProjectionMatrix()); mDiffuseShader.setMatrix3x3Uniform("worldcameraNormal", camera->getTransformation().Transpose()); mDiffuseShader.setVector3Uniform("lightposition", lightPosInCamera.x, lightPosInCamera.y, lightPosInCamera.z ); mDiffuseShader.setVector4Uniform("lightcolor", mLightColor.x, mLightColor.y, mLightColor.z, 1.0); // Draw mesh drawObject(mDiffuseShader, mCube, true, true); for (int i = 0; i < PILLAR_COUNT; i++) { mPillar.setTransformation(mPillarMatrices[i]); drawObject(mDiffuseShader, mPillar, false, true); } mDiffuseShader.unbind(); mSimpleShader.bind(); mSimpleShader.setMatrix4x4Uniform("worldcamera", cameraInverse); mSimpleShader.setMatrix4x4Uniform("projection", camera->getProjectionMatrix()); drawObject(mSimpleShader, mSun, true, false); drawObject(mSimpleShader, mStars, true, false); mSimpleShader.unbind(); }
//-------------------------------------------------------------- void box2dScene::draw(){ drawObject(); for (int l = 0; l < forces.size(); l++) { if (l<forceNum) { if (drawforce) { forces[l].draw(); } } } }
void SimObject::draw(const VisualizationParameterSet& visParams, bool skipFirstChild) { //Draw the object itself: drawObject(visParams); //Check for controller drawings connected to this object: drawControllerDrawings(visParams); //Draw child nodes: ObjectList::const_iterator pos = childNodes.begin(); for(pos != childNodes.end() && skipFirstChild ? pos++ : pos; pos != childNodes.end(); ++pos) { (*pos)->draw(visParams); } }
// track the filtered object void TrackerPoint::trackFilteredObject(int &x, int &y, cv::Mat threshold, cv::Mat &cameraFeed){ cv::Mat temp; threshold.copyTo(temp); //these two vectors needed for output of findContours vector<vector<cv::Point>> contours; vector<cv::Vec4i> hierarchy; //find contours of filtered image using openCV findContours function findContours(temp, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE); //use moments method to find our filtered object double refArea = 0; bool objectFound = false; if (hierarchy.size() > 0) { int numObjects = hierarchy.size(); //if number of objects greater than MAX_NUM_OBJECTS we have a noisy filter if (numObjects<MAX_NUM_OBJECTS){ for (int index = 0; index >= 0; index = hierarchy[index][0]) { cv::Moments moment = moments((cv::Mat)contours[index]); double area = moment.m00; //if the area is less than 20 px by 20px then it is probably just noise //if the area is the same as the 3/2 of the image size, probably just a bad filter //we only want the object with the largest area so we safe a reference area each //iteration and compare it to the area in the next iteration. if (area>MIN_OBJECT_AREA && area<MAX_OBJECT_AREA && area>refArea){ x = moment.m10 / area; y = moment.m01 / area; objectFound = true; refArea = area; } else objectFound = false; } //let user know you found an object if (objectFound == true){ putText(cameraFeed, "Tracking Object", cv::Point(0, 50), 2, 1, cv::Scalar(0, 255, 0), 2); //draw object location on screen drawObject(x, y, cameraFeed); } } else putText(cameraFeed, "TOO MUCH NOISE! ADJUST FILTER", cv::Point(0, 50), 1, 2, cv::Scalar(0, 0, 255), 2); } }
void DrawWalls(int layer){ glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex0); for (int i = 0; i < maze_size; i++) for (int j = 0; j < maze_size; j++) if (M[i][j] == '#') for (int kx = 0; kx < 2; kx++) for (int kz = 0; kz < 2; kz++) { matM = glm::translate(glm::mat4(1.0f), glm::vec3(4.0f*i + kx*2.0f, layer*4.0f, 4.0f*j + kz*2.0f)); drawObject(); } }
void trackFilteredObject(Sample TheSample,Mat threshold,Mat HSV, Mat &cameraFeed){ vector <Sample> BlueRocks; Mat temp; threshold.copyTo(temp); //these two vectors needed for output of findContours vector< vector<Point> > contours; vector<Vec4i> hierarchy; //find contours of filtered image using openCV findContours function findContours(temp,contours,hierarchy,CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE ); //use moments method to find our filtered object double refArea = 0; bool objectFound = false; if (hierarchy.size() > 0) { int numObjects = hierarchy.size(); //if number of objects greater than MAX_NUM_OBJECTS we have a noisy filter if(numObjects<MAX_NUM_OBJECTS){ for (int index = 0; index >= 0; index = hierarchy[index][0]) { Moments moment = moments((cv::Mat)contours[index]); int area = moment.m00; //if the area is less than 20 px by 20px then it is probably just noise if((area>MIN_OBJECT_AREA) && (area<MAX_OBJECT_AREA)){ Sample BlueRock; BlueRock.setxPos( moment.m10/area ); BlueRock.setyPos( moment.m01/area ); BlueRock.setarea( moment.m00 ); BlueRock.setType(TheSample.getType()); BlueRock.setColor(TheSample.getColor()); BlueRocks.push_back(BlueRock); objectFound = true; }else objectFound = false; } //let user know you found an object if(objectFound ==true){ //draw object location on screen drawObject(BlueRocks,cameraFeed);} }else putText(cameraFeed,"TOO MUCH NOISE! ADJUST FILTER",Point(0,50),1,2,Scalar(0,0,255),2); } }
void drawScene(int pass) { /* The 0.03 in the Y column is just to shift the texture coordinates a little based on Y (depth in the water) so that vertical faces (like on the cube) do not get totally vertical caustics. */ GLfloat sPlane[4] = { 0.05, 0.03, 0.0, 0.0 }; GLfloat tPlane[4] = { 0.0, 0.03, 0.05, 0.0 }; /* The causticScale determines how large the caustic "ripples" will be. See the "Increate/Decrease ripple size" menu options. */ sPlane[0] = 0.05 * causticScale; sPlane[1] = 0.03 * causticScale; tPlane[1] = 0.03 * causticScale; tPlane[2] = 0.05 * causticScale; if (pass == PASS_CAUSTIC) { /* Set current color to "white" and disable lighting to emulate OpenGL 1.1's GL_REPLACE texture environment. */ glColor3f(1.0, 1.0, 1.0); glDisable(GL_LIGHTING); /* Generate the S & T coordinates for the caustic textures from the object coordinates. */ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, sPlane); glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); if (HaveTexObj) { glBindTexture(GL_TEXTURE_2D, currentCaustic+1); } else { glCallList(currentCaustic+101); } } drawFloor(pass); drawObject(pass); if (pass == PASS_CAUSTIC) { glEnable(GL_LIGHTING); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } }