CSharp .Net Tutorial: Using Log Files in Truevision 3D

James Cloud
Introduction

Debugging projects can be very tedious and trying. This is the case even more so in a 3D environment. One must take into count the mathematical calculations of 3D space as well as those of 2D space. Truevision 3D contains a debugging system which outputs valuable information that helps developers to pin point and fix errors and adjust values until they are just proper.

In the steps below you will learn how to enable the debugging system and how to write data to the debug file.

Step One - Enable the Debug System

The first step involves enabling the debugging system and setting a file to output the debugging information to. To enable the debugging module, call the 'SetDebugMode()' function in the TVEngine object, using the proper parameters. You will also also need to set a file to output the debugging information, to do this, use the 'SetDebugFile()' and supply the path as the parameter. The code given below is a working example of how to enable the debugger and set an output path.

// Enable the Debug System
Engine.SetDebugMode(true, false);

// Set the Debug File
Engine.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\Editor.log");

The second parameter in the 'SetDebugMode()' function, if set to true, will also write the debugging information to the console. This will allow you to view the output without accessing the debug file.

Step Two - Writing to the Log

Not only does the Truevision 3D debugging system output its own information, but it allows you to output string and variables to the debug file. Here is an example usage of the engine's 'AddToLog()' function,

Engine.AddToLog("Camera Position: " + Scene.GetCamera().GetPosition().x.ToString() + ", " + Scene.GetCamera().GetPosition().y.ToString() + ", " + Scene.GetCamera().GetPosition().z.ToString());

The example source code given above will write the camera's position to the debug file. You can export any variable that can be converted into a string to the debug file.

Published by James Cloud

I like to program and do basically anything that has to do with technology and computers.  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.