Introduction to WTK Jin-Bey Yu 2001/10/04
What is WTK Library With over 1000 functions written in C that enable you to rapidly develop virtual reality applications. Resemble virtual world Object in this world may have reality-world properties and behavior Structured in an object-oriented way Functions are object-oriented in their naming convention, and are organized into over 20 classes.
Scene Graph Architecture
What WTK Does Rendering Reading input sensors Importing geometries Simulation Incorporates the philosophy of OpenVR TM (portable across platforms) Supports a variety of input and output devices.
Overview of the WTK Classes Universe The container of all WTK object Geometries Graphical object that are visible in a simulation Nodes Building blocks from scene graphs Polygons Vertices Lights
Overview of the WTK Classes (const.) Viewpoints Define the position and orientation of the view. Windows Display user ’ s scene. Sensors Manipulate object motion Path Object that allow geometric or viewpoint to follow.
Overview of the WTK Classes (const.) Tasks assign behaviors (such as movement) Motion links Associate a senor (or a path) with an target Sound User interface Networking asynchronously communicate over an Ethernet Serial port
Other Features Materials and Translucency Complete control of coloring geometries Task Objects Specify the behavior of any geometry, node Performance Optimizations for Rendering Atmospheric Effects fog, haze, and cloud layers Constraints Available on the translations and rotations
Other Features (const.) Textures from Memory Support for Many Sensors Support for 3D Text Support for Many File Formats WRL, FLT, DXF, NFF, OBJ, 3DS, BFF, SLP, and GEO file formats.
Simulation Loop
使用環境 作業系統 : 95/98/NT MicroSoft visual C WTK Release 7.0 其他工具 : 3D Studio MAX 3D 加速卡 (optional)
事前設定 安裝 將 WorldToolKit_Release7 目錄下的 Wtk.lib- cracked 取代安裝後的 Lib 目錄下的 Wtk.lib 將 wtkcodes 複製到 ( 你的 ) 執行檔目錄。 VC 設定 Tools ->Options ->Directories 下請加入 WTK 的 Include 和 Lib 目錄的位置 Project -> Settings ->Link ->General->modules 請加入 wtk.lib opengl32.lib ->Link ->Input -> Ignore libraries 請填上 libcd.lib
Example #include "wt.h" WTnode *root; WTviewpoint *view; void main (int argc, char* argv[]) { WTsensor *sensor; WTuniverse_new(WTDISPLAY_DEFAULT, WTWINDOW_DEFAULT); root = WTuniverse_getrootnodes(); sensor = WTmouse_new(); view = WTuniverse_getviewpoints(); WTviewpoint_addsensor(view, sensor); WTkeyboard_open(); /* set universe action function */ WTuniverse_setactions(actions); WTuniverse_setbgrgb(0, 0, 0); setup_scene(); WTuniverse_ready(); WTuniverse_go(); WTuniverse_delete(); }
Example (const.) void actions() { int key ; key = WTkeyboard_getkey(); if (key) handle_key(key); } void handle_key(int k) { WTp3 pos; switch (k) { case '1' : WTviewpoint_getposition(view, pos); WTmessage("%f, %f, %f\n", pos[X], pos[Y], pos[Z]); break; default:break; }
Example (const.) void setup_scene() { WTgeometry *cylinder, *sphere; WTnode *myLOD, *n1, *n2, *tel; float lodrange[2] = {10.0, 30.0}; WTp3 pos; WTlight_load("lights"); tel = WTnode_load(root, "Tel.3DS", 0.01f); cylinder = WTgeometry_newcylinder(10.0, 0.3, 3, FALSE, FALSE); sphere = WTgeometry_newsphere(1.0, 8, 16, FALSE, FALSE); myLOD = WTlodnode_new(root); n1 = WTgeometrynode_new(myLOD, cylinder); n2 = WTgeometrynode_new(myLOD, sphere); pos[X] = 0; pos[Y] = 7.5; pos[Z] = 0; WTlodnode_setcenter(myLOD, pos); WTlodnode_setrange(myLOD, lodrange, 2); }
WTK light format Directed light parameters d[irected] [dir ] [ int ] [amb ] [diff ] [spec ] Point light parameters p[oint] [pos ] [ int ] [att ] [amb ] [diff ] [spec ] Spot light parameters s[pot][pos ][dir ][int ][angle[rad] ] [exp ] [att ][amb ][diff ][spec ] Ambient light parameters a[mbient] [int ] [amb ]
Relative Resource Ftp cggmpc3.csie.nctu.edu.tw:21 username/password: vr2001/vr2001 WTK release7 3D Studio Max R3 Bryce 4.0 Poser 4.0