[Solved] Computer Graphics- Lab Assignment 7

$25

File Name: Computer_Graphics-_Lab_Assignment_7.zip
File Size: 329.7 KB

SKU: [Solved] Computer Graphics- Lab Assignment 7 Category: Tag:
5/5 - (1 vote)

Computer Graphics, Lab Assignment 7

  1. Start from the following code skeleton.
import glfwfrom OpenGL.GL import * import numpy as np from OpenGL.GLU import *def render():glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glEnable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-2,2, 2,2, 1,1) glMatrixMode(GL_MODELVIEW) glLoadIdentity() drawFrame()t = glfw.get_time() # blue base transformation glPushMatrix() glTranslatef(np.sin(t), 0, 0) # blue base drawing glPushMatrix() glScalef(.2, .2, .2) glColor3ub(0, 0, 255) drawBox() glPopMatrix() # red arm transformation glPushMatrix() glRotatef(t*(180/np.pi), 0, 0, 1)glTranslatef(.5, 0, .01) # red arm drawing glPushMatrix() glScalef(.5, .1, .1) glColor3ub(255, 0, 0) drawBox() glPopMatrix()
glPopMatrix() glPopMatrix()def drawBox():glBegin(GL_QUADS) glVertex3fv(np.array([1,1,0.])) glVertex3fv(np.array([-1,1,0.])) glVertex3fv(np.array([-1,-1,0.])) glVertex3fv(np.array([1,-1,0.])) glEnd()def drawFrame():# draw coordinate: x in red, y in green, z in blue glBegin(GL_LINES) glColor3ub(255, 0, 0) glVertex3fv(np.array([0.,0.,0.])) glVertex3fv(np.array([1.,0.,0.])) glColor3ub(0, 255, 0) glVertex3fv(np.array([0.,0.,0.])) glVertex3fv(np.array([0.,1.,0.])) glColor3ub(0, 0, 255) glVertex3fv(np.array([0.,0.,0])) glVertex3fv(np.array([0.,0.,1.])) glEnd()def main(): if not glfw.init():return window = glfw.create_window(480,480,2017123456-lab6-1, None,None) if not window: glfw.terminate() returnglfw.make_context_current(window) glfw.swap_interval(1)while not glfw.window_should_close(window): glfw.poll_events() render()glfw.swap_buffers(window) glfw.terminate()if __name__ == __main__:main()
  1. Add a green arm at the end of the red arm, and rotate the green arm about its local

z axis.

  1. Render the green arm using drawBox().
  2. Also render local frames of the blue base, red arm, green arm using drawFrame().
  3. Expected result: Uploaded LabAssignment7-1.mp4
  4. Submit a single .py file [studentID]-[assignment#]-[prob#].py
  1. Write down a Python program to draw following triangular pyramid () by using indexed triangles representation and glDrawElements().
  2. Start from the code in 7-Hierarchy,Mesh slides. Make sure camera manipulation shortcuts

1, 3, 2, w work.

  1. Set the window title to [studentID]-[assignment#]-[prob#] and the window size to (480,480).
  2. Submit a single .py file [studentID]-[assignment#]-[prob#].py

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Computer Graphics- Lab Assignment 7
$25