Skip to content

VRML in Mayavi2

February 14, 2011

VRML

It stands for Virtual Reality Modelling Language. VRML as a text-based language is a powerful, nevertheless simple language to build ‘virtual worlds’, which include 3D objects, light sources and animations. The description of these virtual environments is a text file, usually identifiable from its ‘.wrl’-extension.

VRML in Mayavi2

Mayavi can interpretes any .wrl file. A simple VRML to display cylinder

#VRML V2.0 utf8
Shape {
 appearance Appearance { 
   material Material { 
     diffuseColor 0.0 0.5 1.0 
   } 
 } 
 geometry Cylinder {
   height 2.0
   radius 1.5 
 } 
}

Save the file as cylinder.wrl

Now open mayavi2
then
File->Load Data->Open file
Select the cylinder.wrl file. It will show cylinder in Mayavi2 screen.

I have drawn a small house in VRML

#VRML V2.0 utf8
Group {
    children [
    # Celing
        Shape {
            appearance DEF White Appearance {
                material Material { }
            }
            geometry Box {
                size 25.0 0.1 25.0
            }
        },
    # Column 1
        Transform {
            translation -10.0 -5.0 -10.0
            children Shape {
                appearance USE White
                geometry Cylinder {
                    radius 1.0
                    height 10.0
                }
            }
        },
        #  Column 2
        Transform {
            translation 10.0 -5.0 -10.0
            children Shape {
                appearance USE White
                geometry Cylinder {
                    radius 1.0
                    height 10.0
                }
            }
        },
        
        # Column 3
        Transform {
            translation -10.0 -5.0 10.0
            children Shape {
                appearance USE White
                geometry Cylinder {
                    radius 1.0
                    height 10.0
                }
            }
        },
        #  Column 4
        Transform {
            translation 10.0 -5.0 10.0
            children Shape {
                appearance USE White
                geometry Cylinder {
                    radius 1.0
                    height 10.0
                }
            }
        },
        
        #ground 
        Transform {
            translation 0.0 -10.0 0.0
            children Shape {
                appearance USE White
                geometry Box {
                    size 25.0 0.1 25.0
                }
            }
        }
        
        #back wall
        Transform {
            translation 0.0 -5.0 -12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 0
                  }
                }
                geometry Box {
                    size 25.0 10.1 1.0
                }
            }
        },
        
       #left wall
        Transform {
            translation 12.0 -5.0 0.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 0
                  }
                }
                geometry Box {
                    size 1.0 10.1 25.0
                }
            }
        },
        
        #right wall
        Transform {
            translation -12.0 -5.0 0.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 0
                  }
                }
                geometry Box {
                    size 1.0 10.1 25.0
                }
            }
        },
        
        #door left wall
        Transform {
            translation -7.0 -7.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 0
                  }
                }
                geometry Box {
                    size 10.0 6.0 1.0
                }
            }
        },

       #steps1
       Transform {
            translation 9.0 -2.0 13.5
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 1
                  }
                }
                geometry Box {
                    size 6.0 2.0 2.0
                }
            }
        },
       #steps2
       Transform {
            translation 9.0 -4.0 15.5
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 1
                  }
                }
                geometry Box {
                    size 6.0 2.0 2.0
                }
            }
        }
       #steps3
       Transform {
            translation 9.0 -6.0 17.5
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 1
                  }
                }
                geometry Box {
                    size 6.0 2.0 2.0
                }
            }
        },
       #steps4
       Transform {
            translation 9.0 -8.0 19.5
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 1
                  }
                }
                geometry Box {
                    size 6.0 2.0 2.0
                }
            }
        }  
       #steps5
       Transform {
            translation 9.0 -10.0 20.5
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 1
                  }
                }
                geometry Box {
                    size 6.0 2.0 2.0
                }
            }
        },
        #first flor back wall
        Transform {
            translation 0.0 2.5 -12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0.5 0.5 1
                  }
                }
                geometry Box {
                    size 25.0 5.0 1.0
                }
            }
        }

       #fist flor left wall
        Transform {
            translation -12.0 2.5 0.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0.5 0.5 1
                  }
                }
                geometry Box {
                    size 1.0 5.0 25.0
                }
            }
        },
        
        #first flor right wall
        Transform {
            translation 12.0 2.5 0.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0.5 0.5 1
                  }
                }
                geometry Box {
                    size 1.0 5.0 25.0
                }
            }
        }
        #first flor front wall
        Transform {
            translation -2.5 2.5 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0.5 0.5 1
                  }
                }
                geometry Box {
                    size 18.0 5.0 1.0
                }
            }
        }
       #door left wall
        Transform {
            translation 9.0 -5.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 0 1 0
                  }
                }
                geometry Box {
                    size 6.0 10.0 1.0
                }
            }
        },
       #window 
        Transform {
            translation -2.5 -2.0 12.0
            children Shape {
               appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 0.3 4.0 0.3
                }
            }
        },
        #window 
        Transform {
            translation -4.5 -2.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 0.3 4.0 0.3
                }
            }
        },
      #window 
        Transform {
            translation -6.5 -2.0 12.0
            children Shape {
               appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 0.3 4.0 0.3
                }
            }
        },
       #window 
        Transform {
            translation -8.5 -2.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 0.3 4.0 0.3
                }
            }
        },
       #window 
        Transform {
            translation -10.5 -2.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 0.3 4.0 0.3
                }
            }
        },
       #window 
        Transform {
            translation -7.5 -1.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 10.0 0.3 0.3
                }
            }
        },
       #window 
        Transform {
            translation -7.5 -2.0 12.0
            children Shape {
                appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 10.0 0.3 0.3
                }
            }
        },
       #window 
        Transform {
            translation -7.5 -3.0 12.0
           
            children Shape {
                 appearance Appearance {
                 material Material {
                        diffuseColor 1 0 0
                  }
                }
                geometry Box {
                    size 10.0 0.3 0.3
                }
            }
        },
     ]
}

output will be

One Comment leave one →
  1. February 14, 2011 3:35 pm

    nice home in vrml
    keep it rocks!!!!!!!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: