spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / 3d / lesson28

Lesson 28 - VRML 97 Free Fall - Part 2

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

The Shape nodes are indeed confusing. They are divided into geometry and appearance fields, but this is not the difficult part. The appearance field calls for a node named Appearance and this node contains a field named material. The material field in turn calls for a node named Material which in turn contains a diffuseColor field. Believe it or not, all this makes sense.

Consider this example.

#VRML V2.0 utf8
Transform {
  children [
    DEF Ball Shape {
      geometry Sphere {radius .5}
      appearance Appearance {
        material  DEF Red Material { diffuseColor 1 0 0 }
      } #end of Appearance
    } #end of shape        
    Transform {
      translation  2 0 0 
      children [
        Shape {
          geometry Box {}
          appearance Appearance {
            material USE Red
          }
        }# End of Shape
      ]#end of children of this transform
    }#end of this transform
    Transform {
      translation -2 0 0
      children [
        USE Ball
      ] #end of children of this transform
    }#end of this transform

  ]#end of children of world transform
} #end of world transform

CLICK HERE to load example if you have a VRML browser.

Before addressing the appearance issue, notice again how the entire world is placed in a Transform node composed of three children. The first child is a Shape (a Sphere) outside its own Transform and therefore cannot be transformed independently in the scene. It is placed at the center of world space. The second and third Shapes (a Box and another Sphere) are in their own Transforms, and translated two units to the right and left respectively.

The first Shape is defined. The DEF tag means that the Shape node is being named Ball, though I could have called it anything. Once the Shape node has been so named, the same name can be used in any other shape node to produce the same result, both as to geometry and appearance. Note how the last Shape uses the Ball node defined before. Thus the third Shape (the one on the left of the screen) has the same geometry and appearance as the first Shape in the world. The one is said to be an "instance" of the other, and if any of the properties of the first node changed, the instance would change with it.

This same power of defining and instancing can be used with appearance. Notice how the Material node of the first Shape is defined as Red. The diffuseColor field of that node is set to 1, 0, 0, (red in the red, green, blue color system). Thus the Material is red in color. The Material node of the second Shape (the Box) is made an instance of the Red node already defined. Thus the color of this node is red as well. This is why the material and appearance fields are made to contain Material and Appearance nodes. As nodes, they can be defined or instanced, and thus used again and again with a simple syntax that reveals a connection between different elements of the world.

Every object in the scene is red. The central Sphere is red because it was made red directly. The Box is red because it instances the Red Material node defined in the first Sphere. And the sphere on the left is red because the entire Shape (both geometry and appearance) is an instance of the first Sphere. (Notice the way that we capitalize the first letter in a node name, but not in a field name.)

This basic concept of instancing can now be taken a further important step.

To Continue to Part 3, or Return to Part 1, Use Arrow Buttons


internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Review: Lenovo ThinkPad SL300 · OCZ PC3-10666 Gold 2x1GB Review · Apple Recommends Antivirus for Macs

Created: November 24, 1997
Revised: November 24, 1997

URL: http://webreference.com/3d/lesson28/part2.html