hi, Can someone help me with computer graphics course assignment I currently tak
ID: 3667392 • Letter: H
Question
hi,
Can someone help me with computer graphics course assignment I currently taking?? I have been working on this assignment for some days now and I can't seem to get it right, it would be helpfull to see an alternative way of apporaching this problem? CAN you help me with it but please comment along the way. THANK YOU.
A stationary 3D scene is interesting, and much effort has been spent producing as accurate a scene as possible using various rendering techniques. However, the applications of a single-frame render are somewhat limited. In this assignment, we are going to introduce motion and interactivity to our scene. Using C++, OpenGL, and Microsoft Visual Studio, create a program that does the following:
Applies a transformation to an object that varies over time, using two of the following examples:
- An object that travels back and forth along a line repeatedly
- An object that moves in a circle
- An object that continually rotates
- An object that scales up and down repeatedly
- Uses a camera class to control the display of the scene
- Allows the user to reposition the camera in the scene using the arrow keys
Explanation / Answer
for each group glReadPixels(...); classify the group glStencilMask(0); /* so DrawPixels won’t affect Stencil */ glDrawPixels(...); 14 Programming with OpenGL: Advanced Rendering render the group Classification consists of drawing each target primitive’s depth value and then clearing those depth values where the target primitive is determined to be outside the trimming primitives. glClearDepth(far); glClear(GL_DEPTH_BUFFER_BIT); a = 0; for each target surface in the group for each partial product targeting that surface render the depth values for the surface for each trimming primitive in that partial product trim the depth values against that primitive set Sa to 1 where Sa = 0 and Z < Zfar; a++; The depth values for the surface are rendered by drawing the primitive containing the the target surface with color and stencil writes disabled. (Scount ) is used to mask out all but the target surface. In practice, most CSG primitives are convex, so the algorithm is optimized for that case. if(the target surface is front facing) glCullFace(GL_BACK); else glCullFace(GL_FRONT); if(the surface is 1-convex) glDepthMask(1); glColorMask(0, 0, 0, 0); glStencilMask(0); draw the primitive containing the target surface else glDepthMask(1); glColorMask(0, 0, 0, 0); glStencilMask(Scount); glStencilFunc(GL_EQUAL, index of surface, Scount); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); draw the primitive containing the target surface glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT);
glDepthMask(0);
glColorMask(0, 0, 0, 0);
glStencilMask(mask for Sp);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 0, 0);
glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT);
draw the trimming primitive
glDepthMask(1);
Once all the trimming primitives are rendered, the values in the depth buffer are
Zf for all target pixels classified as “out”. The Sa bit for that primitive is set to 1
everywhere that the depth value for a pixel is not equal to Zf , and 0 otherwise.
Each target primitive in the group is finally rendered into the frame buffer with
depth testing and depth writes enabled, the color buffer enabled, and the stencil
function and operation set to write depth and color only where the depth test succeeds
and Sa is 1. Only the pixels inside the volumes of all the trimming primitives
are drawn.
glDepthMask(1);
glColorMask(1, 1, 1, 1);
a = 0;
for each target primitive in the group
glStencilMask(0);
glStencilFunc(GL_EQUAL, 1, Sa);
glCullFace(GL_BACK);
draw the target primitive
glStencilMask(Sa);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
a++;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.