Download presentation
Presentation is loading. Please wait.
Published byBertha Miles Modified over 9 years ago
1
1 Review of COMPSCI 221 Chapters 1-11 in text User Interfaces will be addressed as a take- home question
2
2 Computer Graphics Modeling: Creating a virtual world. Rendering: Generating a visual image of a scene.
3
3 Java2D Graphics2D class manages the rendering Use a Panel to provide the Graphics context Use JApplet or JFrame as root container
4
4 Graphics2D Class Properties –Foreground color –Font –Stroke –Paint Capabilities –drawing and filling Shape objects –applying AffineTransforms
5
5 2D Objects A 2D object consists of a set of points in a plane Examples –point –lines, curves –shapes like rectangles, ellipses, arcs, polygons –text and images
6
6 Parametric Equation Parametric equation expresses each coordinate in terms of a parameter x = f(t) y = g(t) The parametric equation for an ellipse is x = x 0 + a cos t y = y 0 + b sin t
7
7 Custom Shapes Area combines shapes to create more complex objects Set-theoretic operations –Intersect –Add –Subtract –Exclusive or PathIterator interface allows Shape object to return an iterator to sub- parts Path2D constructs an outline from a sequence of lines and curves –moveTo –lineTo –quadTo –curveTo –closePath
8
8 Coloring Objects Paint interface supports –Color - create a color by giving the amount od red, green, blue to make the color –Gradients - interpolations between two different colors –Texture - use an image to "color" an object
9
9 Strokes The Stroke interface defines a method for creating an outline from a shape BasicStroke class has the following properties –Width –End style (butt, round, square) –Join style (bevel, miter, round) –Miter limit (limits miters on small angle joins) –Dash pattern and phase
10
10 Affine Transformation Maps parallel lines to parallel lines Common affine transforms in both 2D and 3D –Translation –Rotation –Reflection –Scale –Shear
11
11 Clipping Path A rendered image may be clipped by a clipping path
12
12 Text in Java2D Text is treated as a special kind of geometric object A Font defines the rendering shapes of all the characters Geometry of a text string in a particular font is represented by a GlyphVector Create a Shape from the GlyphVector
13
13 BufferedImage A BufferedImage contains –Raster -- holds the pixel values –ColorModel -- specifies how to interpret pixel values BufferedImage has a create Graphics method which allows you to draw to the image BufferedImageOps –RescaleOp - scale pixel values linearly –LookupOp - use a table to convert pixel values –ConvolveOp - convolute pixel value with thos of neighbors –ColorConvertOp - pixel-by- pixel color conversion –AffineTransformOp - apply the specified transformation to each pixel
14
14 Animation You need a way to make something happen at regular intervals –Change some parameter used by the paintComponent method –call repaint() or revalidate() to cause paintComponent to be called Timer is a Swing Component –delay can be set –generates an ActionEvent after each delay period –register a Listener to respond to the event
15
15 3D Model and View
16
16 Java 3D High-level API Scene is represented as a scene graph object –Content branch defines the onjects in the scene –View branch defines how the scene is viewed VirtualUniverse –SimpleUniverse Locale Nodes –Group nodes –Leaf nodes NodeComponents –attached to one or more nodes
17
17 Background and Bounds Default background is black Create custom background with the Background node –set the color –use an image –use a geometry Environmental nodes need to be limited in extent –e.g. lights, background –limits amount of rendering to be done Two ways: –Bounds, node component –BoundingLeaf, a Node uses a Bounds object
18
18 Points and Vectors Point represents position Vector represents direction Both can be represented as a tuple An n-dimensional vector is an n-tuple of numbers –(x 1, x 2, …, x n )
19
19 Shapes in 3D Use a Shape3D Node to represent visual objects –A Shape3D leaf node usually references Geometry and Appearance node components Geometry is abstract class with many subclasses –GeometryArray –IndexedGeometryArra y –Text3D
20
20 GeometryArray Supports construction of objects using arrays of points, lines and polygons Defines an array of vertices along with other properties that are associated with them –normals –color (3 or 4 elements) –texture coordinates (2, 3 or 4 elements)
21
21 Transform3D A higher-level representation for transformations Has constructors to create from both Matrix objects and from vectors Also has set and get methods for the internal 4 x 4 matrix Can also set a particular type of transformation
22
22 Views View Volume –represented by a projection matrix View positioning –represented by a view matrix View Properties –Projection type –Field of view –Limits to view distance –Size of view plate
23
23 Projections A projection maps a point in the virtual world onto a view plane –view plate is a finite window in the view plane –also limit the depth that is rendered Two types of projection –parallel –perspective
24
24 Types of Lights Ambient light –uniform in all directions and locations Directional light –models a distant light source whose rays are all parallel Point light –light located at a particular location which emits in all directions –Intensity decreases with distance Spot light –Like a point source except the direction of the emission is restricted
25
25 Geometry of Reflection For perfectly reflective surface –angle of incidence = angle of reflection –no loss of intensity In reality surfaces aren't perfect –light gets scattered –light can be absorbed Phong model I = I a k a + I p k d cos + I p k s cos n –k a, k d, k s are coefficients for ambient, diffuse and specular reflection for a particular material –n is the shininess coefficient, also a property of the material
26
26 Appearance Node component which has components that control various aspects of the appearance of an object. –ColoringAttributes, RenderingAttributes, TransparencyAttributes –PointAttributes, LineAttributes, PolygonAttributes –Material –TextureAttributes, Texture, TexCoordGeneration, TextureUnitState
27
27 Material Contains components to control the color contributed by different kinds of lighting –ambient, diffuse, specular –can also contain an emissive color component Shininess coefficient affects specular reflection Color target for per-vertex colors
28
28 Depth Cueing Atmospheric attenuation effects can be simulated with depth cueing Blend the objects with background color (or with arbitrary fog color) C = f C 0 + (1 - f) C f Blending is an increasing function of the distance –linear –exponential –gaussian
29
29 Texture Mapping Real surfaces often have a large amount of detail Use a digital image to provide complex detail with minimal computational cost Procedural textures use a function to calculate the color at any given point
30
30 Behavior Java3D uses behavior to facilitate dynamics in a scene graph Behavior is a leaf node –Defines actions to be taken when the behavior is activated (waked-up) –Behavior is triggered by wakeup conditions For interactions, triggers are user generated For animation, triggers are time-based
31
31 Interpolators for Animation Interpolator is an abstract subclass of Behavior –It has a number of predefined subclasses containing typical behaviors needed for animation For example, Color, Switch, Transparency, Transform The idea is to set two values for a particular attribute and interpolate values in between as a function of time Alpha object is used to trigger the changes
32
32 Alpha A function of time –usually periodic Has a range from 0.0 to 1.0
33
33 User Interfaces Design principles –User should be in control –Reduce memory load for users –Be consistent Useability heuristics –Ease of learning and remembering –Efficiency of use –Minimize errors Facilitate recovery from errors
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.