+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Beginning VRML2

  1. #1
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Beginning VRML2

    Beginning VRML2
    Hi all,
    VRML is an ever growing technology that enables web developers to display 3D objects and environments in a web browser. You’ve probably heard of VRML from the newsteller, that’s why I wanted to make a tutorial to introduce it in a better way.

    Through this tutorial you will get to know the basics of VRML and its main components and shapes

    the file extension associated with VRML is “.wrl” which is basically a text file with unique structure similar to HTML, to display the 3D objects in your browser you will only need to install relatively small plug-in for your browser –I’ve attached a plug-in


    The structure of a typical .wrl file contains three elements:
    • File header
    • Comments
    • Scene graph

    Header
    The file header looks like this:
    Code:
    #VRML V.2 utf8
    Notice that it starts with a ‘#’ and there’s a space between ‘VRML’ and V.2 which indicated the version of VRML you are using, and utf8 indicates the Encoding type that you use which is (UCS Transformation Format and its 8bit)

    Comments
    Comments start with a ‘#’ sign except the first line because it’s the header (ex:# this line is a comment).

    Scene Graph
    The rest of this tutorial will be about the scene graph.

    Scene Graph is a Collection of nodes that draws or describes the shapes that we want to draw and how these shapes appear (lights, textures ….). Each node in a Scene graph may contain zero or more fields and each field can be assigned with values or left blank, I bet you have lost me so lets view a simple example:
    Code:
    #VRML V2.0 utf8
    # You can write this text in a text document and save it as “.wrl”
    
    Shape{
       appearance Appearance{ 
         texture ImageTexture { url "codecall.JPG" }
         material Material{}
       }
    geometry Box{
    size 4 2 2
    }
    }
    There are 54 types of nodes in VRML, Objects of VRML are placed inside a main node that’s called “shape” which contains another 2 nodes (appearance and geometry) , the appearance node that specifies how (not what) the object will be displayed in this example we used a texture with the path to a “.jpg” file.
    And the geometry node identifies what object geometry to draw and it has one field (size) that specifies the dimensions of the box (x,y,z)

    When you view this .wrl file in your browse it will look like this:


    Now let’s take a brief look at the available shapes that we can use:
    1. Box
    2. Cone
    3. Cylinder
    4. Sphere
    5. Text
    -No explanation needed for the box shape we already used it

    Cone
    -the cone has two fields that we can customize: height and bottom radius
    Code:
    Shape{
       appearance Appearance{ 
         material Material{}
    }
    geometry Cone{
    height 7
    bottomRadius 3.5
    }
    }
    cylinder
    -the cylinder has two fields the height and the radius:
    Code:
    geometry Cylinder{
         height 3
         radius 2
     }
    Sphere
    -the sphere has one field: the radius


    Text
    Code:
    Text{
    string [ "CodeCall.Net" , "  While(true)" ]
    fontStyle FontStyle{
    style "italic"
    size 3.0
    spacing 1.0
    }
    }
    In this one we have 1 field and one node , the first field is the “string” value(s) that we want to write and the node contains various fields related to the font, size and spacing. in the style field we can use bold, italic, bolditalic, or plain (notice that they are all in lowercase).the spacing is the vertical spacing between each string we have.

    Here is the final output of the previous code:

    --------------------------------------------------------------------


    Transform Node

    -Till now we know how to draw a single shape in one VRML, but we have a problem; if we try to draw more than one shape they will collapse because the are all drawn in the same position , that’s why we will need the “Transform Node”
    The Transform node includes the translation (position), rotation and scaling. A typical fields of and transform node can look like this:
    Code:
    Transform{
        translation X Y Z
        rotation X Y Z angle
        scale X Y Z
        Children[……]
    }
    The above code X,Y, and Z represent float variables . in the rotation field we specified the direction of the rotation and the angle, for example this line(rotation 0.0 1.0 0.0 .5) will rotate the shape around the y axis for .5 angle (90degree) . The “scale” node will resize the shape according to the values you assign to x,y and z.

    The children node will contain the shapes that we want to draw, now lets test this node:
    Code:
    #VRML V2.0 utf8
    Transform{
       translation 3.0 4.0 00
       rotation 0.0 0.0 1.0 1.0
       scale 1.0 0.5 1.0
       children[
         Shape{
           appearance Appearance{ 
           material Material{}
          }
         geometry Cylinder{
              height 3
              radius 2
          }
        }
        Shape{
           appearance Appearance{ 
           material Material{}
        }
        geometry Cylinder{
              height 8
              radius 0.1
    }  }  ]  }
    Transform{
           translation -2.0 0.0 00
           rotation 0.0 0.0 0.0 0.0
           scale 1.0 0.5 1.0
           children[
               Shape{
                    appearance Appearance{ 
                    material Material{
                        diffuseColor 0.0 0.5 1.0
                        specularColor 0.5 1.0 0.0 
                        ambientIntensity 0.5
                        transparency 0.2
                        shininess 10 
                    }
               }
              geometry Text{
                 string [ "CodeCall.Net" , "  While(true)" ]
                 fontStyle FontStyle{
                 style "italic"
                 size 3.0
                 spacing 1.0
    } } } ] }
    Notice we have two Transform nodes, in the first node we inserted two shapes that’s why they collapsed into one we can separate them by making a third Transform node and assigning different position.

    Now lets take a brief look at the Material node, which controls the values of color and lightening and transparency:
    • diffuseColor: is the dominant color of the shape and take three values
    • specularColor: is a highlight Color
    • ambientIntensity: specifies the amount of ambient light (brightening and darkening)
    • transparency: takes one float value and ranges from (0.0 to 1.0) 0.0 means its transparent
    • shininess: takes one value which determines the highlight size

    And here is the final output:


    I hope you liked this tutorial, don’t hesitate to ask anything or comment
    All the previous .wrl files and plug-in are in the attachments
    **sorry for my English
    Amr
    Attached Thumbnails Attached Thumbnails Beginning VRML2-pic1.jpg   Beginning VRML2-pic2.jpg   Beginning VRML2-pic3.jpg   Beginning VRML2-codecall.jpg  
    Attached Files Attached Files
    yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
    Code:
    eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
    www.amrosama.com | the unholy methods of javascript

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Beginning VRML2

    Very nice tutorial.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Beginning VRML2

    thnx wp
    i was starting to worry for not showing up
    Last edited by amrosama; 11-02-2008 at 09:32 AM.

  5. #4
    Jordan Guest

    Re: Beginning VRML2

    Awesome tutorial! +rep

  6. #5
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    Re: Beginning VRML2

    Good Tutorial .. +rep when it allows me to

  7. #6
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Beginning VRML2

    Haha
    its okay i didnt make it for rep points anyway

  8. #7
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Beginning VRML2

    I haven't read it just yet because I am busy, but a quick scan of it and the outcomes are REALLY good! +rep

    Can't +rep ATM

    Also, just a note.
    GET RID OF IE
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  9. #8
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Beginning VRML2

    love is blind brandon
    yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
    Code:
    eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
    www.amrosama.com | the unholy methods of javascript

  10. #9
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Beginning VRML2

    What does that mean amro?
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  11. #10
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Beginning VRML2

    im loyal to internet explorer
    but the pc i was using while writing the tutorial had tint processor and ram so i used Ie because it opens fast
    yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
    Code:
    eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
    www.amrosama.com | the unholy methods of javascript

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginning PHP
    By Xav in forum PHP Development
    Replies: 110
    Last Post: 02-16-2011, 04:27 AM
  2. beginning C#
    By mastrgamr in forum C# Programming
    Replies: 8
    Last Post: 12-27-2009, 06:44 AM
  3. Beginning C programming
    By ady251981 in forum C and C++
    Replies: 5
    Last Post: 08-31-2009, 01:07 PM
  4. Beginning C++
    By PlayaSkater in forum C and C++
    Replies: 17
    Last Post: 07-21-2008, 09:25 AM
  5. The beginning!
    By Jaan in forum PHP Tutorials
    Replies: 1
    Last Post: 02-20-2007, 05:43 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts