Mouse EventsThis is a featured page


This sample shows mouse event scripts moving items within the scene.
MouseEvents.xpkg

Click on the image to download the sample.

Mouse Events - Blade3D
After importing the package, the scene contains two Cones, named Cone and Cone 1. Each of these cones act as rigid bodies in the scene. They also use the default floor plane collision graph (Floor Plane Collision Graph) which allows them to be influenced by gravity, yet not fall down infinitely. The script events are used to counteract against the gravity for these scene items. The floor plane collision graph looks like this:


Mouse Events - Blade3D

To execute the scripts, click on the cones in the scene. The OnMouseClick even script for each cone will cause the cone to jump up into the air. Cone has the following code on its OnMouseClick event:


context.Velocity += new Vector3(0,5,0);


This adjust its velocity so that it jumps straight up into the air. It also has a similar script on its OnMouseWheel event:


context.Velocity += new Vector3(0, 1.0f,0);


This means you could could keep the Cone in the air by scrolling the mouse wheel with it selected.

The second cone (Cone1) has this code on its OnMouseClick event:


context.Velocity += new Vector3(0,10,0);
context.AngularVelocity += new Vector3(0,10,0);

This script also adjusts the velocity so that it jumps into the air, thought this time a little higher. It also adjusts the AngularVelocity so that it spins arouund the Y axis as it jumps into the air.



X-Tatic
X-Tatic
Latest page update: made by X-Tatic , Jun 3 2007, 9:14 AM EDT (about this update About This Update X-Tatic Edited by X-Tatic


view changes

- complete history)
Keyword tags: None
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.