PROSEMINAR WEB3D - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

PROSEMINAR WEB3D

Description:

Our earlier animations didn t show moves, they were just static, here are some moving. ... seen that animating objects requires to lighten them up as well and add some ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 53
Provided by: wwwbruegge
Category:

less

Transcript and Presenter's Notes

Title: PROSEMINAR WEB3D


1
PROSEMINAR WEB3D
  • ANIMATIONS
  • COLORS LIGHTING
  • TEXTURES
  • By Riff Roger

2
Whats the Goal?
Get Objects to change move in a scene
Animations

Lightening up the scene,and describing
materials colors
Colors Lighting
Adding textures to your scene for realism
Textures
3
Picturing view
  • Cartoons

Scientific (molecule)
4
Picturing view
  • Our earlier animations didnt show moves, they
    were just static, here are some moving.
  • http//www.animationcentral.com/symbols.htm

5
I. Animations
  • Def Changes in the virtual universe that are
    independant of the user action.
  • ExTic Tac of our watch (happens without any
    interaction).
  • To create animations,
  • We use the behaviors classes
  • Of the Java3D-API.

Java3D-API
Behaviors classes
6
I.1.How to create Animations?
Dealing view positions Orientations in
Animations
Time-based Animations
7
I.1.A.Time-based Animations
InterpolatorsAlpha Object
Time-based Animations
  • The defined interpolator behaviors smoothly
    interpolates between two
  • extreme values which are 0.0 and 1.0 which is
    called the alpha value
  • (thats why the name interpolators).
  • Alpha Value
  • time (ms) is mapped to alpha value in range
    0,1.
  • alpha value 0,1 is mapped onto predefined
    behavior.
  • 0 is mapped to minimum extreme value .
  • 1 to maximum extreme value.
  • Alpha 1
  • Value
  • 0 1
    time

8
Phases of the Alpha wave form
9
Main steps to create a time-based animation
(thru an Ex. of ClockAnimation)


  • public class ClockAnimation // using the
    RotationInterpolator
  • public BranchGroup createSceneGraph( )
  • // create the root of the Branch
  • BranchGroup obj new BranchGroup( )
  • // 1.create a Target object with the
    appropriate capability(here TransformGroup)
  • TransformGroup target new
    TransformGroup( )
  • target.setCapability(Tr
    ansformGroup.ALLOW_TRANSFORM_WRITE)
  • // 2.create an Alpha object (here it rotates
    with a period of 1 min)
  • Alpha alpha new Alpha (-1,6000)

10
(follows here)
  • // 3.create an Interpolator referencing the Alpha
    and the Target
  • RotationInterpolator rot new
    RotationInterpolator (alpha,target)
  • // 4.Add Scheduling bounds to the
    Interpolator
  • rot.setSchedulingBounds(new
    BoundingSphere( ))
  • // 5.Add the Interpolator to the scene graph
  • obj.addChild(target)
  • target.addChild(new Clock( ) )
  • obj.addChild(rot)
  • // let Java3D perform
  • obj.compile( )
  • return obj
  • // end of createSceneGraph( )
  • // end of ClockAnimation

11
Output of the complete prog.
  • ClockAnimation by 430

N.B the alpha effect stays up to the programmer,
hes the one to decide how to increase or
decrease it (Smoothing of the alphawaveform).
12
Overviewing the API
  • Interpolators Behaviors They are called
    interpolators because they smoothly interpolate
    between the two extreme values that an
    interpolator can produce.

(Fig. Interpolators classes Hierachy)
13
Two Scenes showing various Interpolators with
their divergences.
14
Overviewing the API
  • Alpha Behaviors.
  • Four General constructors
  • 1.Alpha()constructs an alpha with
    modeINCREASING-ENABLE, loop count-1,
    increasing alpha duration1000,and all others
    parameters0,except Starttime.
  • 2.Alpha (int loopcount,long increasingAlphaduratio
    n).
  • 3.Alpha(int loopcount,long triggerTime,long
    increasingAlphaduration ....).
  • 4.Alpha( with all the different parameters.....).

15
I.1.B.Dealing View positions Orientations
  • A.Billboard Classes
  • Billboard refers to the technique of
    automaticallly rotating a planar visual object
    such it is always facing the viewer.
  • Motivationtextured plane as a low cost
    replacement for the complex geometry.
  • Classic example Trees as 2D Textures because
    they look the same when viewed in the back or
    front.

16
Steps for creating a billboard object(same as
the interpolator object but no alpha object to
drive the animation)
  • public BranchGroup createSceneGraph(SimpleUniverse
    su)
  • BranchGroup objRoot new BranchGroup()
  • Vector3f translate new Vector3f()
  • Transform3D T3D new Transform3D()
  • TransformGroup TGT new TransformGroup()
  • //1.create a target TransformGroup with
    ALLOW_TRANSFORM_WRITE capability
  • TransformGroup TGR new TransformGroup()
  • Billboard billboard null
  • BoundingSphere bSphere new BoundingSphere()

17
(follows here)
  • translate.set(new Point3f(1.0f, 1.0f, 0.0f))
  • T3D.setTranslation(translate)
  • TGT.set(T3D)
  • // set up for billboard behavior
  • TGR.setCapability(TransformGroup.ALLOW_TRANSFORM_W
    RITE) //1.step as above
  • //2.create a Billboard referencing the Target
    Transformation
  • billboard new Billboard(TGR)
  • //3.supply ascheduling bound
  • billboard.setSchedulingBounds(bSphere)
  • //4. assemble scene graph
  • objRoot.addChild(TGT)
  • objRoot.addChild(billboard)

18
TGT.addChild(TGR) TGR.addChild(createTree())
  • Scene Graph

19
Output
20
Overview of Billboard API
  • Four consructors
  • Billboard()constructs a Billboard node with
    default
  • parametersmodeROTATE_ABOUT_AXIS,axis(0,1,0).
  • Billboard(TransformGroup tg)contructs a
  • Billboard node with default parameters that
    operates on
  • the specified TransformGroup node .
  • Billboard(TransformGroup tg,int mode,Vector 3f
    axis)Thru
  • a vector as axis, with a defined mode that
    operates on the defined TransformGroup node.
  • Billboard(TransformGroup tg,int mode,Point 3f
    axis)Thru a point as axis.

21
Some Billboard Methods
Billboard class

void setAlignementAxis(Vector3f axis)sets the
Alignement axis thru a vector. void
setAlignementAxis (float x,floty,float z) do the
same but thru a 3D axis. void setRotationpoint(Po
int3f point) void setRotationPoint(float x,float
y,float z) void setTarget(TaransformGroup tg)
22
B.LOD (level of DetailAnimations)
  • LOD is a general term for a technique that varies
    the amount of detail in a visual object based on
    some value from the virtual world.
  • They are designed to provide increasingly
    detailed models as the user approaches
  • The typical Example is to vary the LOD based on
    the distance to the viewer(sometimes on the
    rendering speed).

23
LOD animation example(LOD snowflakes)

24
Steps for Creating a LOD Object(same as the
Interpolator but no alpha value)
  • public BranchGroup createSceneGraph()
  • BranchGroup objRoot new BranchGroup()
  • BoundingSphere bounds new BoundingSphere()
  • // create target TransformGroup with Capabilities
  • TransformGroup objMove new TransformGroup()
  • //1. create DistanceLOD target object
  • Switch targetSwitch new Switch()
  • targetSwitch.setCapability(Switch.ALLOW_SWITCH_WRI
    TE)

25
//6. add visual objects to the target switch
targetSwitch.addChild(new Sphere(.40f, 0, 25))
targetSwitch.addChild(new Sphere(.40f, 0, 15))
targetSwitch.addChild(new Sphere(.40f, 0, 10))
targetSwitch.addChild(new Sphere(.40f, 0, 4))
  • // 2.create list of distances tresholds array for
    the distanceLod object
  • float distances 5.0f, 10.0f, 20.0f
  • //3.create DistanceLod object using that array
  • DistanceLOD dLOD new DistanceLOD(distances,
    new Point3f())
  • //4.Set the Target switch object for the distance
    LOD
  • dLOD.addSwitch(targetSwitch)
  • //5.supply ascheduling boundsfor the distance LOD
    Object
  • dLOD.setSchedulingBounds(bounds)

26
// 6.assemble scene graph objRoot.addChild(objMo
ve) objMove.addChild(dLOD) // make the bounds
move with object objMove.addChild(targetSwitch)
// must add switch to scene graphreturn
objRoot // end of CreateSceneGraph method of
DistanceLODApp
  • Scene Graph...

27
Output
28
Overviewing the LOD API
  • Constuctor LOD()constructs and initializes an
    LOD node.
  • LOD methods summary


void addSwitch(Switch switchNode)Apppends the
specified switch Node to this LODs List of
switches. void insertSwitch(Switch node,int
index)inserts the specified switch node at the
specified index. int numSwitches() returns a
count of the LODs switch. void setSwitch(Switch
switchnode, int index)repalces the
specified Switch node with the switch node
provided.
29
C.MORPH
  • Interpolators classes change various visual
    attributes in the virtual,but theres no
    interpolators to change geometry of a visual
    object,thats what does the Morph class.
  • Morph objects can be used to turn stuff into
    another that means to change any Geometry into
    another(pyramids into cubes, dogs into cats)
  • To create Morph object, we should
  • 1.create an array of Geometry Arrayobjects,
  • 2.create a Morph object with ALOW_WEIGHTS_WRITE,
  • 3. assemble the scene Graph.

30
Example of a Morph Code
  • public class MorphBehavior extends Behavior
  • private Morph targetMorph
  • private Alpha alpha
  • // the following two members are here for
    efficiency
  • private double weights 0, 0, 0, 0
  • private WakeupCondition trigger new
    WakeupOnElapsedFrames(0)
  • // create MorphBehavior
  • MorphBehavior(Morph targetMorph, Alpha alpha)
  • this.targetMorph targetMorph
  • this.alpha alpha

31
public void initialize()// set initial wakeup
conditionthis.wakeupOn(trigger)
  • public void processStimulus(Enumeration
    criteria)
  • // don't need to decode event since there is only
    one trigger
  • weights0 0 weights1 0 weights2 0
    weights3 0
  • float alphaValue 4f alpha.value() // get
    alpha
  • int alphaIndex (int) alphaValue // which Geom
    obj
  • weightsalphaIndex (double) alphaValue -
    (double)alphaIndex
  • if(alphaIndex lt 3) // which other obj
  • weightsalphaIndex 1 1.0 -
    weightsalphaIndex
  • else weights0 1.0 - weightsalphaIndex

32
targetMorph.setWeights(weights)
this.wakeupOn(trigger) // set next wakeup
condition // end of class MorphBehavior
  • Fig-OUTPUT

33
Overviewing the Morph API
Node
  • Constructors
  • Morph(GeometryArray geometryArrays)constructs
    and initializes a Morph object with specified
    arry and null appearance object
  • Morph(GeometryArray geometryArrays,Appearance
    appearance)constructs and initializes a Morph
    object with specified arry and the defined
    appearance object

Morph
34
Morph Method Summary
  • void setApperance(Apearnce appearance) sets he
    appearance Component of the Morph node
  • void setGeometryArrays(GeometryArray
    geometryArrays) sets the Geometry arrays
    Components of the Morph Node.
  • void setWeights(double weights)sets this Morph
  • Nodes morph weight vector.

35
II.COLORS LIGHTING
  • We have seen so far how to create time based
    and Billboard-Lod animations ,
  • Now we think about coloring
  • and lighting them.

36
A.COLORS
  • What is the Color?
  • You can specify color in 3 places
  • per-vertex geometry - has highest precedence .
  • material - enables lighting. only used for lit
    objects .
  • coloring attributes - only used for unlit objects
    when no material is specified.

37
B.LIGHTING
  • To obtain Lighting effect, one must
  • add light objects to the scene graph .
  • attach a material to the shape's appearance .
  • add normals to shape's geometry.
  • Shadows and inter-object reflection are not
    modeled (as seen in the picture B.1.).

38
Picture B.1.
39
Lights objects
40
Directional light
Ambient Light (soft and general)

  • Directional light



41
Point light

  • Point light



42
Spot light
  • Spot light


43
Steps for Creating Lights(Thru the Teapotcode)
  • public BranchGroup createSceneGraph()
  • // Create the root of the branch graph
    BranchGroup
  • objRoot new BranchGroup()
  • ...
  • // 1.Create Directional light with color and
    direction. Add it to scene.
  • DirectionalLight light new DirectionalLight(new
    Color3f(1.f,1.f,1.f),new Vector3f(-1,-1,0))
    light.setCapability(Light.ALLOW_COLOR_WRITE)
    light.setInfluencingBounds(new BoundingSphere())
    objRoot.addChild(light)

44
Following...
  • //2. Create AmbientLight light with color. Add it
    to scene.
  • AmbientLight ambientLight new AmbientLight(new
    Color3f(.3f,.3f,.3f)) ambientLight.setInfluencing
    Bounds(new BoundingSphere()) objRoot.addChild(amb
    ientLight)
  • ...
  • return objRoot

45
Output
  • Check it on
  • This ouput helps us to see clearly the Lightening
    on a Teapot.
  • http//www.willamette.edu/gorr/classes/cs445/lect
    ures/Java_Overview/demos/LightedTeapot/teapot.html


46
IIITEXTURES
  • You could model every detail of every 3D shape in
    your scene .
  • This requires an enormous amount of modeling
    effort
  • More shapes means more to draw and worse
    interactivity .
  • Instead, create the illusion of detail
  • Take a photograph of the "real thing" .
  • Paste that photo onto simple 3D geometry .
  • Increases realism without increasing the amount
    of geometry to draw .
  • Not every aspect of texture mapping are
    availaible in Java3D, but the main one.

47

  • So,the detail that characterizes the surface
    color and texture of many objects is difficult to
    model simply using polygons.
  • The brick shown below is an example. On the left
    is the 3D image.
  • Texture coordinates
    Textured Object



48
Code snippet for loading textures(Recipe)
  • public BranchGroup createSceneGraph()
  • // Create the root of the branch graph
  • BranchGroup objRoot new BranchGroup()
  • ...
  • // Load in the Texture File
  • TextureLoader loader new TextureLoader("brick.jp
    g",this)
  • //Create Texture object
  • Texture brick loader.getTexture()
  • //Create Appearance Object
  • Appearance appearance new Appearance()

49
(follows here)-Rotating cube code
  • // Create Appearance Attributes and give to
    Appearance.
  • // TextureAttributes can be used for
    transforming texture (e.g. scaling)
  • TextureAttributes ta new TextureAttributes()
    appearance.setTextureAttributes(ta)
  • // Attach Texture object to Appearance object
    appearance.setTexture(brick)
  • // Create Shape object and assign it the
    Appearance object. Sphere mySphere new
    Sphere(0.7f,Primitive.GENERATE_TEXTURE_COORDS,appe
    arance)
  • ...
  • return objRoot

50
Texture modes
The Texture mode in TextureAttributes controls
how texture pixels affect shape color
. TCtexture color , SM Shape mode
  • Textures can be combined with the "color" of the
    shape.

PaTa
51
Explaining the terms.
  • Prgb is the color of the pixel being texture
    mapped, as if no texture-mapping was to take
    place
  • Pa is the alpha of the pixel being texture
    mapped, as if no texture-mapping was to take
    place
  • Trgb is the texture color
  • Ta is the texture alpha
  • Brgb is the blend color
  • Non-primed quantities denote before
  • Primed quantities denote after

52
Sum up
  • After all this talk,we still need to got deep
    into the Java3D API to master and know how each
    method needs to be handled,
  • Mean time, we have seen that animating objects
    requires to lighten them up as well and add some
    textures for more realism.
  • To have a picturingview
  • http//www.animation-central.com/symbols.htm
Write a Comment
User Comments (0)
About PowerShow.com