Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12.

Similar presentations


Presentation on theme: "1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12."— Presentation transcript:

1 1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12

2 2 3D Sound (1/4) WTsounddevice *WTsounddevice_open( int type, int nplayable, WTviewpoint *listener) Arguments: typeWTSOUNDDEVICE_DS WTSOUNDDEVICE_WINMM WTSOUNDDEVICE_DWSTK WTSOUNDDEVICE_VSI WTSOUNDDEVICE_SGI WTSOUNDDEVICE_CRE nplayable The number of sounds you would like to play at once. viewpoint The viewpoint assigned to the listener. FLAG WTsounddevice_close(WTsounddevice *device)

3 3 3D Sound (2/4) FLAG WTsounddevice_setlistener ( WTsounddevice *device, WTviewpoint *viewpoint); This function specifies a viewpoint as a listener. The device argument specifies the device for which the listener is set. The viewpoint argument specifies the location of the listener. It returns TRUE if successful, FALSE if unsuccessful. WTviewpoint *WTsounddevice_getlistener ( WTsounddevice *device); This function gets the viewpoint that is being used as a listener by a device. The device argument specifies the device from which to get the listener. This function returns the viewpoint used as listener or NULL if unsuccessful.

4 4 3D Sound (3/4) WTsound *WTsound_load ( WTsounddevice *device, char *source); This function creates a new sound from a source. The device argument specifies the sound device from which to load the sound. The source argument specifies the name of source (filename, resource name, or sample name). FLAG WTsound_play (WTsound *sound); This function cues a sound to begin playing. When a sound is finished playing, it returns to the beginning of the sample. The sound argument specifies the name of the sound to play. void WTsound_stop (WTsound *sound); This function stops a currently playing sound. The sound argument specifies the name ofthe sound to stop playing.

5 5 3D Sound (4/4) void WTsound_setposition ( WTsound *sound, WTp3 position); This function sets a sound's position in 3D space. This setting overrides object and viewpoint attachments for placing sounds. The sound argument specifies which sound is specified. The position argument specifies the new position for the sound.

6 6 Texture Change (1/3) FLAG WTgeometry_settexture( WTgeometry *geom, char * bitmap, FLAG shaded, FLAG transparent); This function applies a texture bitmap to each polygon surface of a geometry (using the WTpoly_settexture function). It returns TRUE if successful and FALSE otherwise. FLAG WTgeometry_changetexture( WTgeometry *geom, char *bitmap, FLAG shaded,FLAG transparent); This function changes all textured polygons of the specified geometry to use the new texture bitmap instead of their current texture. The new bitmap is specified by the bitmap argument. The shading and transparent flags are applied in a fashion similar to WTgeometry_settexture.

7 7 Texture Change (2/3) unsigned char *WTtexture_load(char *bitmap, int *w, int *h); This function reads in a texture bitmap named bitmap and returns a pointer to the image file and the width and height of the texture. The return values of this function can then be used as parameters to the WTtexture_replace function. FLAG WTtexture_cache(char *bitmap, FLAG enable); This function controls the caching of a texture. When the enable flag is TRUE, the specified texture bitmap ( bitmap ) is loaded (if not already loaded), then marked as cached. When the enable flag is FALSE the texture is marked as not cached and is deleted if no polygons reference this texture. This function is useful for texture animations so that the texture does not have to be reloaded from disk during every pass of the animation.

8 8 Texture Change (3/3) void WTpoly_rotatetexture(WTpoly *poly, float angle); void WTpoly_scaletexture(WTpoly *poly, float factor); void WTpoly_translatetexture(WTpoly *poly, WTp2 displacement); A texture after scalingA texture after translation

9 9 Collision Detection (1/5) Bounding Box parameters: extents, radius and midpoint

10 10 Collision Detection (2/5) The location of that instance of the geometry (remember, there is only one actual geometry) depends on the path (node path) you take through the scene graph tree to reach it. These are two things you can do with node paths –Perform intersection tests in the scene graph –Pick graphical entities rendered into WTK windows

11 11 Collision Detection (3/5) WTnodepath *WTnodepath_new( WTnode *node, WTnode*ancestor, int which); This function creates a new node path. A node path must be fully specified by giving three arguments to this function: the node that the instance references the ancestor of that node (the ancestor is the root node above) the occurrence number which. The which parameter is the number of that instance of the node FLAG WTnodepath_getextents(WTnodepath *path, float ext[2][3]); This function places the center and extents of the node path in the specified floating point array (given by ext ). The extents box of a node path is the smallest rectangular box that encloses all the geometries of the node path and which is aligned with the world coordinate axes.

12 12 Collision Detection (4/5) FLAG WTnodepath_intersectpoly( WTnodepath *nodepath1, WTnodepath *nodepath2); This function tests for the intersection of any polygons in two node paths (nodepath1 and nodepath2) and their sub-trees. It returns TRUE if there is an intersection, FALSE otherwise. FLAG WTnodepath_intersectbbox( WTnodepath *nodepath1, WTnodepath *nodepath2); This function tests for the intersection of two node paths, n1 and n2, based on their bounding boxes. Remember that these bounding boxes are the bounding boxes of the entire sub-tree of the scene graph beginning at the bottom-most node of the node path.

13 13 Collision Detection (5/5) WTnodepath *WTnodepath_intersectnode( WTnodepath *nodepath, WTnode *node, int which); This function performs a bounding box intersection test between the specified node path and the numbered occurrence of the specified node (and its sub-tree). If they do not intersect, it returns NULL. If they do intersect, then this function traverses down the specified node’s sub- tree in search of the node whose bounding box has the smallest extents and yet still intersects the bounding box of the specified node path. Then a node path to that node is created and a pointer to it is returned.

14 14 Interaction (1/3) WTpoly *WTscreen_pickpoly( int screennum, WTp2 pt, WTnodepath **nodepath, WTp3 p); This function obtains a pointer to the frontmost polygon rendered at the specified 2D screen point on the specified screen. –Screen coordinates are specified as 2D floating point values, with (0.0, 0.0) representing the top-left corner of the screen, and the bottom-right corner of the screen represented by (screen width, screen height). –The WTp3 obtained is the 3D point in world coordinates at which the selected polygon was intersected. –The WTnodepath pointer, indicating the node path to which the selected polygon belongs.

15 15 Interaction (2/3) WTtask *WTtask_new( void *objptr, WTtask_function fptr, float priority); This function creates a new WTtask and activates it, so that it is automatically executed as the simulation runs. Tasks created by this function are executed in the simulation loop. –The objptr is a pointer to the WTK object. The same object can perform more than one task. –The fptr is the task function ( WTtask_function ) that is executed as the WTK simulation runs. –The priority specifies the order in which tasks are executed within the tasks slot in the simulation loop. Lower-numbered tasks are executed before higher-numbered ones.

16 16 Interaction (3/3) FLAG WTtask_delete(WTtask *task); This function deletes a task (destroys it). Deleting a task both removes it from the simulation so that it is no longer executed as the simulation runs, and also frees the memory associated with the WTtask object passed in. The task pointer passed in is invalid after this function is called.

17 17 Constrained Motion (1/3) These are three things you can constrain the motion 1.Arrange the Scene Grpah to fit our requirements 2.Assign tasks for objects 3.Use Motion Links to constain the motion of the objects Some ways to use motion links

18 18 Constrained Motions (2/3) WTmotionlink *WTmotionlink_new( void *source, void *target, int from_type, int to_type); Source Pointer to either a sensor or a path. Target Pointer to either a viewpoint, a movable, a transform node,or a node path leading to either a transform node or a movable node. from_type The type of the source WTSOURCE_SENSOR,WTSOURCE_PATH to_type The type of the target WTTARGET_VIEWPOINT,WTTARGET_MOVABLE, WTTARGET_TRANSFORM,WTTARGET_NODEPATH

19 19 Constrained Motions (3/3) FLAG WTmotionlink_addconstraint( WTmotionlink *link, int dof, float min, float max); Use this function to add a constraint to a motion link so that the position and/or orientation of the motion link’s target is constrained. The dof specifies the degrees of freedom (DOF) WTCONSTRAIN_X, WTCONSTRAIN_Y, WTCONSTRAIN_Z, WTCONSTRAIN_XROT, WTCONSTRAIN_YROT, WTCONSTRAIN_ZROT. The min and max specify the range within which the target of the motion link is constrained (within that DOF).

20 20 Lighting (1/2) Ambient light node Directed light node Point light node Spot light node

21 21 Lighting (2/2) FLAG WTlightnode_load(WTnode *parent,char *filename); FLAG WTlightnode_setposition(WTnode *light,WTp3 p); void WTlightnode_setdirection(WTnode *light,WTp3 dir); void WTlightnode_setintensity(WTnode *light,float x); void WTlightnode_setambient(WTnode *l,float r,float g,float b); void WTlightnode_setdiffuse(WTnode *light,float r,float g,float b); void WTlightnode_setspecular(WTnode *l,float r,float g,float b); void WTlightnode_setattenuation(WTnode *light, float atten0,float atten1,float atten2); T he attenuation factor: 1.0/(atten0 + atten1*dist + atten2*dist*dist) void WTlightnode_setangle(WTnode *light,float angle); void WTlightnode_setexponent(WTnode *light, float val);


Download ppt "1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12."

Similar presentations


Ads by Google