vrt · the vrt reference manual vrt virtual reality toolkit

212
The VRT reference manual VRT Virtual Reality Toolkit Version 1.5 Programmer’s Manual (2 nd Edition, September 1998) (3 rd Edition, February 1999) (4 th Edition, August 2000) (5 th Edition, August 2002) Copyright © 1998 - 2002 Stefan Seipel ([email protected]) Robin Stridh ([email protected]) Lukas Ahrenberg ([email protected]) Department of Information Science Division of Human-Computer Interaction University of Uppsala 1

Upload: others

Post on 27-Jan-2021

30 views

Category:

Documents


0 download

TRANSCRIPT

  • The VRT reference manual

    VRT Virtual Reality Toolkit

    Version 1.5

    Programmer’s Manual

    (2nd Edition, September 1998)

    (3rd Edition, February 1999) (4th Edition, August 2000) (5th Edition, August 2002) Copyright © 1998 - 2002

    Stefan Seipel ([email protected]) Robin Stridh ([email protected])

    Lukas Ahrenberg ([email protected])

    Department of Information Science Division of Human-Computer Interaction

    University of Uppsala

    1

  • 2

  • Introduction The Virtual Reality Toolkit (VRT) is a graphics library for 3D modeling and simulation. It was designed for use on the Win32 architecture Windows platforms. The VRT exports a number of C functions that together with the VRT datatypes make up the VRT API. This document contains an introduction to modeling and simulation as well as a complete VRT API function and data types reference. Background Tool-driven modeling Modeling and simulation of three-dimensional worlds are complex. By using tools that aid in keeping track of details, the modeler is able to focus his efforts on the important main issues of composition of the world and direction of the simulation. VRT was designed as such a tool. A collection of real-world natural language concepts is used in the VRT interface to let the modeler interact with the simulation in a concise and straight-forward way. This also hides the specific details of how things are actually carried out. For example, the concepts of Scene and Camera are used to encapsulate the behavior of the world and our view upon it, things that have quite complex inner machinery when it comes to implementing them on a computer graphics system. As such, they shouldn’t concern the modeler. Using the VRT Basic 3D modeling concepts and terminology is used throughout the VRT programming interface. Familiarity with these terms are a prerequisite for successful use of VRT. A basic understanding of event-driven programming under the Win32 API is assumed. However, VRT will require a very small portion of actual Win32 API programming to produce a working simulation. VRT modeling and simulation In VRT, objects are created and added to a lighted scene and a camera gives a view of the scene from a particular viewpoint. A three-dimensional coordinate system is used to refer to positions in the scene. In order to create a simulation, the objects in the scene are made to interact while the camera gives a continous view of the scene. The interface is transparent, allowing use of native OpenGL functions in VRT applications. Where available, VRT will take advantage of hardware assisted graphics acceleration. The VRT offers use of non-traditional 3D display modes, e g stereoscopic, Workbench and Virtual Plane display modes. The Scene The scene is where the simulation takes place. Initially, the scene is lighted but empty. As objects are added, they show up on the screen. The scene has a three-dimensional coordinate system with axes, x, y and z, who relate to width, height and depth, respectively. The x-axis goes from left towards the right, the y-axis from down upwards, and the z-axis goes from behind the screen towards the viewer. This is

    VRT Programmer’s Manual - 3

  • called a right hand coordinate system, because you can use your right hand to form the x, y and z-axes with your thumb, index finger and middle finger.

    Figure 1: Scene, Camera and Light

    The scene coordinate system is used to refer to positions in the scene. Objects in the scene are placed and arranged using this coordinate system. The Camera The camera defines the current view of the scene. The properties of the camera are position and orientation, where the position is defined as a point in the scene and the orientation is defined as a point in the scene and a direction. The point is the position the camera is looking at, and the direction is the direction in which the top of the camera is facing.

    Look-at

    Up

    Position

    Figure 2: Properties of the Camera

    4

  • 3D points and directions A point is a triplet of coordinates, for example (0.0, 0.0, 0.0) for the scene origo and (0.0, 1.0, -1.0) for a position slightly above and behind the scene origo. A direction, or vector, is also a triplet, representing the relative amounts of the x-, y- and z-axis making up the direction. For example, a direction from left to right is (1.0, 0.0, 0.0) and a direction upwards and towards the left in a 45 degree angle is (-1.0, 1.0, 0.0). A way to visualize a direction triplet is to imagine a line drawn from origo to the point specified by the triplet. This line points in the direction represented by the triplet. Transformations All moving and positioning of objects in the scene are accomplished by performing transformations of the objects. The three kinds of transformation are translation (moving along the axes), rotation (rotation around the axes) and scaling (scaling of the object dimensions along the axes).

    Figure 3: Translation, scaling and rotation

    Combinations of translation, rotation and scaling can be used to achieve any desirable positioning of an object. The Scene-graph, Nodes and Geometries When complex objects are modeled by adding several components together, it is often desirable to be able to manipulate the components as well as the complex object as a whole. This is called hierarchical modeling. In hierarchical modeling, the relationships between objects in the scene can become quite complex. In VRT, a scene-graph is used to manage these relationships. The actual appearance of an object in the scene is determined by a geometry. A geometry represents the physical shape of an object in the scene. When an object is to be added to the scene, a new scene-graph node is created. This new node is used to represent the object’s relation to other objects in the scene. A parent node is supplied when a new node is created, reflecting a parent-child relationship in the object hierarchy. The node is added to the scene-graph on creation. To connect the new node to a physical appearance in the scene, the node is connected to a geometry. When a node is connected to a geometry it appears in the scene.

    5

  • Root

    Child 1 Child 2 Child 3

    Child 1BChild 1A

    Geometry

    Geometry

    Geometry

    Figure 4: The Scene-graph

    A geometry is not tied to a particular node, but can be shared by several nodes. That is, several objects in the scene can have the same physical appearance. Arranging the scene Manipulating the objects in the scene is accomplished by applying transformations to the nodes of the scene-graph. Note that the geometries themselves are not affected in any way, as they are node-independent. The fact that a node is a parent to another node has several implications. Most important of all, all transformations to a node affects all it’s children. This is where the hierarchical modeling really comes to it’s use. By applying a single transformation to the parent node, all children are transformed as well. Another implication of parentship is that when a node is switched off (made invisible), all it’s children are switched off as well. When an object is added to the scene, it is has no transformations applied to it. This means that the size and position properties of the node’s geometry will decide where in the scene the object shows up. The structure of a VRT program All VRT program must include a Win32 API WinMain function. Within it the code for initializing the library and setting simulation parameters is put, along with scene building code. Simulation parameters include display mode, initial camera position and callback function definition. The callback function is a user-defined function that is called repeatedly during the execution of the program. This is where code for handling keyboard and mouse events is put along with code for any non-interactive actions that is to occur in the simulation.

    6

  • 1. Open the library: Before any VRT functions can be called the library has to be opened. This is done by calling VRT_Init, passing along the application instance parameter from the WinMain parameters. After this, any VRT functions are available for use.

    2. Set the display mode: VRT supports a number of display modes, including traditional monoscopic display, stereoscopic display, Workbench and Virtual Plane display modes. The display mode is set with a call to a VRT_SetDisplayMode, passing along the desired display mode. 3. Set the callback function: A user-defined callback function is optionally specified with the VRT_SetCallback function, passing along the name of the callback function. Upon entering the simulation loop, the specified callback function will be called repeatedly during the simulation. This function will define the interactive as well as non-interactive behavior of the simulation. It is here the main simulation programming goes. 4. Build the scene: The scene is set up by specifying a background color and adding the objects that are to be in the scene initially. 5. Run the simulation: The simulation loop is entered by calling VRT_SimulationLoop. 6. Close the library: Upon exiting the simulation loop, the VRT library is closed and the program is terminated. A small example program: The PLG Viewer The PLG format is a simple ASCII file format for storing geometry data. A PLG file holds the vertices and polygons of a geometry. Here is a small example of a VRT application that loads an object from a PLG file and displays it on the screen, allowing simple manipulation of the object as well as toggling between different shading models. Here is a small step-by-step guide to the PLG Viewer application: The WinMain function First, we define the WinMain function like this:

    /* * The main entry point of the application, WinMain */ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ if (hPrevInstance) return 0; /* Initiate the VRT */

    7

  • VRT_Init(hInstance); /* Set display mode to default monoscopic display */ VRT_SetDisplay(hInstance, VRT_DEFAULT); /* Set up the scene */ BuildScene(); /* Register the callback function */ VRT_SetCallback((VRT_HookPtr)SimulationLoop); /* Set the background color */ VRT_SetClearColor(0.0, 0.0, 0.0, 1.0); /* Enter the simulation loop */ VRT_SimulationLoop(); /* Close the VRT */ VRT_Close(); /* Exit gracefully */ return TRUE; } First, if hPrevInstance is not null, there is another instance of VRT running, and we terminate the program. Then a call to VRT_Init is done, to initiate VRT. The display is set to the default mode, which is monoscopic display with a standard viewing projection. After this, we set up the scene contents by a call to BuildScene, a small helper function that loads geometries and attaches them to nodes in the scene-graph. We will look into the code for BuildScene further down. Our callback function, SimulationLoop, are registered by a call to VRT_SetCallback. We will look into the code for the callback function further down. A background color of black is set with a call to VRT_SetClearColor. Now we are all set up to go. We enter the simulation loop by calling VRT_SimulationLoop. VRT will run the simulation, periodically calling our callback function to perform control of the simulation. When the running application is terminated, we return from the simulation loop. VRT is then closed with a call to VRT_Close, and we return from WinMain with a non-zero value to indicate that our application terminated in an orderly fashion. Setting up the scene with BuildScene Our scene-building function, BuildScene, along with the global declarations and includes, looks like this: #include "VRT.h" #define PLG_FILENAME "..\\Data\\PLG\\Submarine.plg" /* Global variables */

    8

  • /* A geometry to add PLG file data to */ VRT_Geometry *geometry; /* A scene-graph node to connect the geometry to */ VRT_Node *node; /* * Set up the scene */ void BuildScene() {

    /* Create a geometry by loading data from a PLG file */ geometry = VRT_LoadPLG(PLG_FILENAME);

    /* Calculate normals for the geometry vertices to be able to use smooth shading */ VRT_GeometryCalcVertexNormals(geometry);

    /* Set the color of the geometry to blue grey*/ VRT_GeometrySetColor(geometry, 64, 64, 90, 255);

    /* Normalize the geometry dimensions */ VRT_GeometryNormalize(geometry);

    /* Create a new node and attach it to the root node */ node = VRT_NodeNew(vrtctx->root, "Node");

    /* Connect the geometry to the node */ VRT_NodeSetGeometry(node, geometry);

    /* Position the camera in front of and pointing towards the origo*/ VRT_SetDefaultCamera(0, 0, 2, 0, 0, 0, 0, 1.0, 0.0);

    } Two global variables for holding the geometry and node for our loaded object, geometry and node, are declared. In the code for BuildScene, the geometry is loaded and assigned to geometry by a call to VRT_LoadPLG, passing along the name of the PLG file. As only vertices and simple polygon information are saved in the PLG file format, vertex normals have to be generated for us to be able to use smooth shading. This is done by a call to VRT_CalcVertexNormal, passing along the geometry. The color of the newly loaded geometry is set with a call to VRT_GeometrySetColor. Since at this stage we do not know anything about the geometry’s position in the scene (it might end up anywhere), we make sure the geometry is scaled accordingly and translated to the origin with a call to VRT_GeometryNormalize. This way we will be sure to be able to find the object in the scene later on. Then a new node is created, specifying the root node is the parent. The root node is a permanent node and cannot be changed or manipulated in any way. For non-hierarchical objects, all nodes are assigned to root node as parent. A call to

    9

  • VRT_NodeNew is made, passing along root as the parent and a string representation of the node, in our case just “node”. Now the geometry is connected to our node with a call to VRT_NodeSetGeometry, passing along the node and the geometry. From here on, an object with the physical appearance specified by the geometry will appear in the scene. We position the camera at two units in front of the scene origin. A normalized object will fill the most of our view from this point. We specify a look-at point at (0, 0, 0), the origin, and an up vector of (0, 1, 0), straight up. The next stage is defining the callback function. The callback function SimulationLoop The code for the callback function looks like this: /* * The callback function */ static VRT_HookPtr SimulationLoop(MSG msg) { /* Variable for holding shading model */ int shadingmodel; // handle WINAPI messages switch (msg.message) { case WM_KEYDOWN: { switch (msg.wParam) { case VK_UP: { /* Rotate the node 10 degrees around the x-axis, towards the viewer */ VRT_NodeRotate(node, -5, 0, 0); break; } case VK_DOWN: { /* Rotate the node 10 degrees around the x-axis, away from the viewer */ VRT_NodeRotate(node, 5, 0, 0); break; } case VK_LEFT: { /* Rotate the node 10 degrees around the y-axis, clockwise from the viewers perspective */ VRT_NodeRotate(node, 0, 5, 0); break; } case VK_RIGHT: { /* Rotate the node 10 degrees around the y-axis, counter-clockwise from the viewers perspective */ VRT_NodeRotate(node, 0, -5, 0); break; } case 'R': { /* Reset all rotations */

    10

  • VRT_NodeSetRotation(node, 0, 0, 0); break; } case 'S': { /* Toggle shading model between smooth and wire model */ VRT_GeometryGetShadingModel(geometry, &shadingmodel); if (shadingmodel == VRT_SM_WIRE) VRT_GeometrySetShadingModel(geometry, VRT_SM_SHADE); else VRT_GeometrySetShadingModel(geometry, VRT_SM_WIRE); break; } default: break; } } } return NULL; } We want to able to change the shading model of our loaded object, so a variable shadingmodel is declared for holding the shading model of the geometry. Next, the message field of the msg variable is switched. In the case of a WM_KEYDOWN event, the field msg.wParam is switched to check which key was pressed. In the case of an arrow key being pressed, the node of the loaded object is rotated with a call to VRT_NodeRotate, passing along the global variable node. In the case of ‘R’ (Reset), the rotation of the node is reset to none with VRT_NodeSetRotation. If an ‘S’ (Shading) is pressed, the shading model of the geometry is to be toggled from smooth to wire-frame shading model, or vice versa. To find out the current shading model of the geometry a call to VRT_GeometryGetShadingModel is made, saving the result in the previously declared variable shadingmodel. Depending on the current shading model of the geometry a new shading model is set with a call to VRT_GeometrySetShadingModel. If none of these keys were pressed, the keypress is ignored. That was it! We have a running simulation. Here is the full code listing for the PLG Viewer application: #include "VRT.h" #define PLG_FILENAME "..\\Data\\PLG\\Submarine.plg" /* Global variables */ /* A geometry to add PLG file data to */ VRT_Geometry *geometry; /* A scene-graph node to connect the geometry to */ VRT_Node *node;

    11

  • /* * Set up the scene */ void BuildScene() { /* Create a geometry by loading data from a PLG file */ geometry = VRT_LoadPLG(PLG_FILENAME); /* Calculate normals for the geometry vertices to be able to use smooth shading */ VRT_GeometryCalcVertexNormals(geometry); /* Enable smooth shading*/ VRT_GeometrySetShadingModel(geometry, VRT_SM_SHADE); /* Set the color of the geometry to blue grey*/ VRT_GeometrySetColor(geometry, 64, 64, 90); /* Normalize the geometry dimensions */ VRT_GeometryNormalize(geometry); /* Create a new node and attach it to the root node */ node = VRT_NodeNew(root, "Node"); /* Connect the geometry to the node */ VRT_NodeSetGeometry(node, geometry); /* Position the camera in front of and pointing towards the origo*/ VRT_SetDefaultCamera(0, 0, 2, 0, 0, 0, 0, 1.0, 0.0); } /* * The callback function */ static VRT_HookPtr SimulationLoop(MSG msg) { /* Variable for holding shading model */ int shadingmodel; // handle WINAPI messages switch (msg.message) { case WM_KEYDOWN: { switch (msg.wParam) { case VK_UP: { /* Rotate the node 10 degrees around the x-axis, towards the viewer */ VRT_NodeRotate(node, -5, 0, 0); break; case VK_DOWN: {

    12

  • /* Rotate the node 10 degrees around the x-axis, away from the viewer */ VRT_NodeRotate(node, 5, 0, 0); break; } case VK_LEFT: { /* Rotate the node 10 degrees around the y-axis, clockwise from the viewers perspective */ VRT_NodeRotate(node, 0, 5, 0); break; } case VK_RIGHT: { /* Rotate the node 10 degrees around the y-axis, counter-clockwise from the viewers perspective */ VRT_NodeRotate(node, 0, -5, 0); break; } case 'R': { /* Reset all rotations */ VRT_NodeSetRotation(node, 0, 0, 0); break; } case 'S': { /* Toggle shading model between smooth and wire model */ VRT_GeometryGetShadingModel(VRT_NodeGetGeometry(node), &shadingmodel); if (shadingmodel == VRT_SM_WIRE) VRT_GeometrySetShadingModel(VRT_NodeGetGeometry(node), VRT_SM_SHADE); else VRT_GeometrySetShadingModel(VRT_NodeGetGeometry(node), VRT_SM_WIRE); break; } default: break; } } } return NULL; } /* * The main entry point of the application, WinMain */ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ if (hPrevInstance) return 0; /* Initiate the VRT */ VRT_Init(hInstance);

    13

  • /* Set display mode to default monoscopic display */ VRT_SetDisplay(hInstance, VRT_DEFAULT); /* Set up the scene */ BuildScene(); /* Register the callback function */ VRT_SetCallback((VRT_HookPtr)SimulationLoop); /* Set the background color */ VRT_SetClearColor(0.0, 0.0, 0.0, 1.0); /* Enter the simulation loop */ VRT_SimulationLoop(); /* Close the VRT */ VRT_Close(); /* Exit gracefully */ return TRUE; }

    14

  • Data types Public and opaque types There are two main categories of data types in VRT: public and opaque data types. Public types are those that have an open structure and can be manipulated by the user using standard C primitives. For example, a field of the public data type VRT_Vertex can be set directly:

    VRT_Vertex vertex; vertex.x = 0.0;

    Opaque data types should only be manipulated via the VRT API functions. For example, an instance of the opaque data type VRT_Geometry is created via a call to VRT_GeometryNew(): VRT_Geometry *geometry; geometry = VRT_GeometryNew(); Most opaque types use reference semantics, which means a pointer is used to refer to an instance of the type. Some use copy semantics and some are a mix of the two. Constants and restrictions Certain restrictions are imposed on a number of VRT features: Maximum number of vertices in a polygon is 4

    Maximum number of children of a node is 256 Maximum number of nodes in the scene-graph is 1024 Maximum depth of the scene-graph is 64 Maximum number of lights is 32 Maximuim number of simultaneous lights is 8 Maximum number of geometries is 1024

    VRT Programmer’s Manual - 3

  • Public types Enumerated types Error codes Improper usage of the VRT generates error codes that are printed to the VRT console window: 99 VRT_ERR_NOINIT VRT is not initialized when a function is called. 100 VRT_ERR_NODELISTOVERFLOW Maximum number of nodes reached. 101 VRT_ERR_PARENTISNULL Invalid node parent specified. 102 VRT_ERR_DELETENULLNODE Trying to delete a deleted or non-initialized node. 103 VRT_ERR_DELETEINVALIDNODE Trying to delete an invalid node. 104 VRT_ERR_DELETEROOTNODE Trying to delete the root node. 105 VRT_ERR_TRANSLATENULLNODE Trying to translate a deleted or non-initialized node. 106 VRT_ERR_TRANSLATEROOTNODE Trying to translate the root node. 107 VRT_ERR_TRANSLATEINVALIDNODE Trying to translate an invalid node. 108 VRT_ERR_ROTATENULLNODE Trying to rotate a deleted or non-initialized node. 109 VRT_ERR_ROTATEROOTNODE Trying to rotate the root node. 110 VRT_ERR_ROTATEINVALIDNODE Trying to rotate an invalid node. 111 VRT_ERR_INVALIDNODE Trying to use an invalid node. 112 VRT_ERR_GEOMETRYLISTOVERFLOW Reached maximum number of geometries. 113 VRT_ERR_GEOMETRYINVALID Trying to use an invalid geometry. 114 VRT_ERR_GEOMETRYISNULL Trying to use a deleted or non-initialized geometry. 115 VRT_ERR_REALLOCVERTEXLISTFAILED Vertex couldn't be added to geometry because of low memory. 116 VRT_ERR_INVALIDVERTEXINDEX Trying to use an invalid vertex index. 117 VRT_ERR_REALLOCPOLYGONLISTFAILED Polygon couldn't be added to geometry because of low memory. 118 VRT_ERR_POLYGONISNULL Trying to use a deleted or non-initialized polygon. 119 VRT_ERR_INVALIDPOLYGONHANDLE

    16

  • Trying to use an invalid polygon handle. 120 VRT_ERR_NODEPATHOVERFLOW Maximum depth of scene-graph reached. 121 VRT_ERR_NODEPATHISNULL Trying to use an empty nodepath. 122 VRT_ERR_TEXTUREFILEOPEN Trying to read a texture bitmap file that is opened by another application. 123 VRT_ERR_TEXTUREFILEWRONGCOLORFORMAT Trying to use a texture bitmap file that has a non-supported color format. 124 VRT_ERR_TEXTUREINVALID Trying to use a invalid texture. 125 VRT_ERR_GEOMETRYISLOCKED Trying to change a locked geometry. 126 VRT_ERR_CHILDLISTOVERFLOW Maximum number of node children reached. 127 VRT_ERR_CHILDISNULL A NULL-node was attempted to be attached to a parent node. 128 VRT_ERR_TEXTUREINVALIDMODE An invalid texture modulation mode was specified. Error created by function VRT_SetTextureModulationMode. 129 VRT_ERR_FOPEN_SAVE File I/O error occurred in saving operation. 130 VRT_ERR_INTERSECTNULLNODE NULL node passed to intersection function. 131 VRT_ERR_INTERSECTROOTNODE Root node illegaly passed to intersection function. 132 VRT_ERR_SUBTEXTURE_OUT_OF_BOUND Tried to perform an operation outside of subtexture bounds. 150 VRT_ERR_LIGHTLISTOVERFLOW Too many lights are being created. Limit of VRT_LIGHTLIST_MAXLIGHTS = 32 reached. 151 VRT_ERR_LIGHTISNULL NULL pointer passed as light handle to light function. 152 VRT_ERR_LIGHTINVALID Pointer passed to light function refers not a valid light object. 153 VRT_ERR_TOOMANYLIGHTS There are more than MAX_GL_LIGHTS lights activated at the same time. 154 VRT_ERR_LIGHTINVALIDTYPE Unknown light type passed to light function. 170 VRT_ERR_PROJECTORLISTOVERFLOW Could not add projector, the maximum number of projectors/cameras (VRT_PROJECTORLIST_MAXPROJECTORS) has been reached. 171 VRT_ERR_CAMERAISNULL Tried to perform a camera opoeration on a NULL camera reference. 172 VRT_ERR_CAMERAINVALID Tried to perform an operation on a camera not in the list of projectors. 173 VRT_ERR_CAMERAINVALIDFOV Tried to set camera field of view to a negative value. 174 VRT_ERR_CAMERAINVALIDCLIP Tried to set invalid parameters of camera clippingplanes. 175 VRT_ERR_CAMERANODEISNULL

    17

  • Tried to attach a NULL valued camera to a node. 180 VRT_ERR_WOWISNULL Tried to perform an operation on a non existent (unallocated, pointer is NULL) WoW projector. 181 VRT_ERR_WOWINVALID Tried to perform an operation on an invalid WoW projector. 182 VRT_ERR_WOWINVALIDCLIP The WoW clippingplane distances are wrong. E.g. near param greater than far param. 183 VRT_ERR_WOWNODEISNULL Either the eye or the window node parameters to a WoW function is null-valued. 190 VRT_ERR_PIPELISTOVERFLOW Could not add pipe, the maximum number of pipes (VRT_PIPELIST_MAXPIPES) has been reached. 191 VRT_ERR_PIPEISNULL Tried to perform a pipe opoeration on a NULL pipe reference. 192 VRT_ERR_PIPEINVALID Tried to perform an operation on a pipe not in the list of pipes. 193 VRT_ERR_PROJECTORISNULL Tried to connect a NULL projector to a pipe. 194 VRT_ERR_PIPEINVALIDPARAMS Tried to set invalid viewport parameters to a pipe. 195 VRT_ERR_PIPEINVALIDINDEX Tried to retrive an nonexistent pipe from the pipelist. 500 VRT_ERR_NODEISNOTSHAREDNODE Tried to use a regulare node as a networked shared node. 501 VRT_ERR_SHAREDMEMORYNOINIT Tried to use networked, shared nodes withoud initializing the shared memory. 600 VRT_ERR_ANIMATIONLISTOVERFLOW There are more then VRT_ANIMLIST_MAXANIMS animations created. 601 VRT_ERR_ANIMATIONINVALID Tried to process an invalid animation. 602 VRT_ERR_ANIMATIONISNULL The animation object processed is null. 603 VRT_ERR_REALLOCANIMKNOTLISTFAILED Could not resize the animknot list. Memory allocation error. Display modes VRT can be set to run in a number of display modes:

    Display mode Description

    18

  • VRT_MONO Standard monoscopic rendering VRT_STEREO Quad-buffered stereo with active

    shutters using a normal stereo capable monitor

    VRT_STEREO_VSPLIT Double-buffered rendering using stereo with vertically split display and sync-doubler unit

    VRT_STEREO_HSPLIT Stereo, horizontally split display using mirror arrangement (CyberHook)

    VRT_VIP Virtual Plane using quad-buffered stereo rendering system

    VRT_VIP_SPLIT Virtual Plane using double-buffered stereo with sync-doubler unit (requires split screen stereo rendering)

    VRT_VMIRROR Vertically mirrored picture on screen VRT_WORKBENCH Using quad-buffered stereo rendering

    with vertically mirrored output for use with VirtualWorkbench/ReachIn

    VRT_DEFAULT Default mode Shading models Polygons and geometries are rendered using one of several shading models:

    Shading model Description VRT_SM_WIRE Points are connected with lines VRT_SM_FLAT Polygon faces are shaded in one color VRT_SM_SHADE Polygon faces are shaded smoothly if

    normal vectors are supplied for vertices. Material properties work only correct in this shading mode.

    VRT_SM_TEXTURE Textures are applied. Observe that texture u/v coordinated must be supplied for the vertices to yield correct results. Remark: In VRT, a black texel value of RGB=(0,0,0) will cause the corresponding fragment not to be rendered i.e. the scene behind that fragment will remain visible and z-buffer is not affected. This is in particular useful if fine structures are supposed to be modeled using masked textures. If black texels are desired the a RGB value of RGB = (1,1,1) should be used.

    19

  • Illumination models Lighting calculations in VRT can be performed in two different ways, which is controlled by a global light model state variable. By default, a global light model is being used for lighting calculations.

    LightModel Description VRT_GLOBAL_LIGHT_MODEL Lighting calculations are based

    upon the direction of light in relation to the orientation of the object surface. Calculations are based upon the global co-ordinate system.

    VRT_LOCAL_LIGHT_MODEL Lighting calculations are based upon the direction of light in relation to the orientation of the object surface and the observer’s position. Calculations are based upon the varying viewing co-ordinate system of the local observer.

    20

  • Structure types Vertex A vertex is a point in the three-dimensional space, defined by x, y and z-coordinates. When using smooth shading for a polygon, a normal is calculated for the vertex and used for creating smooth shading across the surface and edges of a polygon. When using flat shading, a single polygon face normal is used for all vertices in a polygon. When applying textures to polygons, each vertex in the polygon is assigned a u and v value, ranging from 0 to 1, representing relative texture coordinates. A vertex is defined as follows:

    typedef struct VRT_Vertextag { float x, y, z, nx, ny, nz, u, v; } VRT_Vertex;

    NodePath A nodepath is a description of a node’s relationship to the root node in the scene-graph. It is a list of all the parents of the node. It is defined as follows:

    typedef struct _nodepath { int depth; VRT_Node *nodes[VRT_NODEPATH_MAXDEPTH]; } VRT_NodePath;

    Opaque types Polygon A polygon is a collection of vertices connected to create a two-dimensional figure. Examples of polygon are triangles and quadrilaterals. Polygons have color, texture and shading model properties that can be set by the user. A handle to a polygon is used when manipulating polygons. Geometry The geometry represents the physical appearance of objects in the scene. A geometry consist of a collection of polygons and a number of surfaces properties. To create a geometry, an empty geometry is first created. Then a number of vertices are added to the geometry. By specifying their vertices, polygons are finally added to the geometry. VRT supports four kinds of polygons: triangles, quads, triangle strips and triangle fans. Triangles and quads are defines by specifying the vertices in a counter-clockwise order. A geometry holds bounding box information, which is an estimation of the space a geometry occupies. It is a box with a width, height and depth of the maximum width, height and depth of the geometry, and fitted to completely surround the geometry. A bounding box is defined by two points in space, lower left, inner point and upper right, outer of the eight points making up the box, and with left to right, lower to upper and inner to outer here defined as the positive x, y, and z vectors. A bounding box of width 2, height 2 and depth 2 could be for example:

    21

  • (-1, -1, -1), (1, 1, 1)

    A geometry has a color and a shading model. The color and shading model of a geometry serves as the default color and shading model of polygons added to the geometry. When a polygon is added to a geometry, it’s face normal is calculated. Polygon face normals are used in the flat shading model. For smooth shading of the surface of the polygon, vertex normals need to be generated. This is not done automatically, as it is quite a costly operation. Generation of vertex normals are done with a call to VRT_GeometryCalcVertexNormals. Using the smooth shading model on a geometry without having calculated the vertex normals will result in. Node A node is a placeholder in the scene. Geometries are connected to nodes and thereby displayed in the scene. The nodes of the objects in the scene are organized in a hierarchical tree, the scene-graph. A node can have a number of children nodes, who in turn can have their own children. This makes it possible to build complex scenes with models made up of smaller parts while keeping their relationship simple and clean. Objects in the scene are manipulated by transforming the nodes they are connected to. A transformation of a node affects all nodes connected to it. A complex model made up of a number of child nodes can then be transformed as a whole just by transforming the parent node. This transformation is propagated along the node path when rendering the scene. A geometry can be connected to one or several nodes in the scene-graph. A shared geometry is displayed identically in the scene, save from transformations made to the connected nodes. Texture A texture is a bitmap that is applied onto the surface of a polygon. A texture can either be loaded from a Windows bitmap file (.BMP) or created by the user and then applied to a polygon.

    22

  • 23

  • Function reference

    23

  • 24

  • void VRT_AnimationAddPositionKnot (VRT_Animation * anim, float time, float x, float y, float z, float tension, float bias, float continuity)

    Add a position knot to an animation. This function adds a position knot to an animation. Parameters:

    anim The animation to add the knot to time The time, in seconds, where the knot is to be added x The knot's x y The knot's y z The knot's z tension The knot's tension bias The knot's bias continuity The knot's continuity

    See also: VRT_AnimationNew , VRT_AnimationAddRotationKnot , VRT_AnimationAddScaleKnot

    25

  • void VRT_AnimationAddRotationKnot (VRT_Animation * anim, float time, float angle, float x, float y, float z, float tension, float bias, float continuity)

    Add a rotation knot to an animation. This function adds a rotation knot to an animation. Parameters:

    anim The animation to add the knot to time The time, in seconds, where the knot is to be added angle Amount of degrees to rotate around the axis x X component of the rotation axis y Y component of the rotation axis z Z component of the rotation axis tension The knot's tension bias The knot's bias continuity The knot's continuity

    See also: VRT_AnimationNew , VRT_AnimationAddPositionKnot , VRT_AnimationAddScaleKnot

    26

  • void VRT_AnimationAddScaleKnot (VRT_Animation * anim, float time, float x, float y, float z, float tension, float bias, float continuity)

    Add a scale knot to an animation. This function adds a scale knot to an animation. Parameters:

    anim The animation to add the knot to time The time, in seconds, where the knot is to be added x The knot's scale factor along the x axis y The knot's scale factor along the y axis z The knot's scale factor along the z axis tension The knot's tension bias The knot's bias continuity The knot's continuity

    See also: VRT_AnimationNew , VRT_AnimationAddPositionKnot , VRT_AnimationAddRotationKnot

    27

  • void VRT_AnimationDelete (VRT_Animation * anim) Dispose an animation. This function deletes an animation. The animation is detached from any nodes it has been attached to. Parameters:

    anim The animation to be disposed See also:

    VRT_AnimationNew

    28

  • int VRT_AnimationGetMode (VRT_Animation * anim) Get the current time mode of an animation. This function retreives the current time mode of an animation. For a discussion on animation time modes, see the documentation for the VRT_AnimationGetMode function. Parameters:

    anim The animation See also:

    VRT_AnimationSetMode

    29

  • float VRT_AnimationGetTime (VRT_Animation * anim) Get the internal time counter of an animation. This function retreives the inte internal time counter of an animation. Parameters:

    anim The animation See also:

    VRT_AnimationSetTime

    30

  • int VRT_AnimationIsStarted (VRT_Animation * anim) Get the start/stop state of an animation. This function determines wheather an animation is currently started. Parameters:

    anim The animation Returns:

    Non zero if the animation is started, and zero is the animation is stopped. See also:

    VRT_AnimationStart , VRT_AnimationStop

    31

  • VRT_Animation* VRT_AnimationNew () Create a new animation. This function creates a new, empty animation with default properties. Returns:

    A pointer to an animation. See also:

    VRT_AnimationDelete

    32

  • void VRT_AnimationSetMode (VRT_Animation * anim, int mode) Set the time mode of an animation. This function sets the time mode of an animation. The time mode determines what should happen when the animation's internal time counter counts beyond the last knot of the animation. There are three different possible time modes: VRT_ANIMATION_ONCE The animation will stop. VRT_ANIMATION_REPEAT The animation will be restarted from the beginning. VRT_ANIMATION_PINGPONG The animation will be played backwards to the beginning, then restarted. The default mode is VRT_ANIMATION_REPEAT. Parameters:

    anim The animation mode Timing mode of the animation

    See also: VRT_AnimationGetMode

    33

  • void VRT_AnimationSetTime (VRT_Animation * anim, float t) Set the internal time counter of an animation. This function sets the current internat time counter of an animation. If the animation is started, i.e. with the function VRT_AnimationStart, this counter will be updated automatically so there is no need to use this function to make the animation run continously. Instead, use this function in the cases where it is necessary to explicitly jump to a different location, for example to restart the animation. Parameters:

    anim The animation t The new internal time counter

    See also: VRT_AnimationGetTime , VRT_AnimationStart

    34

  • void VRT_AnimationStart (VRT_Animation * anim) Start an animation. This function starts an animation, so that it's internal time counter will automatically be updated. A newly created animation will be started as default. Parameters:

    anim The animation See also:

    VRT_AnimationStop , VRT_AnimationIsStarted

    35

  • void VRT_AnimationStop (VRT_Animation * anim) Stop an animation. This function stop an animation, so that it's internal time counter will not be automatically updated. A newly created animation will be started as default. Parameters:

    anim The animation See also:

    VRT_AnimationStart , VRT_AnimationIsStarted

    36

  • VRT_Geometry* VRT_Arrow (float x) Create an arrow geometry. This function creates an simple arrow geometry, consisting of a cylinder and a cone, centered at the origin. Parameters:

    x The length of the arrow Returns:

    A pointer to an arrow geometry. See also:

    VRT_Box , VRT_Button , VRT_Cone , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    37

  • int VRT_AttachCameraToNode (VRT_Node * node) Attaches the camera to any node in the scene graph. In order to ease the animation of the scene camera, VRT allows to attach the camera to any node of the scene. Doing so, the camera viewing parameters are automatically updated as the node travels through the scene. Observe that the camera viewing direction is down the negative z-axis of the nodes reference frame, while the up-vector of the camera corresponds to the y-vector of the nodes reference frame. The field of view of the camera is independently controlled with the function VRT_SetCameraFieldOfView. A camera will remain attached to a node until VRT_AttachCameraToNode is called with NULL as a node parameter or until the application places the camera explicitly with a call to VRT_SetDefaultCamera. Parameters:

    node node to which camera is to be attached Returns:

    Zero on failure. See also:

    VRT_SetCameraFieldOfView , VRT_SetDefaultCamera , VRT_GetDefaultCamera

    38

  • VRT_Geometry* VRT_Box (float dx, float dy, float dz) Create a box geometry. This function creates a simple box geometry, centered at (dx/2, dy/2, dz/2). Parameters:

    dx width of the box dy height of the box dz depth of the box

    Returns: An pointer to a box geometry.

    See also: VRT_Arrow , VRT_Button , VRT_Cone , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    39

  • VRT_Geometry* VRT_BulbLock (float diameter, float height, int resolution) Creates a concave circular disc geometry shape. This function creates a disk shaped geometry with a convexity into the direction of the positive y-axis. Depending on the height parameter, the shape of the created geometry looks like a satellite dish. Parameters:

    diameter diameter of the disk height the height of the concave disc (i.e. convexity) resolution number of segments

    Returns: A pointer to the created geometry ot NULL if function failed.

    See also: VRT_Arrow , VRT_Box , VRT_Cone , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    40

  • VRT_Geometry* VRT_Button (float w, float h, float d, char * texturename) Create a button geometry. This function creates an object with the appearance of a standard GUI-button. A texture is applied to the top of the button. Parameters:

    w width of the button h height of the button d depth of the button. texturename name of texture to be applied to the button surface

    Returns: A pointer to a button geometry.

    See also: VRT_Arrow , VRT_Box , VRT_Cone , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    41

  • int VRT_CameraDelete (VRT_Camera * camera) Deletes a camera. Removes a camera from VRT, returning allocated memory. Parameters:

    camera pointer to the camera. Returns:

    Zero and a VRT error on failure.

    42

  • int VRT_CameraGetClipDistances (VRT_Camera * camera, float * nearparam, float * farparam) Retrievs the clippping plane distances. This function retrieves the clipping plane distances as coordinates on the camera view vector. Parameters:

    camera pointer to the camera to query. nerarparam float pointer to varaible for the near clipping parameter. farparam float pointer to varaible for the far clipping parameter.

    Returns: Zero and a VRT error on failure.

    See also: VRT_CameraSetClipDistance

    43

  • float VRT_CameraGetFOV (VRT_Camera * camera) Returns the field of view. This function is used to query a camera for the field of view. Parameters:

    camera the camera ti query. See also:

    VRT_CameraSetFOV

    44

  • VRT_Node* VRT_CameraGetNode (VRT_Camera * camera) returns the node a camera is attached to. If a the camera has been attached to a node, this node is returned. The default node is the root node. Parameters:

    camera the camera to query. Returns:

    the node the camera is attached to. See also:

    VRT_CameraSetNode

    45

  • VRT_Camera* VRT_CameraNew () Creates a new camera. Creates a new camera setting it's parameters to standard values. The following values are used: Field of view: 45 degrees. Near clipping plane: 1.0 . Far clipping plande: 10000.0 . Returns:

    A pointer to the new camera. See also:

    VRT_CameraDelete

    46

  • int VRT_CameraSetClipDistances (VRT_Camera * camera, float nearparam, float farparam) Sets near and far clipping planes. The near and far clipping planes of a camera descibes viewing distance of a camera. Everything closer to respectively further away than the clipping planes is not visible. The values represent coordinates on the viewing axis of the camera, the greater value the further away a plane is located. Naturally a far plane cannot be closer than the near. Parameters:

    camera a pointer to the camera. nearparam the position of the near clipping plane. farparam the position of the far clipping plane.

    Returns: Zero and a VRT error on failure.

    See also: VRT_CameraGetClipDistances

    47

  • int VRT_CameraSetFOV (VRT_Camera * camera, float fov) Sets the field of view. This function is used to set the field of view (in degrees) of a camera. Parameters:

    camera a pointer to the camera. fov the fiewl of view in degrees.

    Returns: Zero and a VRT error on failure.

    See also: VRT_CameraGetFOV , VRT_SetCameraFieldOfView

    48

  • int VRT_CameraSetNode (VRT_Camera * camera, VRT_Node * node) Attaches a camera to a node. This function is used to connect a camera to any node in the scene. The cameras rotation and position will then change with the node, so that the view-at and view-up vectors of the camera always is aligned with the negative z-axis and positive y-axis of the node reference frame respectivly. Parameters:

    camera The camera to attach. node The destination node.

    Returns: Zero and a VRT error on failure.

    See also: VRT_AttachCameraToNode;

    49

  • void VRT_CameraSetPreloadMatrix (VRT_Camera * camera, float * preload) Sets the preload matrix. This function ís used to set the preload matrix (the transforms before any view frustum operations in the matrix chain). Parameters:

    wow a pointer to the WoW projector. preload a 16 float array containing the 4x4 matrix.

    50

  • void VRT_Close () Close the VRT library. This function is called to close the VRT library. It frees up any resources allocated by the system during run-time. This includes any nodes as well as geometries remaining in the scene graph. See also:

    VRT_Init

    51

  • VRT_Geometry* VRT_Cone (float tr, float br, float height, int resolution) Create a cone geometry. This function creates a cone geometry centered at the origin. The sides of the cone is made up of triangles. The number of triangles used is determined by the resolution of the cone. The bottom of the cone is a polygon connecting to the bottom edges of the triangles. Parameters:

    tr radius of the cone at the top br radius of the cone at the bottom height height of the cone resolution number of sides in the cone

    Returns: A pointer to a cone geometry.

    See also: VRT_Arrow , VRT_Button , VRT_Box , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    52

  • VRT_Geometry* VRT_ConstantPipe (float radius, int resolution, int numsamples, float * controls) Create a pipe with constant radius along a central poly-line. This function creates a pipe shaped geometry with a circular crossectional shape. The pipes is generated along a central line which is defined by a number of control points in 3D space. The controls pointer must point to an array of at least 3 x numsamples coordinates in the format: x y z x y z x y z . Parameters:

    radius the radius of the pipe. resolution the number of segments around the curvature numsamples the number of control points of the central poly controls a pointer to an array of control points

    Returns: A pointer to a geometry.

    See also: VRT_ModulatedPipe , VRT_Box , VRT_Button , VRT_Cone , VRT_Cube , VRT_Flat , VRT_Plate , VRT_Pyramid

    53

  • VRT_Htx VRT_CreateRGBATexture (int sx, int sy, char * texels) Create a texture. This function creates a texture, given dimensions of the texture to be created and texel data. The texel data is a collection of color specifications on the RGBA form. That is, four values an the range of 0-255 (char type) indicating the red, green, blue and alpha components of a color. The texel data is an array of such tuples. Note: The current texture mode is affecting the type of texture created. Parameters:

    sx width of the texture sy height of the texture texels pointer to an array of texel data

    Returns: A texture.

    See also: VRT_LoadTexture , VRT_CreateRGBATexture , VRT_DeleteTexture , VRT_ReplaceRGBATexture , VRT_ReplaceRGBASubTexture , VRT_SetTextureModulationMode

    54

  • VRT_Geometry* VRT_Cube (float size) Create a cube geometry. This function creates a simple cube geometry, centered at the orgigin. Parameters:

    size size of the cone's sides Returns:

    A pointer to a cube geometry. See also:

    VRT_Arrow , VRT_Button , VRT_Box , VRT_Cone , VRT_Flat , VRT_Plate , VRT_Pyramid

    55

  • int VRT_DeleteNodePath (VRT_NodePath * np) Delete a nodepath. This function disposes a nodepath. Parameters:

    np a pointer to a nodepath Returns:

    Zero on failure. See also:

    NodeGetNodePath

    56

  • int VRT_DeleteTexture (VRT_Htx * texture) Delete a texture. This function deletes a texture. Parameters:

    texture a texture Returns:

    A VRT error code See also:

    VRT_LoadTexture , VRT_CreateRGBATexture , VRT_ReplaceRGBATexture , VRT_ReplaceRGBASubTexture

    57

  • void VRT_EnumeratePixelFormats () List available pixel formats. This function lists the available pixel formats on the particular system where VRT is running.

    58

  • void VRT_ExitSimulationLoop () Leave the VRT simulation loop from any point within the user program. This function can be used by the application programmer to terminate the simulation loop of VRT at any time of the simulation. After a call to this function, all actions defined within the user callback function will be finished. Upon return to the VRT simulation loop, the kernel will be cleaned up and terminate the system simulation loop without redrawing the scene. The user should issue an VRT_Close command after the call to VRT_SimulationLoop in the main program. See also:

    VRT_SimulationLoop , VRT_Close

    59

  • VRT_Geometry* VRT_Flat () Create a flat box geometry. This function creates a box geometry with width 2, height 0.4 and depth 3, centered at the origin. Returns:

    A pointer to a flat box geometry. See also:

    VRT_Arrow , VRT_Button , VRT_Box , VRT_Cone , VRT_Cube , VRT_Plate , VRT_Pyramid

    60

  • int VRT_GeometryAddVertex (VRT_Geometry * geom, float x, float y, float z, float nx, float ny, float nz, float u, float v)

    Add a vertex to a geometry. This function adds a vertex a geometry. The vertex is internally assigned an index in order of addition to the geometry. This index is used to refer to the vertex when polygons are added to the geometry. Parameters:

    geom a pointer to a geometry x vertex x component y vertex y component z vertex z component nx vertex normal x component ny vertex normal y compoent nz vertex normal z component u vertex texture u component v vertex texture v component

    Returns: a VRT error code.

    See also: VRT_GeometryGetVertex , VRT_GeometrySetVertex

    61

  • int VRT_GeometryCalculateBoundingSphere (VRT_Geometry * geom) Set the bounding sphere of a geometry. This function calculates the bounding sphere of a geometry, and stores the information in it. A geometry's bounding sphere is the smallest sphere containing the geometry. The function calculates the center of gravity and the maximum distance of all geometry vertices with regard to the local reference frame of the geometry. Since this is a time computing procedure, this function should be executed once after a geometry is not modified any longer. In order to retrieve the bounding spheres parameters, use the function VRT_GeometryGetBoundingSphere. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure. See also:

    VRT_GeometryGetBoundingBox , VRT_GeometryLock , VRT_GeometryGetBoundingSphere

    62

  • int VRT_GeometryCalcVertexNormals (VRT_Geometry * geom) Enable smooth shading of geometry. This function calculates the normals of each vertex in the geometry and stores this information in the vertices. Vertex normals are used for smooth shading. This is not done automatically, because computing the normals is a quite time-consuming operation. In flat shading, the polygon normals are used, thereby resulting in a faceted surface. The polygon normals are automatically computed when a polygon is added to a geometry. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure.

    63

  • int VRT_GeometryCompile (VRT_Geometry * geom) Speed up geometry drawing. This function uses OpenGL display lists to speed up drawing of a geometry. This will have a substantial effect on performance when dealing with complex geometries. Note that any modifications to a geometry must be completed prior to a call to VRT_GeometryCompile. Once this function has been executed, geometry manipulation routines will show no effect. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure.

    64

  • int VRT_GeometryDelete (VRT_Geometry * geom) Dispose a geometry. This function deletes a geometry from the scene. The geometry is detached from any nodes it has been connected to. The geometries vertex and polygon lists are discarded. Parameters:

    geom a pointer to a geometry Returns:

    a VRT error code. See also:

    VRT_GeometryNew

    65

  • int VRT_GeometryFlipNormals (VRT_Geometry * geom) Inverts the direction of normal vectors. This function inverts the direction of the vertex normal vectors in the specified geometry by multiplying each component of the normal vector with a factor of -1.0. The lengths of the vectors are therefore preserved. This function can come handy if an objects normal vectors have for some reason the wrong direction thus causing erroneous shading of the object. Observe that this function does not influence the polygons vertex order (clockwise / counter- clockwise). Therefore, culling of the objects polygons is not affected. Parameters:

    geom geometry that shall be processed Returns:

    true upon success, false otherwise. See also:

    VRT_GeometryCalcVertexNormals , VRT_GeometryReverseFaces

    66

  • VRT_Geometry* VRT_GeometryFromPatch (VRT_Patch p) Create a geometry using patch data. This function creates a geometry from a patch by triangulating the patch vertex data. Besides the vertices, the geometry are given default properties. Parameters:

    p patch Returns:

    A pointer to a new geometry. See also:

    VRT_GeometryNew , VRT_GeometryMerge

    67

  • int VRT_GeometryGetBoundingBox (VRT_Geometry * geom, float * bounds) Get the bounding box of a geometry. This function gets the bounding box of a geometry. The supplied variable bounds will be filled with an array of bounding box coordinates on return. The bounding box is defined as two points in space: the lower left, innermost point and the upper right, outermost point of the eigth points making up the box. Parameters:

    geom pointer to a geometry bounds an array of bounding coordinates

    Returns: Zero on failure.

    See also: VRT_CalcBoundingSphere , VRT_GetBoundingSphere

    68

  • int VRT_GeometryGetBoundingSphere (VRT_Geometry * geom, float * cx, float * cy, float * cz, float * radius)

    Get the bounding sphere of a geometry. This function gets the bounding sphere parameters of a geometry. The bounding sphere is defined as the center of gravity of all vertices of the object and radius of the bounding sphere. If after modifications to the polygon list or vertex array of a geometry you want to retrieve the latest bounding sphere parameters, please use the function VRT_GeometryCalculateBoundingSphere. Parameters:

    geom pointer to a geometry cx pointer to center of gravity x coordinate cy pointer to center of gravity y coordinate cz pointer to center of gravity z coordinate radius pointer to bounding sphere radius

    Returns: Zero on failure.

    See also: VRT_GeometryGetBoundingBox , VRT_GeometryCalculateBoundingSphere

    69

  • int VRT_GeometryGetColor (VRT_Geometry * geom, int * r, int * g, int * b, int * alpha) Get the color of a geometry. This function gets the color of a geometry. The color components are in the range of 0-255. The color of a geometry determines the color of polygons added to the geometry. The polygons get the color of the geometry when they are added. Previously added polygons are not affected. On return, the r, g and b variables will hold the color component values of the geometry. The alpha value of a geometry specifies the transparency of an object. A alpha value of 255 means a completely opaque geometry whereas a alpha value of 0 means a fully transparent object. Parameters:

    geom pointer to a geometry r a pointer to red color value g a pointer to green color value b a pointer to blue color value alpha a pointer to the alpha value

    Returns: Zero on failure.

    See also: VRT_GeometryGetColor , VRT_PolygonSetColor

    70

  • int VRT_GeometryGetMaterial (VRT_Geometry * geom, float * material) The function reads the material parameters of a geometry. The function reads the current material of an object. Materials are defined by a set of 17 floating point values, which define the reflective properties of a surface with regard to different types of light. If the object has no material property assigned at the time of the function call, the parameter list returned will contain zero values only. The order of different parameters in the material array and their valid range is as follows: AR (ambient red [0.0 - 1.0]) AG (ambient green [0.0 - 1.0]) AB (ambient blue [0.0 - 1.0]) AA (ambient alpha [0.0 - 1.0]) DR (diffuse red [0.0 - 1.0]) DG (diffuse green [0.0 - 1.0]) DB (diffuse blue [0.0 - 1.0]) DA (diffuse alpha [0.0 - 1.0]) SR (specular red [0.0 - 1.0]) SG (specular green [0.0 - 1.0]) SB (specular blue [0.0 - 1.0]) SA (specular alpha [0.0 - 1.0]) ER (emission red [0.0 - 1.0]) EG (emission green [0.0 - 1.0]) EB (emission blue [0.0 - 1.0]) EA (emission alpha [0.0 - 1.0]) SC (shininess co-efficient [0.0 - 1.0]) Parameters:

    geom a pointer to a geometry object material a pointer to an array of 17 floating point values

    Returns: Zero on failure.

    See also: VRT_GeometrySetMaterial , VRT_GeometrySetColor

    71

  • int VRT_GeometryGetShadingModel (VRT_Geometry * geom, int * shadingmodel) Get the shading model of a geometry. This function retrieves the shading model of a geometry. The supplied shadingmodel variable will be set to the shading model of the geometry on return of the function. The following shading models are presently available: VRT_SM_UNDEFINED : not defined VRT_SM_WIRE : rendering as wireframe VRT_SM_FLAT : constant shaded polygons VRT_SM_SHADE : Gouraud shaded polygons VRT_SM_TEXTURE : Textured polygons Combinations of these values are possible. Observe that in the mode VRT_SM_SHADE normal vectors must be calculated for any geometry vertex. Parameters:

    geom pointer to a geometry shadingmodel the shading model of the geometry

    Returns: Zero on failure.

    See also: VRT_PolygonGetShadingModel , VRT_PolygonSetShadingModel , VRT_GeometrySetShadingModel

    72

  • int VRT_GeometryGetVertex (VRT_Geometry * geom, int i, float * x, float * y, float * z, float * nx, float * ny, float * nz, float * u, float * v)

    Get vertex data. This function gets vertex data from a geometries vertex list. Parameters:

    geom a pointer to a geometry i the vertex index x a pointer to vertex x component y a pointer to vertex y component z a pointer to vertex z component nx a pointer to vertex normal x component ny a pointer to vertex normal y compoent nz a pointer to vertex normal z component u a pointer to vertex texture u component v a pointer to vertex texture v component

    Returns: Zero on failure.

    See also: VRT_GeometryAddVertex , VRT_GeometrySetVertex

    73

  • int VRT_GeometryLock (VRT_Geometry * geom) Restrict access to geometry. This functions locks a geometry from further changes to it. All attempts to change the geometry via the VRT API calls will be denied until the geometry is unlocked by a call to VRT_GeometryUnlock. Any attempts will result in an error message. When the geometry is locked, bounding sphere information is calculated. An unlocked geometry has an undefined bounding sphere. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure. See also:

    VRT_GeometryUnlock , VRT_GeometryCalculateBounding , VRT_GeometryGetBoundingSphere

    74

  • VRT_Geometry* VRT_GeometryMerge (VRT_Geometry * geomA, VRT_Geometry * geomB) Create a new geometry from two other geometries. This function creates a new geometry by merging two other geometries. Besides the polygon data, the new geometry gets default properties. Parameters:

    geomA a pointer to a geometry geomB a pointer to another geometry

    Returns: A pointer to a new geometry.

    See also: VRT_GeometryNew , VRT_GeometryFromPatch

    75

  • VRT_Geometry* VRT_GeometryNew () Create a new geometry. This function creates a new, empty geometry with default properties. Returns:

    A pointer to a geometry. See also:

    VRT_GeometryDelete , VRT_GeometryFromPatch , VRT_GeometryMerge

    76

  • VRT_HPlg VRT_GeometryNewQuad (VRT_Geometry * geom, int v1, int v2, int v3, int v4) Add a quad to a geometry. This function adds a new quad polygon to a geometry. Four vertex indices are specified to make up the quad. These vertices must have been added previously to the geometry. The order by wich the vertices are specified determine the facing of the polygon. Counter-clockwise order is used for front facing. Parameters:

    geom a a pointer to a geometry v1 quad vertex index 1 v2 quad vertex index 2 v3 quad vertex index 3 v4 quad vertex index 4

    Returns: A handle to the newly created triangle polygon.

    See also: VRT_GeometryNewTriangle , VRT_GeometryNewTriangleStrip , VRT_GeometryNewTriangleFan

    77

  • VRT_HPlg VRT_GeometryNewQuadStrip (VRT_Geometry * geom, int nv, int * vi) This function adds a new quadriliteral strip to a geometry. This function adds a new quadriliteral strip to a geometry. The supplied vertex index array holds indices, referring to the geometry's vertices. A quadriliteral strip is an optimized way to define a set of several contingous quadriliteral polygon. By minimizing the number of vertices passed to the system, increased rendering performance can be achieved. The figure below shows a quadriliteral strip with eight vertices, which defines 3 adjacend quadriliteral polygons. Note that 12 vertices would otherwise be needed to define the same polygons if the VRT_NewQuad function was used. Parameters:

    geom a a pointer to a geometry nv number of vertices supplied vi an array of vertex indices

    Returns: A handle of type VRT_HPlg to the created quadriliteral strip

    See also: VRT_GeometryNewTriangle , VRT_GeometryNewTriangleFan , VRT_GeometryNewQuad , VRT_GeometryNewQuadStrip

    78

  • VRT_HPlg VRT_GeometryNewTriangle (VRT_Geometry * geom, int v1, int v2, int v3) Add a triangle to a geometry. This function add a new triangle polygon to a geometry. Three vertex indices are specified to make up the triangle. These vertices must have been added previously to the geometry. The order by wich the vertices are specified determine the facing of the polygon. Counter-clockwise order is used for front facing. Parameters:

    geom a a pointer to a geometry v1 triangle vertex index 1 v2 triangle vertex index 2 v3 triangle vertex index 3

    Returns: A handle to the newly created triangle polygon.

    See also: VRT_GeometryNewQuad , VRT_GeometryNewTriangleStrip , VRT_GeometryNewTriangleFan

    79

  • VRT_HPlg VRT_GeometryNewTriangleFan (VRT_Geometry * geom, int nv, int * vi) Add a triangle fan to a geometry. This function adds a new triangle fan to a geometry. The supplied vertex index array holds indices, referring to the geometry's vertices. Parameters:

    geom a a pointer to a geometry nv number of vertices supplied vi array of vertex indices

    Returns: A handle to the newly created triangle fan polygon.

    See also: VRT_GeometryNewTriangle , VRT_GeometryNewQuad , VRT_GeometryNewTriangleStrip

    80

  • VRT_HPlg VRT_GeometryNewTriangleStrip (VRT_Geometry * geom, int nv, int * vi) Add a triangle strip to a geometry. This function adds a new triangle strip to a geometry. The supplied vertex index array holds indices, referring to the geometry's vertices. Parameters:

    geom a a pointer to a geometry nv number of vertices supplied vi an array of vertex indices

    Returns: A handle to the newly created triangle strip.

    See also: VRT_GeometryNewTriangle , VRT_GeometryNewTriangleFan , VRT_GeometryNewQuad , VRT_GeometryNewQuadStrip

    81

  • int VRT_GeometryNormalize (VRT_Geometry * geom) Scale a geometry to unit size. This function normalizes the dimensions of a geometry. This means scaling the geometry to size 1.0 as well as translating it to the center of the objects reference frame. This operation affects the actual vertex data. Normalizing the geometry does not affect the lengths of the normal vectors. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure.

    82

  • int VRT_GeometryRenderColorsPerPolygon (VRT_Geometry * geom, int flag) Sets color rendering state. If flag is non-zero the individual color attributes of each polygon in the geometry geom will be rendered. A zero value switches the rendering off. Parameters:

    geom The geometry to affect. flag A flag with a zero value meanign off and a non-zero meaning on.

    Returns: Zero and a VRT error upon falure. One on success.

    83

  • void VRT_GeometryReverseFaces (VRT_Geometry * geom) Cange facing of a geometrys surface. This function reverses the facing of all polygons in a geometry, thereby changing the facing of the geometry's surface. This function can be used whenever the appearance of an object is strange due to the fact that only the inside surface of the object seems to be rendered. Note that it might be required to recalculate the objects normal vectors or to flip the objects normal vectors in order to achieve correct lighting results. Parameters:

    geom a pointer to a geometry See also:

    VRT_GeometryFlipNormals , VRT_GeometryCalcVertexNormals

    84

  • int VRT_GeometrySaveOBJ (VRT_Geometry * geom, char * file_name, int texturecoordinates, int normals)

    Saves a geometry to OBJ format file. This function saves the vertex and polygon data of an object into a Wafefront OBJ format file.The file type is ASCII so it can be manipulated by hand with a text editor. The function returns an error if the file for some reason could not be created. The flags texturecoordinates and normals can be set to non- zero values if it is desired to save texturte coordinates and/or normal vectors per vertex. Note, that VRT does not append a file extension. The .OBJ suffix must be supplied to the filename by the user. Parameters:

    geom a pointer to the object to be saved file_name a NULL terminated string pointer for file name texturecoordinates flag to save texture coordinates normals flag to save vertex normals

    Returns: 1 if function succeeded. 0 if an error occurred. In this case a VRT error is prompted to the console window.

    See also: VRT_GeometrySaveVRML , VRT_GeometrySavePLG , VRT_LoadPLG , VRT_LoadOBJ

    85

  • void VRT_GeometrySavePLG (VRT_Geometry * geom, char * fileName) Save geometry data into external file. This function saves the vertex and polygon data of an object into a proprietary file.The file type is ASCII so it can be manipulated by hand with a text editor. The function returns an error if the file for some reason could not be created. Parameters:

    geom a pointer to a geomtry fileName the name of the output file including pathes

    See also: VRT_GeometrySaveVRML , VRT_GeometrySaveOBJ , VRT_LoadPLG , VRT_LoadOBJ

    86

  • void VRT_GeometrySaveVRML (VRT_Geometry * geom, char * fileName) Save geometry data into external file. This function saves the vertex and polygon data of an object into VRML 1.0 compatible file.The file type is ASCII so it can be manipulated by hand with a text editor. Only vertex coordinate data and polygon data are stored. The function returns an error if the file for some reason could not be created. Parameters:

    geom a pointer to a geomtry fileName the name of the output file including pathes

    Returns: A VRT error code.

    See also: VRT_GeometrySaveOBJ , VRT_GeometrySaveVRML , VRT_LoadPLG , VRT_LoadOBJ

    87

  • int VRT_GeometrySetBothSides (VRT_Geometry * geom, int bs) Render both sides of a geometry's polygons. This function turns on or off rendering of both sides of the polygons of a geometry, not only the front (as specified by the ordering of vertices in the polygon). Rendering both sides of polygons is sometimes not necessary, for example in the case of a sphere, where the inside of the sphere isn't required to be rendered, because it cannot be seen. Note that rendering of both sides of an object decreases significantly the performance of your application. Parameters:

    geom a pointer to a geomtry bs ON/OFF, 1 or 0

    Returns: Zero on failure.

    88

  • int VRT_GeometrySetColor (VRT_Geometry * geom, int r, int g, int b, int alpha) Set the color of a geometry. This function sets the color of a geometry. The color components are in the range of 0-255. The color of a geometry determines the color of polygons added to the geometry. The polygons get the color of the geometry when they are added. Previously added polygons are not affected. The alpha value of a geometry specifies the transparency of an object. A alpha value of 255 means a completely opaque geometry whereas a alpha value of 0 means a fully transparent object. Parameters:

    geom pointer to a geometry r red color value g green color value b blue color value alpha alpha or transparency value

    Returns: Zero on failure.

    See also: VRT_GeometryGetColor , VRT_GeometrySetMaterial , VRT_PolygonSetColor

    89

  • int VRT_GeometrySetMaterial (VRT_Geometry * geom, float * material) Set the geometry material properties. This function sets material parameters of a geometry. If the shading mode of a geometry is set to VRT_SM_SHADE then the material properties of an object are used to calculate shading and lightning of an object. It is also advisable that the vertex normal for any vertex in the object are available for the lightning calculations to succeed. The material properties are defined by an array of 10 floating point values in the range from 0.0 to 1.0: AMBIENT : 3 RGB values DIFFUSE : 3 RGB values SPECULAR : 3 RGB values SHININESS : 1 exponent value VRT provides currently 25 different build in materials which are named VRT_MAT_1 through VRT_MAT_25. Parameters:

    geom pointer to a geometry material pointer to an array of material parameters

    Returns: Zero on failure.

    See also: VRT_GeometryGetColor , VRT_GeometrySetColor

    90

  • int VRT_GeometrySetShadingModel (VRT_Geometry * geom, int shadingmodel) Set the shading model of a geometry. This function sets the shading model of a geometry. The shading model of a geometry determines the shading mode of polygons added to the geometry. The polygons get the shade model of the geometry when the polygon is added. Previously added polygons are not affected. Parameters:

    geom a a pointer to a geometry shadingmodel the shading model to set

    Returns: Zero on failure.

    See also: VRT_GeometryGetShadingModel , VRT_PolygonGetShadingModel , VRT_PolygonSetShadingModel

    91

  • int VRT_GeometrySetTexture (VRT_Geometry * geom, VRT_Htx texture) Apply texture to a geometry object. The function applies a texture to a geometry. The function does not check, if the supplied texture handle is valid! If , in addition, the geometries texture shading model is VRT_SM_TEXTURE, all polygons of the geometries will be textured using the applied texture. Texturing a geometry requires a valid handle of a texture, which has been created prior to the call to VRT_GeometrySetTexture. Note also, that the texture coordinates of the polygons in that geometry must have meaningful values in order to yield reasonable texturing results. Parameters:

    geom a pointer to a geometry to which the texture shall be applied texture a handle to the texture to be applied

    Returns: 1 if function succeeded otherwise 0.

    See also: VRT_CreateRGBATexture , VRT_LoadTexture , VRT_GeometrySetShadingModel , VRT_PolygonSetTexture

    92

  • int VRT_GeometrySetVertex (VRT_Geometry * geom, int i, float x, float y, float z, float nx, float ny, float nz, float u, float v)

    Set vertex data. This function sets vertex data. Previous data are overwritten. Parameters:

    geom a pointer to a geometry i the vertex index x vertex x component y vertex y component z vertex z component nx vertex normal x component ny vertex normal y compoent nz vertex normal z component u vertex texture u component v vertex texture v component

    Returns: a VRT error code.

    See also: VRT_GeometryAddVertex , VRT_GeometryGetVertex

    93

  • int VRT_GeometryTransform (VRT_Geometry * geom, M4 ATOB) Transform a geometry. This function transforms the vertices of a geometry by applying the tranformation matrix to each. The transformation matrix is a 4 by 4 matrix. Note that mirroring of the geometry leads to turning the geometry “inside out”, due to the winding of the polygons in the geometry. Here VRT_GeoemtryReverseFaces might come in handy. Parameters:

    geom a pointer to a geometry ATOB transformation matrix

    Returns: zero (and setting a VRT error) on failure. One on success.

    See also: VRT_GeometryReverseFaces

    94

  • int VRT_GeometryUnlock (VRT_Geometry * geom) Gain access to geometry. This function unlocks a geometry that was previously locked, thereby allowing changes to be made to it. Parameters:

    geom a pointer to a geometry Returns:

    Zero on failure. See also:

    VRT_GeometryLock

    95

  • void VRT_GetClearColor (float * r, float * g, float * b, float * a) Get the clearing color VRT uses. This function gets the current clearing color being used by VRT. The color component ranges are 0-1 inclusive. Parameters:

    r a pointer to the red component g a pointer to the green comonent b a pointer to the blue component a a pointer to the alpha component

    See also: VRT_SetClearColor

    96

  • VRT_Context* VRT_GetContext () Used to get the current VRT context. Wrapper function used to retrieve the global vrtctx pointer. Returns:

    The current VRT context. See also:

    vrtctx , VRT_Context

    97

  • void VRT_GetDefaultCamera (float * ex, float * ey, float * ez, float * cx, float * cy, float * cz, float * ux, float * uy, float * uz)

    Get the current viewing parameters of the camera. This function retrieves the current viewing parameters of the camera. This function is in particular useful if the camera has been attached to a node in the scene graph. In that case, the camera is travelling according to the nodes movements and therefore it is not known to the application at which world coordinate the camera is positioned and oriented. This function is useful to retireve the cameras current looking direction and position. Parameters:

    ex a pointer to eye position x ey a pointer to eye position y ez a pointer to eye position z cx a pointer to camera target point x coordinate cy a pointer to camera target point y coordinate cz a pointer to camera target point z coordinate ux a pointer to the camera up vector x component uy a pointer to the camera up vector y component uz a pointer to the camera up vector z component

    Returns: void

    See also: VRT_SetDefaultCamera , VRT_AttachCameraToNode

    98

  • HBITMAP VRT_GetFrameAsBitmap (RECT * tr) Grabs frame buffer to Windows bitmap. This function creates a Windows bitmap of the current simulation window. If tr is NULL then the entire client area of the simulation window will be captured otherwise only a sub-region of the client area which is defined in tr is captured. The function allocates memory and creates a bitmap object. This function can be used to record an animated sequence of a simulation scenario. It is the calling functions responsibility to free the resources allocated by this function. Freeing the bitmap resources is done with Windows API functions. Parameters:

    tr a pointer to the rectangle data See also:

    DeleteObject (Windows API) , VRT_SaveBitmap

    99

  • float VRT_GetFrameRate () Get the current fram rate of VRT. This function computes the current frame rate of VRT. Returns:

    The current frame rate. See also:

    VRT_GetSimulationTime , VRT_GetSystemTime

    100

  • int VRT_GetLightModel () Retrieving the current light model. VRT can perform lighting calculations in two different ways. Global lightning (VRT_GLOBAL_LIGHT_MODEL) calculations, take care about the direction and position of lights in relation to the shaded objects surface attitude. In local lighting calculations (VRT_LOCAL_LIGHT_MODEL), in addition the relation between direction of light and direction from object towards the observer considered in illumination calculations. This gives more realistic shading results at the cost of decreased rendering performance. By default, VRT_GLOBAL_LIGHT_MODEL is installed and should only be changed, if specific illumination effects are desired. Returns:

    VRT_GLOBAL_LIGHT_MODEL or VRT_LOCAL_LIGHT_MODEL See also:

    VRT_SetLightModel

    101

  • float VRT_GetSimulationTime () Get the up-time of the simulation. This function returns the time elapsed since the simulation loop has been entered for the first time. The time returned is a floating point value indicating the elapsed time in seconds. Returns:

    Time elapsed since simulation start. See also:

    VRT_GetFrameRate , VRT_GetSystemTime

    102

  • void VRT_GetSystemTime (int * h, int * m, int * s) Get the systems current time from midnight. This function returns the computer systems current time of the day. Parameters:

    h pointer to hour m pointer to minute s pointer to second

    See also: VRT_GetFrameRate

    103

  • int VRT_GetTextureModulationMode () Retrieving the currently set texture modulation mode. The function returns the currently set texture modulation mode. The texture modulation mode is a environment state variable which affects the visual appearnace of textures. Whenever a texture is read from a file or created, the texture modulation mode at the time of texture creation determines how the texture will be created. Decal textures do generally replace the objects or polygons color with the picture contained in the texture. In modulate textures, the color and transparency of texels is multiplied with the color and transparency of the object and the rendered. As a result of this, the alpha channel in a texture can be used to modulate color and transparency of the entire object. In addition, in VRT a zero value texture element will not be rendered at all when a modulate texture is mapped upon a polygon. Therefore, textures can be used to stencil out irregular shapes from objects. Returns:

    VRT_TEXTURE_MODULATION_DECAL || VRT_TEXTURE_MODULATION_MODULATE || VRT_TEXTURE_MODULATION_BLEND

    See also: VRT_SetTextureModulationMode , VRT_CreateRGBATexture , VRT_LoadTexture

    104

  • void VRT_Init (HINSTANCE hInstance) Initialize VRT. This function initializes VRT for use. All internal states along with the scene graph is set up. No other VRT functions should be called prior to a call to this function. Parameters:

    hInstance handle to program instance See also:

    VRT_Close

    105

  • int VRT_IntersectRayNode (float * p, float * d, VRT_Node * anode, float * t, VRT_HPlg * hit_poly) Test for intersection of a ray with a node. This function test whether the ray defined by starting point p and directional vector d is intersecting with the given nodes geometry. This function is one of the most convenient procedures to test for ray-object intersection. This function performs in a three stage procedure in order to improve runtime performance. Observe, that intersection testing is performed for the geometry of the given node with regard to the current attitude of the node specified by the nodes current transformation matrix. Therefore, the rays coordinates are specified in world coordinates, and, if intersection testing is positive, the resulting intersection point is considered in world coordinates. Note that only the nodes geometry is considered for testing and not the children of the node. In case of intersection, the variable t gives the distance of the intersection point i from p along the direction vector d. Hence, the world coordinates of the point of intersection i can be calculated as follows: i = p + t*d. Parameters:

    p a pointer to ray starting coordinates d a pointer to ray direction vector components anode a pointer to the node to be tested t a pointer to the distance of the intersection point hit_poly a pointer to the hit polygon.

    Returns: Zero, if test fails. Non-zero, if ray intersects with nodes geometry.

    See also: VRT_IntersectRayTriangleUVT , VRT_IntersectRayTriangle , VRT_IntersectRayQuad , VRT_NodeIntersectNode

    106

  • int VRT_IntersectRayQuad (float * p, float * d, float * v1, float * v2, float * v3, float * v4, float * t) Test for intersection of a ray with a four sided polygon. This function tests for intersection of a ray with a quadriliteral polygon. The ray is defined by starting point p and a directional vector d. The quadriliteral polygon is given by four vertices v1, v2, v3, and v4 respectively. If the ray intersects with the polygon, the function returns a non zero value. In that case, variable t gives the distance of the intersection point i from p along the direction vector d. Hence, the world coordinates of the point of intersection i can be calculated as follows: i = p + t*d. Parameters:

    p a pointer to ray starting coordinates d a pointer to ray direction vector components v1 a pointer to polygons first vertex coordinates v2 a pointer to polygons second vertex coordinates v3 a pointer to polygons third vertex coordinates v4 a pointer to polygons fourth vertex coordinates t a pointer to the distance of the intersection point

    Returns: Zero, if test fails. Non-zero, if ray intersects with polygon.

    See also: VRT_IntersectRayTriangleUVT , VRT_IntersectRayTriangle , VRT_IntersectRayNode , VRT_NodeIntersectNode

    107

  • int VRT_IntersectRayTriangle (float * p, float * d, float * v1, float * v2, float * v3, float * t) Test for intersection of a ray with a triangle. This function tests for intersection of a ray with a triangle. The ray is defined by starting point p and a directional vector d. The triangle is given by three vertices v1, v2, v3, and v4 respectively. If the ray intersects with the triangle, the function returns a non zero value. In that case, variable t gives the distance of the intersection point i from p along the direction vector d. Hence, the world coordinates of the point of intersection i can be calculated as follows: i = p + t*d. Parameters:

    p a pointer to ray starting coordinates d a pointer to ray direction vector components v1 a pointer to triangles first vertex coordinates v2 a pointer to triangles second vertex coordinates v3 a pointer to triangles third vertex coordinates t a pointer to the distance of the intersection point

    Returns: Zero, if test fails. Non-zero, if ray intersects with triangle.

    See also: VRT_IntersectRayTriangleUVT , VRT_IntersectRayQuad , VRT_IntersectRayNode , VRT_NodeIntersectNode

    108

  • int VRT_IntersectRayTriangleUVT (float * p, float * d, float * v1, float * v2, float * v3, float * uvt) Test for intersection of a ray with a triangle. Function perfroms in the same way as VRT_IntersectRayTriangle. However, the variable uvt points to an array of three floating point parameters where the first element u, and the second element v represent polygon texture coordinates. In case of intersection, u and v specify the intersection point in terms of the poolygons texture coordinate system. The third element of the array t gives the distance of the intersection point i from p along the direction vector d. Hence, the world coordinates of the point of intersection i can be calculated as follows: i = p + t*d. Note that this function can be used to pick and select texture elements of a given polygon. Parameters:

    p a pointer to ray starting co d a pointer to ray direction vector components v1 a pointer to triangles first vertex coordinates v2 a pointer to triangles second vertex coordinates v3 a pointer to triangles third vertex coordinates uvt a pointer to array of three floating point values

    Returns: Zero, if test fails. Non-zero, if ray intersects with triangle.

    See also: VRT_IntersectRayTriangle , VRT_IntersectRayQuad , VRT_IntersectRayNode , VRT_NodeIntersectNode

    109

  • int VRT_IntersectTriangleTriangle (float * v1, float * v2, float * v3, float * u1, float * u2, float * u3) Test for triangle-triangle intersection. Explicite function to test whether two triangles do intersect or not. The vertices of both triangles are passed to the function by vertex pointers. Each vertex pointer must reference a triple of 3 floating point values, which contain the explicite co-ordinates of the corresponding vertex. The function supposes, that the triangles are defined in the same coordinate system. Note: If triangles from different nodes in a scene-graph hierarchy are supposed to be tested, it is recommended to either transform the coordinates of both triangles to the root coordinate system, or to transform the coordinates of one triangle into the local reference frame of the other triangle ! Parameters:

    v1 pointer to x v2 pointer to x v3 pointer to x u1 pointer to x u2 pointer to x u3 pointer to x

    Returns: 1 if intersection occurs, otherwise 0

    See also: VRT_IntersectRayQuad , VRT_IntersectRayNode , VRT_IntersectRayTriangle , VRT_IntersectRayTriangleUVT , VRT_NodeIntersectNode

    110

  • int VRT_LightDelete (VRT_Light * light) Delete a light object and free allocated resour