180 likes | 339 Views
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
E N D
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.
What WTK Does • Rendering • Reading input sensors • Importing geometries • Simulation • Incorporates the philosophy of OpenVRTM (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.
使用環境 • 作業系統: 95/98/NT • MicroSoft visual C++ 6.0 • 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 <X> <Y> <Z>] [ int <V>] [amb <R> <G> <B>] [diff <R> <G> <B>] [spec <R> <G> <B>] • Point light parameters p[oint] [pos <X> <Y> <Z>] [ int <V>] [att <X> <Y> <Z>] [amb <R> <G> <B>] [diff <R> <G> <B>] [spec <R> <G> <B>] • Spot light parameters s[pot][pos <X> <Y> <Z>][dir <X> <Y> <Z>][int <V>][angle[rad] <V>] [exp <V>] [att <a0><a1><a2>][amb<R><G><B>][diff<R><G><B>][spec<R><G><B>] • Ambient light parameters a[mbient] [int <V>] [amb <R> <G> <B>]
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