Vizard 7 » Reference » 3D models » 3D model basics
7.7

3D model basics

3D models are the 3D objects inside of your world. Usually you will import objects created by other software, although you can also create objects from primitives within Vizard.  

Adding and removing 3d models

Add 3D models to your world with viz.add(<object filename>).  Because adding objects can sometimes take a couple seconds, you are better off adding all your objects at the beginning of your script. If you do not want to see an object initially, turn off its visibility with <node3d>.visible(). To remove an object from your world permanently, use <node3d>.remove().

object = viz.add('soccerball.ive')
object.visible( viz.OFF ) #Make the object invisible.
object.remove() #Remove the object.

Avatars

Avatars are a special class of 3D models. You can use any of the commands you use with other 3D models. In addition to the generic commands, they have a variety of functionality all their own, detailed in the avatar section.

Appearance and texturing models

The appearance and texturing of 3D models can be changed in all sorts of ways. Check out this section for more details.

object = viz.add('ball.wrl') #Add an object.
object.alpha( .5 ) #Make it semi-transparent.
object.texture( viz.addTexture( 'image2.jpg' ) ) #Change its texture.
 

Rotating, positioning and scaling models

Rotating, positioning and scaling models are all common ways to transform models. Check out this section for more details on transforms.

object = viz.add('wheelbarrow.ive') #Add object.
object.setPosition( 0, 2, 0 ) #Translate it up.
object.setEuler( 90, 0, 0 ) #Rotate it.
object.setScale( 2, 2, 2 ) #Scale it.

Retrieving object information

To retrieve information about 3D models, check out the <node3d> library of commands beginning with 'get'.

object = viz.add('wheelbarrow.ive') #Add object.
object.setPosition( 0, 2, 0 ) #Translate it up.
print( object.getPosition() )#Print its position.
print( object.getFilename() )#Print its filename.

Animating models and model physics

For information on how to animate objects, check out the sections on actions and animation paths. If you want to move your model by applying forces or want your model to collide with other models, check out the section on physics.

Duplicating, copying and cloning objects

To copy an object, use <node3d>.copy(). This copy will have the appearance of the original object when it was created. Any future changes to the original object's appearance will not affect the copy. Copies are also created independent of any position, orientation or scale transforms applied to the original object. So, even if you create a copy of an object that is two meters about the origin, the copy will appear at the origin.

 

To create a clone, use <node3d>.clone(). Clones share the appearance of all the other clones. Changing the appearance of any one clone will change the appearance of all the clones (although all their position, orientation, and scale transforms will be independent).

 

To create a duplicate of an object that appears in another scene and shares the appearance and transforms of the original object, use <node3d>.addParent(<parent>,<scene>),where <scene> is the scene you want the duplicate to appear in. See the section on scene basics for more on this distinction.

object = viz.add('soccerball.ive')
objectCopy = object.copy() #Copy the object
objectCopy.setPosition( 1, 0, 0 )
objectClone = object.clone() #Clone the object
objectClone.setPosition( -1, 0, 0 )
object.color(viz.YELLOW) #Change the appearance of the clones.
object.addParent(viz.WORLD,2) #Duplicate the object in scene 2.

See also

In this section:

3D model command tables

Transforms and hierarchies

Appearance and texturing

Node plugins

3D text nodes

Other sections:

Action basics

Animation path basics

Linking

Physics engine

Example scripts:

Rotation

Translation

3D text

3D objects on-the-fly

Hierarchical