virtool

Homework #1

Virtools Training

Sept 5, 2005

Head over to room 130 North and try logging into any PC. Be sure to select “ACPUB Kerberos” as your login domain.

Launch Virtools Dev

(Start Menu -> Program Files -> Virtools -> Virtools Dev 3.0 -> Virtools Dev 3.0)

Email me ([email protected]) if you cannot launch the program.

Make sure you have some resources available.

Experiment with instantiating objects, changing their materials (such as texture map and transparency).

Tips: Use the “F1” key to access help.

Always “rename” an object in the Level Manager to avoid future confusion

Continue any exercises below that we did not complet today in class.

Exercise 1: Rotating a Cube

Subjects covered:

Basic scripting

Saving as a web format

Parameter display

You will need:

Asset:

File cube.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BB:

BB Rotate in 3D Transformation\ Basic folder.

Instructions:

Setting-up:

Open the Virtools resources by going to Resources → Open Data Resource

Browse the folder: C:\Program Files \ Virtools\ Virtools Dev 3.0\ Documentation.

Select the file: VirtoolsResources.rsc.

Importing assets:

From the VirtoolsResources window, select the 3DEntities\ Primitives folder

Drag & Drop the cube.nmo file into the 3DLayout window.

Adding Virtools objects:

Add a light and change its name.

Add a camera and change its name.

Creating behaviours:

Create a script for the 3D Object (cube) that will allow it to rotate in a loop.

Right click on the Angle parameter and select Change Parameter Display\ Name and Value to display the name and value of the parameter in the Schematic.

Saving as a web format (secured format):

Save the composition as Cube.vmo in a vmo format by going to File → Export to Virtools Player.

Running a web version using Virtools Web Player:

Drag & Drop the Cube.vmo file into the Internet Explorer window.

Exercise 2: Rotating and translating a Cube

Subjects covered:

The Virtools process loop

Link delay

Trace Mode

Step One Frame

You will need:

Asset:

File cube.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BBs:

BB Rotate and Translate in 3D Transformation\ Basic folder.

Instructions:

Importing assets:

From the VirtoolsResources window, select the 3DEntities\ Primitives folder.

Drag & Drop the cube.nmo file into the 3DLayout window.

Creating behaviours:

Create a script to rotate and translate the cube in a loop

Two possible ways:

Use Rotate and Translate BB in parallel with there own loop.

OR

Use Rotate and Translate BB in the same loop.

Question:

Which is the best way to script and why?

Debugging/Tracing:

Set every link delay at 1 and active the Trace Mode to show the execution process.

Execute the application step by step using the Step One Frame button.

Exercise 3: Rotating and translating with a Link delay or Time

delay

Subjects covered:

The Virtools Process Loop

Link delay >1

Time delay

Shortcuts

You will need the BB:

BB Delayer in Logics\ Loops folder.

Instructions:

Use the previous exercise

Adapting the behaviour

Use a Delayer BB after the rotation and another Delayer BB after the translation.

Debugging/Tracing:

Display the elapsed time of the Delayer BB using a shortcut to its parameter output (pOut) by displaying the shortcut value:

Right click on the parameter output Elapsed Time and select Copy.

Right click on an empty part of the script and select Paste as Shortcut.

Right click on the shortcut and select Change Parameter Display\ Name and Value.

Exercise 4: Rotating the cube for a given time

Subjects covered:

Loop in/ Loop out BB

For Loop, While Loop, Timer Loop

Use of link delay for debugging purposes

You will need:

Asset:

File cube.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BBs:

BB Timer in Logics\ Loops folder.

BB Rotate in 3D Transformation\ Basic folder.

Creating Behaviours:

Create a script to rotate the cube in a loop for a given time.

environment.

Exercise 5: Rotating the cube for a given time

Subjects covered:

Loop in/ Loop out BB

For Loop, While Loop, Timer Loop

Use of link delay for debugging purposes

You will need:

Asset:

File cube.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BBs:

BB Timer in Logics\ Loops folder.

BB Rotate in 3D Transformation\ Basic folder.

Creating Behaviours:

Create a script to rotate the cube in a loop for a given time.

Exercise 6: Camera looking at a teapot moving along a curve

Subjects covered:

Loop in/ Loop out BB

Curve

Pass data from a BB output to another BB input

You will need:

Asset:

File TeapotPatch.nmo in VirtoolsResources\ 3DEntities\ Patch Primitives folder.

BBs:

BB Curve Follow and Position on Curve in 3D Transformation\ Curve folder.

BB Look At in 3D Transformation\ Constraint folder.

Creating Behaviours:

Part 1

Create a closed curve

Import the TeapotPatch.nmo

Create a script to move the Teapot object along the curve using Curve Follow BB

Create a camera with a script to constrain the camera to look at the Teapot while it is moving along the curve using Look At BB.

Part 2

Use the Position on Curve BB in association with the Curve Follow BB to improve the Teapot behaviour with more advanced following options.

Exercise 7: Driving a Teapot + Following cameras

Subjects covered:

Loop in/ Loop out BB

For Loop, While Loop, Timer Loop

Use of link delay for debugging purposes

Part 1: Drive the Teapot

You will need:

Asset:

File TeapotPatch.nmo in VirtoolsResources\ 3DEntities\ Patch Primitives folder.

BBs:

BB Switch on key in Controllers\ Keyboard folder.

BB Rotate and Translate in 3D Transformations\ Basic folder.

Creating Behaviours:

Drive the Teapot using arrow keys like a car.

i.e. rotate left and right and translate forward and backward.

Note:

The Switch on Key BB has a “V” icon.

This icon means that you can construct additional inputs and/or outputs. Use the Construct option of the contextual menu of the BB.

Part 2: Create Third Person View Cameras

You will need the BBs:

BB Look At in 3D Transformations\ Constraint folder.

BB Rotate and Translate in 3D Transformations\ Basic folder.

a – Surveillance Camera

This camera looks at the Teapot from a static point of view.

Create a new camera

The camera looks at the object using the Look At BB.

b – Hierarchy Camera

This camera follows the Teapot from behind.

Create a new camera

Place the camera at the correct position and orientation.

In the Hierarchy Manager, parent the camera to the Teapot

Set Initial Conditions on the Camera

c – Following Camera

This camera follows the Teapot from behind but does not use hierarchy

Create a new camera

Use the Set Position BB to place the camera behind the teapot.

Use the Look at BB to force the camera to look at the teapot with some delay

d – Mimic Camera

This camera will track the position and orientation of an object.

This object must be at the exact wanted place, i.e. the perfect point of view for your “Mimic Camera”.

Create a new camera.

Use the above “Hierarchy Camera” (part b of this exercise) as the object to track.

Use the Mimic BB to force the new camera to track the position and orientation of the object to track.

Part 3: Switch cameras using keyboard keys

You will need the BBs:

BB Switch on Key in 3D Transformations\ Constraint folder

BB Set As Active Camera in Cameras\ Montage folder

BB Identity in Logics\ Calculator folder

Exercise 8: Time Dependant Versus Frame Dependant

Subjects covered:

Per Second BB

You will need:

Asset:

Use Exercise number 7.

BBs:

BB Per Second in Logics\ Calculator folder.

Adapt the previous exercise number 7 using “Per Second” BB in a way that the Teapot movements are Time dependant and not Frame dependant.

Note:

Experience different frame rates using the time settings of the Time Setting window.

Right click on the Play button.

Exercise 10: Use a message to trigger a 3 second rotation

Subjects covered:

Messages

Sound

You will need:

Asset:

File TeapotPatch.nmo in VirtoolsResources\ 3DEntities\ Patch Primitives folder.

BBs:

BB Send Message and Wait Message in Logics\ Messages folder

BB Timer in Logics\ Loops folder.

BB Play Sound Instance in Sounds\ Basic folder.

Part1

Trigger a 3 seconds rotation on the cube and then play a sound.

Import a Teapot.

Create a script on the Teapot that waits for a message that will trigger a 3 seconds rotation.

Create a script on the Level that sends a message to the Teapot when the Space key is pressed.

Part2

Pass the value of the time to wait from the Level script to the Teapot script

Right click on the Send Message BB and select Construct\ Add Parameter Input.

The new input must be of type Time.

Get the value using the Get Message Data right after the Wait Message BB and pass the to the Timer parameter input.

Exercise 11: Perform Operation

Subject covered:

Op

Settings

You will need:

Asset:

File TeapotPatch.nmo in VirtoolsResources\ 3DEntities\ Patch Primitives folder.

BB:

BB Op in Logics\ Calculator folder.

Perform mathematical operations and get data from a Virtools Object

Use BB Op to calculate the equation a+b-c.

Use BB Op to get the position of the Teapot.

Use BB Op to get the diffuse color of the Teapot.

Exercise 12: Parameter Operation

Subjects covered:

Param Op

2d Interface

Text

You will need:

Assets:

SphereLowRes.nmo, SphereMediumRes.nmo, SphereHighRes.nmo from VirtoolsResources\ 3D Entities\ Primitives.

BBs:

BB Mouse Waiter and 2D Picking in Controller\ Mouse and Interface\ Screen folders.

BB Create System Font and 2D Text in Interface\ Fonts and Interface\ Text folders.

BB Op in Logics\ Calculator folder.

Get and display the number of faces of a picked object.

Part1

Pick an object onscreen

Import the 3 spheres objects from the VirtoolsResources.

On the Level, use Mouse Waiter BB to detect a mouse click.

Use 2D Picking BB to get the reference of the picked object.

Part2

Get face count of the picked object using Op BBs.

Part3

Display a text on screen

Add a 2DFrame object on screen.

Create a script on the 2DFrame object.

Use Create System Font BB to create a font.

Use 2DText BB to display the number of faces on screen.

Part4

Improve the scripts by replacing the Op BBs with Parameter Op BBs instead.

Exercise 12: Character Animation

Subject covered:

Character Animation

Attributes

Collision detection

You will need:

Assets:

File MagicalHouse.nmo in VirtoolsResources\ 3DEntities\ Worlds folder.

File Eva.nmo in VirtoolsResources\ Characters\ Skin Characters folder.

File Run.nmo, Walk.nmo, WalkBckWd.nmo and Wait.nmo in VirtoolsResources\ Characters\ Animations\ Skin Character Animations \Eva folder.

BBs:

BB Character Controller from VirtoolsResources\ Characters\ Movement folder.

BB Keyboard Controller or Keyboard Mapper in Controllers\ Keyboard folder.

BB Character Keep On Floor from VirtoolsResources\ Characters\ Constraint folder.

Part1

Control script of the character.

Use BB Character Controller to select the 4 basic animations.

Use BB Keyboard Controller (or BB Keyboard Mapper) to map the keys to the messages used by the character animations.

Use the BB Character Keep On Floor to keep the character on the floor.

The Floor attribute should be attached to the floor object.

Part2

Add collision detection.

Create a group of objects for the collision detection, i.e. walls and trees

Use the BB Object Slider on Eva to apply collision detection to Eva.

Part3

Add a third person camera.

Create a third person camera using BB Mimic. (see exercise number 7)

Note: Parent the referential object tracked by the Mimic to the FloorRef object in the hierarchy of the character or it will not work properly.

Use BB Object Slider on the camera to apply collision detection on the camera.

Exercise 13: Use one generic script to rotate many objects

Subject covered:

Group

Buttons

Dynamic Loading

Arrays

Externalize data in a text file

You will need:

Assets:

File Cube.nmo, Prism.nmo and Pyramid.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BBs:

BB Rotate in 3D Transformation\ Basic folder.

BB Group Iterator in Logics\ Groups folder.

BB PushButton in Interface\ Controls folder.

Part 1: Dynamic Loading

Import the objects.

Create a group containing every object.

Use BB Group Iterator and Rotate to apply a rotation to every object of the group in a loop

Use BB PushButton to create a button to trigger the rotation script.

Part 2: Dynamic Loading

Save the cube object with its script as My Cube.nmo and delete the original cube from the composition (use Full Dependencies option).

Use the BB Object Load to dynamically load your cube at initialisation.

Part 3: Dynamically load a list of objects using an array of file names

Create an array with a column of strings.

Type in the list of the file names of the object to load, one file name at every line.

Create a script to parse the array using BB Iterator, get the file name string from the pOut of the BB Iterator, and use the file name to load the object using the BB Object Load.

Part 4: Externalize the object list in a text file

Use BB Array Save to save your array data in a text file on your hard drive.

Use the BB Clear Array to clear the array.

The array should keep the same structure but without the data.

Use the BB Array Load to load the data from the text file into the array.

Exercise 14: Dynamic Loading and copy of Objects

Subject covered:

Dynamic Copy

You will need:

Assets:

File Cube.nmo, Prism.nmo and Pyramid.nmo in VirtoolsResources\ 3DEntities\ Primitives folder.

BBs:

BB Object Copy in Narratives\ Object Management folder.

BB Object Load in Narratives\ Object Management folder.

BB Iterator in Logics\ Array folder.

BB Array Save in Logics\ Array folder.

BB Clear Array in Logics\ Array folder.

BB Array Load in Logics\ Array folder.

Part 1: Dynamic Copy

Create a curve.

Create a script to copy and place 10 instances of the cube every 10 % of the curve.

Part 2: Advanced Dynamic Copy

Add a script to the original cube to apply a 5 second rotation on the cube when clicked with the mouse.

Change the copy parameters of the BB Object Copy to copy the cube with its script.

Exercise 15

Subject: Activate and Execute scripts

Composition: Structuration of the previous composition

Create a script on the Level called “Scenario”

Set the script Activate at Scene Start to True.

Break your previous scripts in subscripts by task

Use Execute and Activate BB to execute these tasks in the right order.

Test the activation order of your scripts using the Step One Frame runtime button.

Note: coloring the script could help organizing and sorting the scripts in the Schematic programming environment.

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: