google search

Wednesday, October 6, 2010

Sutherland–Hodgman algorithm

The algorithm begins with an input list of all vertices in the subject polygon. Next, one side of the clip polygon is extended infinitely in both directions, and the path of the subject polygon is traversed. Vertices from the input list are inserted into an output list if they lie on the visible side of the extended clip polygon line, and new vertices are added to the output list where the subject polygon path crosses the extended clip polygon line.
This process is repeated iteratively for each clip polygon side, using the output list from one stage as the input list for the next. Once all sides of the clip polygon have been processed, the final generated list of vertices defines a new single polygon that is entirely visible. Note that if the subject polygon was concave at vertices outside the clipping polygon, the new polygon may have coincident (i.e. overlapping) edges – this is acceptable for rendering, but not for other applications such as computing shadows.


PSEUDO CODE:-
List outputList = subjectPolygon;
  for (Edge clipEdge in clipPolygon) do
     List inputList = outputList;
     outputList.clear();
     Point S = inputList.last;
     for (Point E in inputList) do
        if (E inside clipEdge) then
           if (S not inside clipEdge) then
              outputList.add(ComputeIntersection(S,E,clipEdge));
           end if
           outputList.add(E);
        else if (S inside clipEdge) then
           outputList.add(ComputeIntersection(S,E,clipEdge));
        end if
        S = E;
     done
  done


Read more...

CLIPPING PLANE

Clipping planes can be used in addition of those used created for the viewing volume. OpenGL define 6 clipping plane GL_CLIP_PLANEi (i goes from 0 to 5).
A clipping plane is a plane that separate the space in two regions. One region is included from the viewing volume, the other is excluded.

In mathematics, a plane is defined by this equation :
    a*x+b*y+c*z+d = 0
(x, y, z) are the coordinates of the points in the 3D space. All points that verify this equation are on the plane.
The inequality (< or > instead of =) define the region in each side of the plane.

In OpenGL, a clipping plane is the region defined by this equation :
    a*x+b*y+c*z+d >= 0
A clipping plane is creates with the 4 values a, b, c & d likethis :
    double[] eq = {a, b, c, d}
    gl.glClipPlane(GL_CLIP_PLANEieq)    

All points draw , the other are excluded (will not be rendered on the screen).

Like for lights, clipping planes have to be enable to be active :
    gl.glEnable(GL_CLIP_PLANEi) 

Read more...

ORTHOGRAPHIC PROJECTION

The Viewing Volume shape in this case is a parallelepiped. The 6 clipping planes delimiting the space can be created with the aid of :
    gl.glOrtho(leftrightbottomtopnearfar)



VIEW VOLUME LOOKS LIKE:-




Read more...

PERSPECTIVE PROJECTION

With this kind of projection, the viewing volume shape is a truncated pyramid (its top is cutted).

This shape is abtained by 6 cutting planes : front, back, right, left, top and bottom planes (planes at the volume boundary). These planes are commonly called Clipping Planes. These planes can be created with the aid of the method :
    glu.gluPerspective(fovyaspectnearfar)
The fovy parameter is the angle between the plane that goes downwards and the plane that goes upwards.
The aspect ratio is generaly the aspect ratio of the window (window is the region of the screen in which the scene is rendered).




Read more...

VIEWING VOLUME

The 3D space is defined by 3 axis (vectors) : X, Y and Z. These 3 axis creates an axis system (see Tutorial 4for a representation of this axis system). All points of the 3D space can be expressed as a linear combination of these vectors. A point is point represented by its coordinates (x, y, z), which means x * X + y * Y + z * Z (upper case is a vector, low case is a scalar). The volume of the entire 3D space is infinity.

The Viewing Volume delimites the 3D space by creating a closed volume. Points outside this volume will not appears on the screen.
This particularity explain the first call glTranslate (just after glLoadIdentity) : we go inside the Viewing Volume. At start, we are on the front plane of the viewing volume.

The Viewing Volume can be created with two different kind of projections :
    Perspective Projection  Render object affected by the distance, a car is seen smaller when it move away.
    Orthographic Projection Render object NOT affected by the distance like a menu, a text on the screen, 2D objects ...

Read more...

Tuesday, October 5, 2010

CLIPPING ALGORITHMS

• Clipping eliminates the parts of a scene that aren’t going to be visible in the
final display.

• Clipping can be applied to various types of graphics objects.
– Points – this is basically trivial; check to see that the point coordinates are
between the clipping boundaries.
– Lines
– Fill Areas
– Curves
– Text

• The first three are standard in graphics packages.

• Most of the algorithms apply to rectangular clipping regions

Read more...

MODIFYING WINDOW PROPERTIES

• You can control how the window is reshaped by defining a reshape function
and setting it as the reshape callback using
glutReshapeFunc( winReshapeFunc);

• You can modify the size and shape of the current window using
glutPositionWindow( xNewTopLeft, yNewTopLeft);
glutReshapeWindow( newWidth, newHeight);

• Change the window title with
glutSetWindowTitle( newTitle);

• Specify the cursor with
glutSetCursorShape( shape);
Use symbolic constants like GLUT_CURSOR_UP_DOWN to specify the shapes. (Exact
shapes available are system specific.)

Read more...

USING MULTIPLE WINDOWS

• Create multiple windows by doing the same sequence of steps for each window.

• You need to keep track of the window ID to be able to go back to a particular
window.
glutSetWindow(windowID);
is used to make a particular window active.

• You can destroy a window when you are done with it.
glutDestroyWindow( windowID);

• The current window ID can be obtained using
glutGetWindow();

Read more...

DISPLAY WINDOWS IN OPEN GL

• Don’t forget to initialize GLUT with glutInit.

• Create a window of specified size in a particular position on the screen with
glutInitWindowPosition( xTopLeft, yTopLeft);
glutInitWindowSize( dwWidth, dwHeight);
glutCreateWindow( "Title");

• Default position is (−1,−1) which allows the window system to choose the
position.

• Default size is 300 pixels square.

• glutCreateWindow returns an integer id for the window. You only need this
if you are displaying more than one window.

Read more...

VIEWPORTS IN OPEN GL

• To specify the viewport parameters, do
glViewport( xvmin, yvmin, vpWidth, vpHeight)
with parameters given in integer screen coordinates. The first two give the
position of the lower left corner relative to the lower left corner of the display
window.

• By default, the viewport is the entire window. window.

• You can create multiple viewports within a window.

• To get the parameters for the active viewport, use
glGetIntegerv( GL_VIEWPORT, vpArray);
where vpArray is a 4 element integer array. The contents of vpArray after
the function returns will be the same as the arguments given to glViewport
in the same order

Read more...

2D VIEWING IN OPEN GL

• The basic library does everything in 3D.
– The 3D routines can be adapted to 2D
– A viewport function is provided.

• To define clipping windows and viewports, first go to projection mode.
glMatrixMode( GL_PROJECTION);
If necessary, use glLoadIdentity to initialize the matrix.

• A 2D clipping window can be defined with
gluOtrho2D( xwmin,xwmax, ywmin,ywmax)

• Normalized coordinates are from −1 to 1 in OpenGL. This is the default
clipping window.

Read more...

2D RENDERING PIPELINE

Read more...

2D VIEWING TRANSFORMATION

Read more...

2D COORDINATE SYSTEM

• We use modeling coordinates for individual parts of a 2D scene. For example,
your polygon function put the polygon at the origin with a “radius” of 1.
Those were modeling coordinates.

• World coordinates are used for organizing the parts into a scene.

• View coordinates are the coordinates within the desired viewport which is
somewhere within the window you are using.

• Normalized coordinates are between 0 and 1 or -1 and 1 in each direction.
They are used to make the viewing process independent of the output device.

• Device coordinates are relative to the actual display area on whatever device
you are using.

Read more...

2D TRANSFORMATIONS

The ability to perform transformations on objects in an image is an important feature of a graphics system. Operators were added to this system which allow the user to create 2D transformation matrices that perform the following transformations:

  • scale around (0, 0)
  • scale around an arbitrary point, with the x-scale direction oriented to a specified angle
  • translate
  • rotate around (0, 0)
  • rotate around an arbitrary point
In addition, helper functions were created that perform matrix multiplication, reset a matrix to the identity, reset a matrix to the zero matrix, and print a matrix. Below are some sample images created using these methods. The original polygons are in red, and the tranformed ones are in blue. The images are of translation, rotation of PI/4 about (0, 0), rotation of PI/4 about (80, 40), scaling by .8 in x and y, and respectively.

Read more...

Monday, October 4, 2010

3D AND ANIMATION


3D computer graphics

3D computer graphics in contrast to 2D computer graphics are graphics that use a three-dimensional representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images. Such images may be for later display or for real-time viewing.
Despite these differences, 3D computer graphics rely on many of the same algorithms as 2D computer vector graphics in the wire frame model and 2D computer raster graphics in the final rendered display. In computer graphics software, the distinction between 2D and 3D is occasionally blurred; 2D applications may use 3D techniques to achieve effects such as lighting, and primarily 3D may use 2D rendering techniques.
3D computer graphics are often referred to as 3D models. Apart from the rendered graphic, the model is contained within the graphical data file. However, there are differences. A 3D model is the mathematical representation of any three-dimensional object. A model is not technically a graphic until it is visually displayed. Due to 3D printing, 3D models are not confined to virtual space. A model can be displayed visually as a two-dimensional image through a process called 3D rendering, or used in non-graphical computer simulations and calculations.


Computer animation

Computer animation is the art of creating moving images via the use of computers. It is a subfield of computer graphics and animation. Increasingly it is created by means of 3D computer graphics, though 2D computer graphics are still widely used for stylistic, low bandwidth, and faster real-time rendering needs. Sometimes the target of the animation is the computer itself, but sometimes the target is another medium, such as film. It is also referred to as CGI (Computer-generated imagery or computer-generated imaging), especially when used in films.
Virtual entities may contain and be controlled by assorted attributes, such as transform values (location, orientation, and scale) stored in an object's transformation matrix. Animation is the change of an attribute over time. Multiple methods of achieving animation exist; the rudimentary form is based on the creation and editing of keyframes, each storing a value at a given time, per attribute to be animated. The 2D/3D graphics software will interpolate between keyframes, creating an editable curve of a value mapped over time, resulting in animation. Other methods of animation include procedural and expression-based techniques: the former consolidates related elements of animated entities into sets of attributes, useful for creating particle effects and crowd simulations; the latter allows an evaluated result returned from a user-defined logical expression, coupled with mathematics, to automate animation in a predictable way (convenient for controlling bone behavior beyond what a hierarchy offers in skeletal system set up).
To create the illusion of movement, an image is displayed on the computer screen then quickly replaced by a new image that is similar to the previous image, but shifted slightly. This technique is identical to the illusion of movement in television and motion pictures.

Read more...

2D COMPUTER GRAPHICS


 
 
2D computer graphics are the computer-based generation of digital images—mostly from two-dimensional models, such as 2D geometric models, text, and digital images, and by techniques specific to them. The word may stand for the branch of computer science that comprises such techniques, or for the models themselves.
2D computer graphics are mainly used in applications that were originally developed upon traditional printing and drawing technologies, such as typography, cartography, technical drawing, advertising, etc.. In those applications, the two-dimensional image is not just a representation of a real-world object, but an independent artifact with added semantic value; two-dimensional models are therefore preferred, because they give more direct control of the image than 3D computer graphics, whose approach is more akin to photographythan to typography.


Pixel art

Pixel art is a form of digital art, created through the use of raster graphics software, where images are edited on the pixel level. Graphics in most old (or relatively limited) computer and video games, graphing calculator games, and many mobile phone games are mostly pixel art.


Vector graphics

Vector graphics formats are complementary to raster graphics, which is the representation of images as an array of pixels, as it is typically used for the representation of photographic images. There are instances when working with vector tools and formats is best practice, and instances when working with raster tools and formats is best practice. There are times when both formats come together. An understanding of the advantages and limitations of each technology and the relationship between them is most likely to result in efficient and effective use of tools.

Read more...

COMPUTER GRAPHICS


The term computer graphics has been used in a broad sense to describe "almost everything on computers that is not text or sound". Typically, the termcomputer graphics refers to several different things:
  • the representation and manipulation of image data by a computer
  • the various technologies used to create and manipulate images
  • the images so produced, and
  • the sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content, see study of computer graphics
Compute graphics is the life line of today's computer world. Today, computers and computer-generated images touch many aspects of daily life. Computer imagery is found on television, in newspapers, for example in weather reports, or for example in all kinds of medical investigation and surgical procedures. A well-constructed graph can present complex statistics in a form that is easier to understand and interpret. In the media "such graphs are used to illustrate papers, reports, theses", and other presentation material.
Many powerful tools have been developed to visualize data. Computer generated imagery can be categorized into several different types: 2D, 3D, 5D, and animated graphics. As technology has improved, 3D computer graphics have become more common, but 2D computer graphics are still widely used. Computer graphics has emerged as a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content. Over the past decade, other specialized fields have been developed like information visualization, and scientific visualization more concerned with "the visualization of three dimensional phenomena (architectural, meteorological, medical, biological, etc.), where the emphasis is on realistic renderings of volumes, surfaces, illumination sources, and so forth, perhaps with a dynamic (time) component".

Read more...

  © Blogger templates ProBlogger Template by Ourblogtemplates.com 2008

Back to TOP