Mouse input data, such as the mouse's position and the status of its buttons, are used in most computer games. 3D shooters, real time strategy games, and the like use this information to tell if the user is firing the weapon, clicking a certain unit, or selecting a part of the graphical user interface. However, whatever its use, this data can be used in most Truevision 3D projects for debugging purposes. Below is highlighted two steps on how to retrieve mouse data using Truevision 3D.
Step One - Input Device
An instance of the TVInputEngine is required to read user input in Truevision 3D projects. Add this definition like so,
public TVInputEngine inputEngine;
And, initialize the input engine before the main loop,
// Initialize the Input Controls
inputEngine = new TVInputEngine();
inputEngine.Initialize(true, true);
Step Two - Reading Mouse Data
As with rendering, loading resources, etc. it is good to have a separate function for reading the user's input. Create a void called 'checkInput()' using the source code supplied below.
private void checkInput()
{
// Data Holders
int aX = 0;
int aY = 0;
bool bBut1 = false;
bool bBut2 = false;
bool bBut3 = false;
// Read the Mouse Data
inputEngine.GetMouseState(ref aX, ref aY, ref bBut1, ref bBut2, ref bBut3);
// Add Code Here
}
Make sure to call the newly created 'checkInput()' method in your main loop for the variables ax, ay, bBut1, bBut2, and bBut3 to be constantly updated with the current status of the mouse.
Conclusion
In the input checking function, the mouse's data is stored into the aX, aY, bBut1, bBut2, and bBut3 variables. aX and aY contain the mouse's x(horizontal) and y(vertical) positions, respectively. The bBut1, bBut2, and bBut3 booleans contain the mouse's button status from button 1 through button 3. You could declare these variables globally if you would like to access them outside of the 'checkInput' function.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
- Logitech's MX1000 Laser Cordless Mouse Redefines What a Mouse Can BeIf you think the optical mouse is the best mouse for your computer, think again. With its high performance laser mouse, the Logitech MX1000 blows everything else out of the water.
- XHTML Common Input ControlsIn this article I give you the basics of common XHTML Input Controls.
- Evolution of PC Input DevicesA lot has changed over the past few decades and with computers getting more powerful, they can handle more data input and newer equipments and gadgets. Here's my view on how PC input devices evolved.
Gulf Oil Spill: NOAA's Analysis of Loop Current Oil Transport to Florida...The gulf loop current, and prevailing winds, are the sources of propulsion that have driven oil from the Deepwater Horizon BP spill in the gulf towards Florida. NOAA discusses t...- Real Estate Specializing: Triple Net Lease PropertyPrimary purpose for a Triple Net Lease (NNN) property, places responsibility to pay all property expenses upon the tenant or Lessor. This type of agreement is along term lease. Best suited for growth industries & econ...
- CSharp .Net Tutorial: Loading Textures in Truevision 3D
- Csharp.Net Tutorial: Drawing Sprites with Truevision 3D
- Csharp.net Tutorial: Drawing Particles with Truevision 3D
- Csharp.Net Tutorial: Basic Ray Collision Detection with Truevision 3D
- How Make Your Website More Dynamic by Allowing User Input to Impact Your Content
- Game Maker 8 Tutorial: Keyboard, Mouse and Joystick Input
- Is the Next Development for the iPhone Going to Be a Faster Way to Input Data?



