00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 var iGlobalUnit=1;
00041
00042 var sV3DDEFAULTRESOURCESPATH="tools/os3dlib/res/";
00043
00044 var iV3Ddebug=0;
00045
00046
00047 var iV3DmaxFramerate=90;
00048
00049 var iV3DIndex=0;
00050 var iV3DSessionIndex=0;
00051
00052
00053 var V3DCLICK_NO=0;
00054 var V3DCLICK_LEFT=1;
00055 var V3DCLICK_RIGHT=2;
00056 var V3DCLICK_SHIFT=4;
00057 var V3DCLICK_CTRL=8;
00058 var V3DCLICK_MIDDLE=16;
00059
00060
00061 var V3DAXIS_X=32;
00062 var V3DAXIS_Y=64;
00063 var V3DAXIS_Z=128;
00064
00065
00066
00067 struct V3Dviewport{
00068
00069 V3D_iViewportIndex (I);
00070 V3D_viewport (SO3_VIEWPORT);
00071 V3D_iViewportX (F);
00072 V3D_iViewportY (F);
00073 V3D_iViewportW (F);
00074 V3D_iViewportH (F);
00075 V3D_lFlashControl ([SO3_FLASH_CONTROL r1]);
00076 V3D_iBgColor (I
00077
00078 );
00079 };
00080 typedef struct mkV3Dviewport V3Dviewport;
00081
00082
00083
00084 struct V3Daxis{
00085
00086 V3D_axisFather (SO3_OBJECT);
00087 V3D_axisShell (SO3_OBJECT);
00088 V3D_xAxisObject (SO3_OBJECT);
00089 V3D_yAxisObject (SO3_OBJECT);
00090 V3D_zAxisObject (SO3_OBJECT);
00091 V3D_xAxisTextObject (SO3_OBJECT);
00092 V3D_yAxisTextObject (SO3_OBJECT);
00093 V3D_zAxisTextObject (SO3_OBJECT);
00094 V3D_iAxisMode (I
00095
00096 );
00097 };
00098 typedef struct mkV3Daxis V3Daxis;
00099
00100
00101
00102 struct V3Dhelper{
00103
00104 V3D_helperFather (SO3_OBJECT);
00105 V3D_helperIcon (SO3_OBJECT);
00106 V3D_iHelperMode (I
00107
00108 );
00109 };
00110 typedef struct mkV3Dhelper V3Dhelper;
00111
00112
00113
00114 struct V3Dsession{
00115
00116 V3D_sessionView (V3Dview);
00117 V3D_session (SO3_SCENE);
00118 V3D_lCamera ([[I SO3_OBJECT] r1]);
00119 V3D_defaultCamera (SO3_OBJECT);
00120 V3D_prevDefaultCamera (SO3_OBJECT);
00121 V3D_shellNavigate (SO3_OBJECT);
00122
00123 V3D_physics (V3Dphysics);
00124 V3D_lAxis ([[SO3_OBJECT V3Daxis] r1]);
00125 V3D_lHelper ([[SO3_OBJECT V3Dhelper] r1]);
00126 V3D_helperGrid ([SO3_OBJECT [SO3_OBJECT r1]]);
00127 V3D_bHelpersState (I);
00128
00129 V3D_selectedAxis ([V3Daxis I]);
00130 V3D_cbAxisClick (fun [V3Dsession SO3_OBJECT I I I I] I);
00131 V3D_cbAxisUnClick (fun [V3Dsession SO3_OBJECT I I I I] I);
00132 V3D_cbAxisMove (fun [V3Dsession SO3_OBJECT I I I I F] I);
00133 V3D_bNavigate (I);
00134
00135 V3D_lAnimations ([[S V3Danim] r1]);
00136 V3D_bAnimations (I
00137
00138 );
00139 };
00140 typedef struct mkV3Dsession V3Dsession;
00141
00142
00143 struct V3Danim{
00144
00145 V3D_anim (SO3_ANIM);
00146 V3D_meshAnim (SO3_OBJECT);
00147 V3D_nodePRS ([[F F F] [F F F F] [F F F]]);
00148 V3D_sAnimName (S);
00149 V3D_bAnimState (I);
00150 V3D_iAnimType (I);
00151 V3D_cbAnimPlay (fun [V3Danim] I);
00152 V3D_cbAnimPause (fun [V3Danim] I);
00153 V3D_cbAnimStop (fun [V3Danim] I);
00154 V3D_AnimEditorValues ([I I F F]
00155
00156 );
00157 };
00158 typedef struct mkV3Danim V3Danim;
00159
00160
00161
00162 struct V3Dview{
00163
00164 V3D_win (ObjWin);
00165 V3D_buffer (SO3_BUFFER);
00166 V3D_channel (Chn);
00167 V3D_iWinW (I);
00168 V3D_iWinH (I);
00169 V3D_iWinX (I);
00170 V3D_iWinY (I);
00171 V3D_iOldWinW (I);
00172 V3D_iOldWinH (I);
00173
00174 V3D_lSessions ([[I V3Dsession] r1]);
00175 V3D_bPaused (I);
00176
00177
00178 V3D_iRenderTick (I);
00179
00180
00181 V3D_iClickStatus (I);
00182 V3D_iClickX (I);
00183 V3D_iClickY (I);
00184 V3D_iMoveX (I);
00185 V3D_iMoveY (I);
00186 V3D_iRenderMoveX (I);
00187 V3D_iRenderMoveY (I);
00188 V3D_iMoveClickStatus (I);
00189 V3D_bMouseEnabled (I);
00190 V3D_bKeyboardEnabled (I);
00191
00192
00193 V3D_cbInit (fun [V3Dview] I);
00194 V3D_cbDestroy (fun [V3Dview] I);
00195 V3D_cbPreRenderEffects (fun [V3Dview] I);
00196 V3D_cbPreRender (fun [V3Dview] I);
00197 V3D_cbPostRender (fun [V3Dview] I);
00198 V3D_cbClick (fun [V3Dview I I I] I);
00199 V3D_cbDbClick (fun [V3Dview I I I] I);
00200 V3D_cbUnClick (fun [V3Dview I I I] I);
00201 V3D_cbWheel (fun [V3Dview I I I I] I);
00202 V3D_cbCursorMove (fun [V3Dview I I I] I);
00203 V3D_cbKeyDown (fun [V3Dview I I] I);
00204 V3D_cbKeyUp (fun [V3Dview I] I);
00205 V3D_cbDropFile (fun [V3Dview I I [P r1]] I);
00206 V3D_cbCameraChange (fun [V3Dview V3Dsession SO3_OBJECT] I);
00207 V3D_cbResizeView (fun [V3Dview I I] I);
00208
00209 V3D_lViewport ([[I V3Dviewport] r1]);
00210
00211 V3D_bFullScreen (I);
00212 V3D_bState (I
00213
00214 );
00215 };
00216 typedef struct mkV3Dview V3Dview;
00217
00218
00219 proto V3DviewSetFocus=fun [V3Dview] I;
00220 proto V3DphysCreate=fun [V3Dsession] I;
00221 proto V3DphysDestroy=fun [V3Dsession] I;
00222 proto V3DphysReset=fun [V3Dsession] I;
00223
00224
00225 V3Dlcat(p, q){
00226 if p==nil
00227 then
00228 q
00229 else let p -> [h nxt] in
00230 h::V3Dlcat nxt q;
00231 }
00232
00233
00234 V3DisUrl(url){
00235 if (!strcmpi "http://" (substr url 0 7)) || (!strcmpi "https://" (substr url 0 8)) || (!strcmpi "ftp://" (substr url 0 6)) || (!strcmpi "mms://" (substr url 0 6)) || (!strcmpi "rstp://" (substr url 0 7)) then
00236 1
00237 else 0;
00238 }
00239
00240
00241 V3DgetPathFile(longfile, file){
00242 if (longfile==nil) || (strlen longfile)==0 || (nth_char longfile ((strlen longfile)-1)) == '/ then
00243 (
00244 if (strfind "." file 0) != nil then
00245 [longfile file]
00246 else if file != nil then
00247 [strcatn longfile::file::"/"::nil nil]
00248 else
00249 [longfile nil];
00250 )
00251 else
00252 V3DgetPathFile
00253 substr longfile 0 (strlen longfile)-1
00254 strcat
00255 substr longfile ((strlen longfile)-1) 1
00256 file;
00257 }
00258
00259
00260 // return the fileName without Path and Extension
00261 V3DgetFileNameWithoutExt(file){
00262 let V3DgetPathFile file "" -> [_ file2] in
00263 substr file2 0 (strfind "." file2 0);
00264 }
00265
00266
00267 V3DgetFileExt(file){
00268 let V3DgetPathFile file "" -> [_ file2] in
00269 substr file2 ((strfind "." file2 0) + 1) 1024;
00270 }
00271
00272
00273 V3DgetFilePathWithoutExt(file){
00274 substr file 0 (strfind "." file 0);
00275 }
00276
00277
00278 V3DremoveIdxFromList(l, idx){
00279 if l==nil
00280 then
00281 nil
00282 else
00283 let hd l -> [id _] in
00284 if id == idx then
00285 tl l
00286 else
00287 (hd l)::V3DremoveIdxFromList tl l idx;
00288 }
00289
00290
00291 V3DremoveTupFromListBy2ndElem(l, s2nd){
00292 if l==nil
00293 then
00294 nil
00295 else
00296 let hd l -> [_ elem] in
00297 if elem == s2nd then
00298 tl l
00299 else
00300 (hd l)::V3DremoveTupFromListBy2ndElem tl l s2nd;
00301 }
00302
00303
00304 V3DremoveTupFromListByName(l, name){
00305 if l==nil
00306 then
00307 nil
00308 else
00309 let hd l -> [sname _] in
00310 if (!strcmp name sname) then
00311 tl l
00312 else
00313 (hd l)::V3DremoveTupFromListByName tl l name;
00314 }
00315
00316
00317 V3DgetSessionIndex(viewstr, sessionstr){
00318 let sizelist viewstr.V3D_lSessions -> size in
00319 let nil -> idx in
00320 let 0 -> i in
00321 (
00322 while i < size && idx == nil do
00323 (
00324 let nth_list viewstr.V3D_lSessions i -> [sidx sstr] in
00325 if sstr != sessionstr then nil else
00326 set idx = sidx;
00327
00328 set i = i + 1;
00329 );
00330 idx;
00331 );
00332 }
00333
00334
00335 V3DgetSession(sessionstr){
00336 sessionstr.V3D_session;
00337 }
00338
00339
00340 V3DgetSessionByIndex(viewstr, idx){
00341 switch viewstr.V3D_lSessions idx;
00342 }
00343
00344
00345 V3DgetDefaultSession(viewstr){
00346 switch viewstr.V3D_lSessions 0;
00347 }
00348
00349
00350 V3DdegToRad(f){
00351 f *. ((2.0 *. PIf) /. 360.0);
00352 }
00353
00354
00355 V3DradToDeg(f){
00356 f /. ((2.0 *. PIf) /. 360.0);
00357 }
00358
00359
00360 V3DgetObjectPos(sessionstr, obj){
00361 if sessionstr == nil then nil else
00362 (
00363 SO3ObjectGetPosition sessionstr.V3D_session obj;
00364 );
00365 }
00366
00367
00368 V3DgetObjectScale(sessionstr, obj){
00369 if sessionstr == nil then nil else
00370 (
00371 SO3ObjectGetScale sessionstr.V3D_session obj;
00372 );
00373 }
00374
00375
00376 V3DgetObjectOrientation(sessionstr, obj){
00377 if sessionstr == nil then nil else
00378 (
00379 SO3ObjectGetOrientation sessionstr.V3D_session obj;
00380 );
00381 }
00382
00383
00384 V3DsetObjectPos(sessionstr, obj, pos){
00385 if sessionstr == nil then nil else
00386 (
00387 if pos == nil then nil else
00388 SO3ObjectSetPosition sessionstr.V3D_session obj pos;
00389
00390 pos;
00391 );
00392 }
00393
00394
00395 V3DsetObjectScale(sessionstr, obj, scale){
00396 if sessionstr == nil then nil else
00397 (
00398 if scale == nil then nil else
00399 SO3ObjectSetScale sessionstr.V3D_session obj scale;
00400
00401 scale;
00402 );
00403 }
00404
00405
00406 V3DsetObjectOrientation(sessionstr, obj, quat){
00407 if sessionstr == nil then nil else
00408 (
00409 if quat == nil then nil else
00410 SO3ObjectSetOrientation sessionstr.V3D_session obj quat;
00411 quat;
00412 );
00413 }
00414
00415
00416 V3DgetSessionView(sessionstr){
00417 sessionstr.V3D_sessionView;
00418 }
00419
00420
00421 V3DgetViewportByIndex(viewstr, idx){
00422 switch viewstr.V3D_lViewport idx;
00423 }
00424
00425
00426 V3DgetViewportIndex(viewstr, viewport){
00427 let sizelist viewstr.V3D_lViewport -> size in
00428 let nil -> idx in
00429 let 0 -> i in
00430 (
00431 while i < size && idx == nil do
00432 (
00433 let nth_list viewstr.V3D_lViewport i -> [sidx view] in
00434 if view != viewport then nil else
00435 set idx = sidx;
00436
00437 set i = i + 1;
00438 );
00439 idx;
00440 );
00441 }
00442
00443
00444 V3DgetDefaultViewport(viewstr){
00445 switch viewstr.V3D_lViewport 0;
00446 }
00447
00448
00449 V3DsetViewportColor(viewportstr, color){
00450 set viewportstr.V3D_iBgColor = color;
00451 SO3ViewportSetBackgroundColor viewportstr.V3D_viewport color;
00452 0;
00453 }
00454
00455
00456 V3DgetViewportColor(viewportstr){
00457 SO3ViewportGetBackgroundColor viewportstr.V3D_viewport;
00458 }
00459
00460
00461 V3DdelViewport(viewstr, viewportstr){
00462 let sizelist viewportstr.V3D_lFlashControl -> size in
00463 let 0 -> i in
00464 while i < size do
00465 (
00466 let nth_list viewportstr.V3D_lFlashControl i -> flashctrl in
00467 (
00468 SO3FlashControlDestroy flashctrl;
00469 );
00470 set i = i + 1;
00471 );
00472 set viewportstr.V3D_lFlashControl = nil;
00473
00474 SO3ViewportDestroy viewportstr.V3D_viewport;
00475 let V3DgetViewportIndex viewstr viewportstr -> idx in
00476 set viewstr.V3D_lViewport = V3DremoveIdxFromList viewstr.V3D_lViewport idx;
00477 0;
00478 }
00479
00480
00481 V3DaddViewport(viewstr, x, y, w, h, backcolor){
00482 let
00483 let 0 -> i in
00484 (
00485 while ((switch viewstr.V3D_lViewport i) != nil) do
00486 (
00487 set i = i + 1;
00488 );
00489 i;
00490 )
00491 -> idx in
00492 let mkV3Dviewport [idx nil x y w h nil backcolor] -> newviewport in
00493 (
00494 set viewstr.V3D_lViewport = V3Dlcat viewstr.V3D_lViewport [idx newviewport]::nil;
00495 newviewport;
00496 );
00497 }
00498
00499
00500 V3DsetViewport(viewstr, viewportstr, sessionstr, camera){
00501 if viewportstr.V3D_viewport == nil then
00502 (
00503 set viewportstr.V3D_viewport = SO3ViewportCreate viewstr.V3D_channel viewstr.V3D_buffer (V3DgetSession sessionstr) camera viewportstr.V3D_iViewportX viewportstr.V3D_iViewportY viewportstr.V3D_iViewportW viewportstr.V3D_iViewportH viewportstr.V3D_iViewportIndex;
00504 SO3ViewportSetBackgroundColor viewportstr.V3D_viewport viewportstr.V3D_iBgColor;
00505 SO3ViewportSetShadowEnabled viewportstr.V3D_viewport 1;
00506 0;
00507 )
00508 else
00509 (
00510 SO3CameraSetViewport viewportstr.V3D_viewport (V3DgetSession sessionstr) camera;
00511 0;
00512 );
00513 0;
00514 }
00515
00516
00517 V3DsetViewportPositionSize(viewportstr, x, y, w, h){
00518 if viewportstr.V3D_viewport == nil then nil else
00519 (
00520 set viewportstr.V3D_iViewportX = x;
00521 set viewportstr.V3D_iViewportY = y;
00522 set viewportstr.V3D_iViewportW = w;
00523 set viewportstr.V3D_iViewportH = h;
00524 SO3ViewportSetPositionSize viewportstr.V3D_viewport x y w h;
00525 );
00526 0;
00527 }
00528
00529
00530 V3DchangeCameraViewport(sessionstr, viewportstr, camera){
00531 let if viewportstr == nil then V3DgetDefaultViewport (V3DgetSessionView sessionstr) else viewportstr -> viewportstr in
00532 (
00533 V3DsetViewport (V3DgetSessionView sessionstr) viewportstr sessionstr camera;
00534 //exec sessionstr.V3D_sessionView.V3D_cbCameraChange with [sessionstr.V3D_sessionView sessionstr camera];
00535 );
00536 0;
00537 }
00538
00539
00540 V3DsetCamera(sessionstr, camera, fovlenght, fovy, nclip, fclip){
00541 if sessionstr == nil then nil else
00542 (
00543 if fovlenght == nil then nil else
00544 SO3CameraSetFocalLenght sessionstr.V3D_session camera fovlenght;
00545
00546 if fovy == nil then nil else
00547 SO3CameraSetFOVy sessionstr.V3D_session camera fovy;
00548
00549 if nclip == nil then nil else
00550 SO3CameraSetNearClipDistance sessionstr.V3D_session camera nclip;
00551
00552 if fclip == nil then nil else
00553 SO3CameraSetFarClipDistance sessionstr.V3D_session camera fclip;
00554 );
00555 camera;
00556 }
00557
00558
00559 V3DgetCameraByIndex(sessionstr, idx){
00560 switch sessionstr.V3D_lCamera idx;
00561 }
00562
00563
00564 V3DgetCameraIndex(sessionstr, camera){
00565 let sizelist sessionstr.V3D_lCamera -> size in
00566 let nil -> idx in
00567 let 0 -> i in
00568 (
00569 while i < size && idx == nil do
00570 (
00571 let nth_list sessionstr.V3D_lCamera i -> [sidx cam] in
00572 if cam != camera then nil else
00573 set idx = sidx;
00574
00575 set i = i + 1;
00576 );
00577 idx;
00578 );
00579 }
00580
00581
00582 V3DgetDefaultCamera(sessionstr){
00583 sessionstr.V3D_defaultCamera;
00584 }
00585
00586
00587 V3DsetDefaultCamera(sessionstr, camera){
00588 if camera == nil then nil else
00589 (
00590 set sessionstr.V3D_prevDefaultCamera = sessionstr.V3D_defaultCamera;
00591 set sessionstr.V3D_defaultCamera = camera;
00592 exec sessionstr.V3D_sessionView.V3D_cbCameraChange with [sessionstr.V3D_sessionView sessionstr camera];
00593 );
00594 0;
00595 }
00596
00597
00598 V3DsetCbCameraChange(viewstr, cbfun){
00599 set viewstr.V3D_cbCameraChange = cbfun;
00600 0;
00601 }
00602
00603
00604 V3DrestaurePreviousDefaultCamera(sessionstr){
00605 if sessionstr.V3D_prevDefaultCamera == nil then nil else
00606 let sessionstr.V3D_defaultCamera -> camera in
00607 (
00608 set sessionstr.V3D_defaultCamera = sessionstr.V3D_prevDefaultCamera;
00609 set sessionstr.V3D_prevDefaultCamera = camera;
00610 );
00611 0;
00612 }
00613
00614
00615 V3DdelCamera(sessionstr, camera){
00616 if camera != sessionstr.V3D_defaultCamera then nil else
00617 (
00618 V3DrestaurePreviousDefaultCamera sessionstr;
00619 set sessionstr.V3D_prevDefaultCamera = nil;
00620 V3DchangeCameraViewport sessionstr (V3DgetDefaultViewport (V3DgetSessionView sessionstr)) (V3DgetDefaultCamera sessionstr);
00621 );
00622
00623 SO3ObjectDestroy sessionstr.V3D_session camera;
00624
00625 let V3DgetCameraIndex sessionstr camera -> idx in
00626 set sessionstr.V3D_lCamera = V3DremoveIdxFromList sessionstr.V3D_lCamera idx;
00627 0;
00628 }
00629
00630
00631 V3DaddCamera(sessionstr, name){
00632 let
00633 let 0 -> i in
00634 (
00635 while ((switch sessionstr.V3D_lCamera i) != nil) do
00636 (
00637 set i = i + 1;
00638 );
00639 i;
00640 )
00641 -> idx in
00642 let SO3CameraCreate sessionstr.V3D_session name -> newcam in
00643 (
00644 set sessionstr.V3D_lCamera = V3Dlcat sessionstr.V3D_lCamera [idx newcam]::nil;
00645 if sessionstr.V3D_defaultCamera != nil then nil else
00646 set sessionstr.V3D_defaultCamera = newcam;
00647
00648 newcam;
00649 );
00650 }
00651
00652
00653 V3DsetLight(sessionstr, light, type, dcolor, scolor, range, const, linear, quadr){
00654 if (sessionstr == nil) || (light == nil) then nil else
00655 (
00656 SO3LightSetType sessionstr.V3D_session light type;
00657 SO3LightSetDiffuseColor sessionstr.V3D_session light dcolor;
00658 SO3LightSetSpecularColor sessionstr.V3D_session light scolor;
00659 SO3LightSetAttenuation sessionstr.V3D_session light [range const linear quadr];
00660
00661 light;
00662 );
00663 }
00664
00665
00666 V3DenableLight(sessionstr, light, state){
00667 SO3LightSetVisible sessionstr.V3D_session light state;
00668 0;
00669 }
00670
00671
00672 V3DaddLight(sessionstr, name, father, type, dcolor, scolor, range, const, linear, quadr){
00673 if sessionstr == nil then nil else
00674 let SO3LightCreate sessionstr.V3D_session name -> light in
00675 (
00676 if father == nil then nil else
00677 SO3ObjectLink sessionstr.V3D_session light father;
00678
00679 SO3LightSetType sessionstr.V3D_session light type;
00680 SO3LightSetDiffuseColor sessionstr.V3D_session light dcolor;
00681 SO3LightSetSpecularColor sessionstr.V3D_session light scolor;
00682 SO3LightSetAttenuation sessionstr.V3D_session light [range const linear quadr];
00683 //SO3LightSetVisible sessionstr.V3D_session light 0;
00684
00685 //SO3LightSetSpotFallOff sessionstr.V3D_session light falloff;
00686 //SO3LightSetPowerScale sessionstr.V3D_session light 1000.0;
00687 //SO3ObjectLookAt sessionstr.V3D_session light [0.0 0.0 0.0] 2;
00688 light;
00689 );
00690 }
00691
00692
00693 V3DaddResource(sessionstr, ressource, group, type){
00694 let V3DgetPathFile ressource "" -> [longfile filename] in
00695 if longfile == nil && filename == nil then nil else
00696 (
00697 if (filename == nil) then
00698 SO3AddResourceLocationDirectory (substr longfile 0 ((strlen longfile) - 1)) group
00699 else if (V3DisUrl ressource) then
00700 SO3AddResourceLocationURL ressource group
00701 else if (!strcmpi (V3DgetFileExt filename) "zip") then
00702 SO3AddResourceLocationZIP ressource group
00703 else
00704 SO3SceneLoadResource sessionstr.V3D_session ressource group type;
00705 );
00706 0;
00707 }
00708
00709
00710 V3DaddMesh(sessionstr, file, name, idx, group, father){
00711 if (sessionstr == nil) || (file == nil) then nil else
00712 (
00713 V3DaddResource sessionstr file group SO3_RESOURCE_MESH;
00714
00715 let SO3SceneLoadEntity sessionstr.V3D_session file strcatn idx::"."::name::nil -> mesh in
00716 (
00717 if father == nil then nil else
00718 SO3ObjectLink sessionstr.V3D_session mesh father;
00719 mesh;
00720 );
00721 );
00722 }
00723
00724
00725 V3DaddEditableMesh(sessionstr, file, name, idx, group, father){
00726 if (sessionstr == nil) || (file == nil) then nil else
00727 (
00728 V3DaddResource sessionstr file group SO3_RESOURCE_MESH;
00729
00730 let SO3SceneLoadEntityWithIndex sessionstr.V3D_session file name idx group -> mesh in
00731 (
00732 if father == nil then nil else
00733 SO3ObjectLink sessionstr.V3D_session mesh father;
00734 mesh;
00735 );
00736 );
00737 }
00738
00739
00740 V3DaddShell(sessionstr, name, idx, father, pos, ang){
00741 if sessionstr == nil then nil else
00742 let if name == nil || (!strcmp name "") then idx else if idx == nil || (!strcmp idx "") then name else strcatn idx::"."::name::nil -> name in
00743 let SO3SceneNodeCreate sessionstr.V3D_session name -> shell in
00744 (
00745 if father == nil then nil else
00746 SO3ObjectLink sessionstr.V3D_session shell father;
00747
00748 if pos == nil then nil else
00749 SO3ObjectSetPosition sessionstr.V3D_session shell pos;
00750
00751 if ang == nil then nil else
00752 SO3ObjectSetOrientation sessionstr.V3D_session shell ang;
00753
00754 shell;
00755 );
00756 }
00757
00758
00759 V3DangularTarget(sessionstr, src, dist){
00760 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) src -> [sax say saz] in
00761 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) dist -> [dax day daz] in
00762 let SO3MathsQuatToEulerXYZ SO3ObjectGetOrientation (V3DgetSession sessionstr) src -> [_ oy oz] in
00763 let daz -. saz -> dx in
00764 let -.dax +. sax -> dy in
00765 let day -. say -> dh in
00766 let sqrt ((dx*.dx) +. (dy*.dy)) -> d in
00767 if d >. 0.001 then
00768 //SO3MathsEulerXYZToQuat [(atan (dh/.d)) (atan2 dy dx) 0.0]
00769 SO3MathsEulerXYZToQuat [(atan (dh/.d)) (atan2 dy dx) oz]
00770 else
00771 SO3MathsEulerXYZToQuat [0.0 oy oz];
00772 }
00773
00774
00775 // update axis pos and scale
00776 V3DupdateObjectAxis(viewstr, sessionstr, axisstr){
00777 if (axisstr == nil) || (axisstr.V3D_axisFather) == nil then nil else
00778 let (V3DgetDefaultViewport viewstr) -> viewportstr in
00779 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
00780 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) camera -> [cx cy cz] in
00781 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) axisstr.V3D_axisFather -> [ox oy oz] in
00782 let SO3ObjectGetGlobalOrientation (V3DgetSession sessionstr) axisstr.V3D_axisFather -> quat in
00783 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [_ _ vw vh] in
00784
00785 // same object size on different distances
00786 let SO3CameraGetFOVy sessionstr.V3D_session camera -> fovy in
00787 let if fovy <=. 0.0 then 0.000001 else fovy -> fovy in
00788 let sqrt ((sqr(cx -. ox)) +. (sqr(cy -. oy)) +. (sqr(cz -. oz))) -> dist in
00789 let maxf 0.000001 ((dist /. ((itof vh) /. 2.0)) *. fovy) /. 2.0 -> scale in
00790 (
00791 SO3ObjectSetPosition (V3DgetSession sessionstr) axisstr.V3D_axisShell [ox oy oz];
00792 SO3ObjectSetOrientation (V3DgetSession sessionstr) axisstr.V3D_axisShell quat;
00793 SO3ObjectSetScale (V3DgetSession sessionstr) axisstr.V3D_axisShell [scale scale scale];
00794 //SO3ObjectSetOrientation (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject (V3DangularTarget sessionstr axisstr.V3D_xAxisTextObject camera);
00795 //SO3ObjectSetOrientation (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject (V3DangularTarget sessionstr axisstr.V3D_xAxisTextObject camera);
00796 //SO3ObjectSetOrientation (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject (V3DangularTarget sessionstr axisstr.V3D_xAxisTextObject camera);
00797 );
00798 0;
00799 }
00800
00801
00802 V3DupdateAxisTarget(viewstr, sessionstr){
00803 let sizelist sessionstr.V3D_lAxis -> size in
00804 let 0 -> i in
00805 while i < size do
00806 (
00807 let nth_list sessionstr.V3D_lAxis i -> [refobj axisstr] in
00808 V3DupdateObjectAxis viewstr sessionstr axisstr;
00809
00810 set i = i + 1;
00811 );
00812 0;
00813 }
00814
00815
00816 V3DshowObjectAxis(viewstr, sessionstr, refobj, mode, state){
00817 if (refobj == nil) then nil else
00818 if state then
00819 let (switch sessionstr.V3D_lAxis refobj) -> axisstr in
00820 let if (axisstr != nil) then axisstr else mkV3Daxis [nil nil nil nil nil nil nil nil 0] -> axisstr in
00821 let SO3ObjectGetName (V3DgetSession sessionstr) refobj -> refname in
00822 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) refobj -> pos in
00823 let SO3ObjectGetGlobalOrientation (V3DgetSession sessionstr) refobj -> quat in
00824 let (V3DgetDefaultViewport viewstr) -> viewportstr in
00825 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
00826 (
00827 set axisstr.V3D_iAxisMode = mode;
00828
00829 // reset axis if exist
00830 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_xAxisObject;
00831 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_yAxisObject;
00832 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_zAxisObject;
00833 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject;
00834 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject;
00835 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject;
00836 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_axisShell;
00837
00838 set axisstr.V3D_axisFather = refobj;
00839 set axisstr.V3D_axisShell = SO3SceneNodeCreate (V3DgetSession sessionstr) strcat refname ".coord_axis";
00840
00841 if mode == 2 then
00842 (
00843 set axisstr.V3D_xAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_x.mesh") strcat refname ".coords_ang_axis_x";
00844 set axisstr.V3D_yAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_y.mesh") strcat refname ".coords_ang_axis_y";
00845 set axisstr.V3D_zAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_z.mesh") strcat refname ".coords_ang_axis_z";
00846 )
00847 else
00848 (
00849 set axisstr.V3D_xAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_x.mesh") strcat refname ".coords_axis_x";
00850 set axisstr.V3D_yAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_y.mesh") strcat refname ".coords_axis_y";
00851 set axisstr.V3D_zAxisObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_z.mesh") strcat refname ".coords_axis_z";
00852 );
00853
00854 set axisstr.V3D_xAxisTextObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_x.mesh") strcat refname ".coords_axis_text_x";
00855 set axisstr.V3D_yAxisTextObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_y.mesh") strcat refname ".coords_axis_text_y";
00856 set axisstr.V3D_zAxisTextObject = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_z.mesh") strcat refname ".coords_axis_text_z";
00857
00858 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_xAxisObject 1;
00859 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_yAxisObject 1;
00860 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_zAxisObject 1;
00861 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject 1;
00862 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject 1;
00863 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject 1;
00864
00865 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_xAxisObject axisstr.V3D_axisShell;
00866 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_yAxisObject axisstr.V3D_axisShell;
00867 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_zAxisObject axisstr.V3D_axisShell;
00868 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject axisstr.V3D_axisShell;
00869 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject axisstr.V3D_axisShell;
00870 SO3ObjectLink (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject axisstr.V3D_axisShell;
00871
00872 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_xAxisObject 0;
00873 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_yAxisObject 0;
00874 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_zAxisObject 0;
00875 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject 0;
00876 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject 0;
00877 SO3ObjectSetCastShadows (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject 0;
00878
00879 SO3ObjectSetPosition (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject [95.0 0.0 0.0];
00880 SO3ObjectSetPosition (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject [0.0 95.0 0.0];
00881 SO3ObjectSetPosition (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject [0.0 0.0 95.0];
00882
00883 SO3ObjectSetPosition (V3DgetSession sessionstr) axisstr.V3D_axisShell pos;
00884 SO3ObjectSetOrientation (V3DgetSession sessionstr) axisstr.V3D_axisShell quat;
00885
00886 SO3ObjectSetAutoTracking (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject camera 1 [0.0 0.0 (-.1.0)] nil;
00887 SO3ObjectSetAutoTracking (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject camera 1 [0.0 0.0 (-.1.0)] nil;
00888 SO3ObjectSetAutoTracking (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject camera 1 [0.0 0.0 (-.1.0)] nil;
00889
00890 // TODO change to render priority
00891 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_xAxisObject 1;
00892 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_yAxisObject 1;
00893 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_zAxisObject 1;
00894 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject 1;
00895 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject 1;
00896 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject 1;
00897
00898 set sessionstr.V3D_lAxis = V3Dlcat sessionstr.V3D_lAxis [refobj axisstr]::nil;
00899 )
00900 else
00901 (
00902 let (switch sessionstr.V3D_lAxis refobj) -> axisstr in
00903 if axisstr == nil then nil else
00904 (
00905 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_xAxisObject;
00906 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_yAxisObject;
00907 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_zAxisObject;
00908 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_xAxisTextObject;
00909 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_yAxisTextObject;
00910 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_zAxisTextObject;
00911 SO3ObjectDestroy (V3DgetSession sessionstr) axisstr.V3D_axisShell;
00912
00913 set sessionstr.V3D_lAxis = V3DremoveIdxFromList sessionstr.V3D_lAxis refobj;
00914 );
00915 );
00916 0;
00917 }
00918
00919
00920 // update axis pos and scale
00921 V3DupdateObjectHelper(viewstr, sessionstr, helperstr){
00922 if (helperstr == nil) || (helperstr.V3D_helperFather) == nil then nil else
00923 let (V3DgetDefaultViewport viewstr) -> viewportstr in
00924 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
00925 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) camera -> [cx cy cz] in
00926 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) helperstr.V3D_helperFather -> [ox oy oz] in
00927 let SO3ObjectGetGlobalOrientation (V3DgetSession sessionstr) helperstr.V3D_helperFather -> quat in
00928 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [_ _ vw vh] in
00929
00930 // same object size on different distances
00931 let SO3CameraGetFOVy sessionstr.V3D_session camera -> fovy in
00932 let if fovy <=. 0.0 then 0.000001 else fovy -> fovy in
00933 let sqrt ((sqr(cx -. ox)) +. (sqr(cy -. oy)) +. (sqr(cz -. oz))) -> dist in
00934 let maxf 0.000001 ((dist /. ((itof vh) /. 2.0)) *. fovy) /. 2.0 -> scale in
00935 (
00936 SO3ObjectSetPosition (V3DgetSession sessionstr) helperstr.V3D_helperIcon [ox oy oz];
00937 SO3ObjectSetOrientation (V3DgetSession sessionstr) helperstr.V3D_helperIcon quat;
00938 SO3ObjectSetScale (V3DgetSession sessionstr) helperstr.V3D_helperIcon [scale scale scale];
00939 );
00940 0;
00941 }
00942
00943
00944 V3DupdateHelpersTarget(viewstr, sessionstr){
00945 if !sessionstr.V3D_bHelpersState then nil else
00946 let sizelist sessionstr.V3D_lHelper -> size in
00947 let 0 -> i in
00948 while i < size do
00949 (
00950 let nth_list sessionstr.V3D_lHelper i -> [refobj helperstr] in
00951 V3DupdateObjectHelper viewstr sessionstr helperstr;
00952
00953 set i = i + 1;
00954 );
00955 0;
00956 }
00957
00958
00959 V3DshowObjectHelper(viewstr, sessionstr, refobj, mode, state){
00960 if (refobj == nil) then nil else
00961 if state then
00962 let (switch sessionstr.V3D_lHelper refobj) -> helperstr in
00963 let if helperstr != nil then helperstr else mkV3Dhelper [nil nil mode] -> helperstr in
00964 let SO3ObjectGetName (V3DgetSession sessionstr) refobj -> refname in
00965 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) refobj -> pos in
00966 let SO3ObjectGetGlobalOrientation (V3DgetSession sessionstr) refobj -> quat in
00967 let (V3DgetDefaultViewport viewstr) -> viewportstr in
00968 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
00969 (
00970 // reset helper if exist
00971 SO3ObjectDestroy (V3DgetSession sessionstr) helperstr.V3D_helperIcon;
00972
00973 set helperstr.V3D_helperFather = refobj;
00974
00975 if !sessionstr.V3D_bHelpersState then nil else
00976 (
00977 if mode == 4 then // light
00978 (
00979 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_light.mesh") strcat refname ".helper_light";
00980 )
00981 else if mode == 8 then // camera
00982 (
00983 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_camera.mesh") strcat refname ".helper_camera";
00984 )
00985 else // dummy
00986 (
00987 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_dummy.mesh") strcat refname ".helper_dummy";
00988 );
00989
00990 //SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) helperstr.V3D_helperIcon 1;
00991
00992 SO3ObjectSetCastShadows (V3DgetSession sessionstr) helperstr.V3D_helperIcon 0;
00993
00994 SO3ObjectSetPosition (V3DgetSession sessionstr) helperstr.V3D_helperIcon pos;
00995 SO3ObjectSetOrientation (V3DgetSession sessionstr) helperstr.V3D_helperIcon quat;
00996
00997 // TODO change to render priority
00998 //SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) helperstr.V3D_helperIcon 1;
00999 );
01000
01001 set sessionstr.V3D_lHelper = V3Dlcat sessionstr.V3D_lHelper [refobj helperstr]::nil;
01002 )
01003 else
01004 (
01005 let (switch sessionstr.V3D_lHelper refobj) -> helperstr in
01006 if helperstr == nil then nil else
01007 (
01008 SO3ObjectDestroy (V3DgetSession sessionstr) helperstr.V3D_helperIcon;
01009
01010 set sessionstr.V3D_lHelper = V3DremoveIdxFromList sessionstr.V3D_lHelper refobj;
01011 );
01012 );
01013 0;
01014 }
01015
01016
01017 V3DisSceneHelperVisible(sessionstr){
01018 if !sessionstr.V3D_bHelpersState then 0 else 1;
01019 }
01020
01021
01022 V3DenableHelpers(viewportstr, sessionstr, state){
01023 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
01024 let sizelist sessionstr.V3D_lHelper -> size in
01025 let 0 -> i in
01026 while i < size do
01027 (
01028 let nth_list sessionstr.V3D_lHelper i -> [_ helperstr] in
01029 if state then
01030 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) helperstr.V3D_helperFather -> pos in
01031 let SO3ObjectGetGlobalOrientation (V3DgetSession sessionstr) helperstr.V3D_helperFather -> quat in
01032 let SO3ObjectGetName (V3DgetSession sessionstr) helperstr.V3D_helperFather -> refname in
01033 (
01034 // reset helper if exist
01035 SO3ObjectDestroy (V3DgetSession sessionstr) helperstr.V3D_helperIcon;
01036
01037 if helperstr.V3D_iHelperMode == 4 then // light
01038 (
01039 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_light.mesh") strcat refname ".helper_light";
01040 )
01041 else if helperstr.V3D_iHelperMode == 8 then // camera
01042 (
01043 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_camera.mesh") strcat refname ".helper_camera";
01044 )
01045 else // dummy
01046 (
01047 set helperstr.V3D_helperIcon = SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_dummy.mesh") strcat refname ".helper_dummy";
01048 );
01049
01050 SO3ObjectSetMouseForeGround (V3DgetSession sessionstr) helperstr.V3D_helperIcon 1;
01051
01052 SO3ObjectSetCastShadows (V3DgetSession sessionstr) helperstr.V3D_helperIcon 0;
01053
01054 SO3ObjectSetPosition (V3DgetSession sessionstr) helperstr.V3D_helperIcon pos;
01055 SO3ObjectSetOrientation (V3DgetSession sessionstr) helperstr.V3D_helperIcon quat;
01056
01057 // TODO change to render priority
01058 SO3ObjectSetRenderOverlay (V3DgetSession sessionstr) helperstr.V3D_helperIcon 1;
01059 0;
01060 )
01061 else
01062 (
01063 SO3ObjectDestroy (V3DgetSession sessionstr) helperstr.V3D_helperIcon;
01064 0;
01065 );
01066
01067 set i = i + 1;
01068 );
01069 set sessionstr.V3D_bHelpersState = state;
01070 0;
01071 }
01072
01073
01074 V3DgetObjectFromHelper(sessionstr, obj){
01075 let nil -> found in
01076 (
01077 let sizelist sessionstr.V3D_lHelper -> size in
01078 let 0 -> i in
01079 while i < size && found == nil do
01080 (
01081 let nth_list sessionstr.V3D_lHelper i -> [_ helperstr] in
01082 if helperstr.V3D_helperIcon != obj then nil else
01083 set found = helperstr.V3D_helperFather;
01084
01085 set i = i + 1;
01086 );
01087 if found == nil then obj else found;
01088 );
01089 }
01090
01091
01092 V3DgetObjectSize(sessionstr, object){
01093 let SO3ObjectGetBoundingBoxInfo (V3DgetSession sessionstr) object -> [size _ _] in
01094 size;
01095 }
01096
01097
01098 V3DgetGlobalObjectCenter(sessionstr, object){
01099 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) object -> [x y z] in
01100 let SO3ObjectGetBoundingBoxInfo (V3DgetSession sessionstr) object -> [_ bpos _] in
01101 let bpos -> [bx by bz] in
01102 if bpos == nil then
01103 [x y z]
01104 else
01105 [(x +. bx) (y +. by) (z +. bz)];
01106 }
01107
01108
01109 V3DgetObjectRadius(sessionstr, object){
01110 let V3DgetObjectSize sessionstr object -> size in
01111 let size -> [px py pz] in
01112 let if px >. py then px else py -> radius in
01113 let if radius >. pz then radius else pz -> radius in
01114 let if size == nil then 100.0 else radius -> radius in
01115 radius;
01116 }
01117
01118
01119 V3DisSceneGridVisible(sessionstr){
01120 if sessionstr.V3D_helperGrid == nil then 0 else 1;
01121 }
01122
01123
01124 V3DshowSceneGrid(sessionstr, mode){
01125 if (mode && (sessionstr.V3D_helperGrid != nil)) then nil else
01126 if mode then
01127 (
01128 let SO3SceneNodeCreate (V3DgetSession sessionstr) "default_helper_grid" -> node in
01129 let SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH "helpers/default_grid_helper.mesh") "default_helper_grid_square" -> square in
01130 let square::nil -> lobj in
01131 (
01132 SO3ObjectSetScale (V3DgetSession sessionstr) square [(0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit))];
01133 SO3ObjectLink (V3DgetSession sessionstr) square node;
01134 SO3ObjectSetCastShadows (V3DgetSession sessionstr) square 0;
01135 let -5 * iGlobalUnit -> i in
01136 while i < (5 * iGlobalUnit) do
01137 (
01138 let SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH (if i == 0 then "helpers/h_line_b.mesh" else "helpers/h_line_w.mesh")) strcat "default_helper_grid_hline_" (itoa i) -> hline in
01139 let SO3SceneLoadEntity (V3DgetSession sessionstr) (strcat sV3DDEFAULTRESOURCESPATH (if i == 0 then "helpers/v_line_b.mesh" else "helpers/v_line_w.mesh")) strcat "default_helper_grid_vline_" (itoa i) -> vline in
01140 (
01141 SO3ObjectSetScale (V3DgetSession sessionstr) hline [(0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit))];
01142 SO3ObjectSetScale (V3DgetSession sessionstr) vline [(0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit)) (0.01 *. (itof iGlobalUnit))];
01143 SO3ObjectLink (V3DgetSession sessionstr) hline node;
01144 SO3ObjectLink (V3DgetSession sessionstr) vline node;
01145
01146 SO3ObjectSetCastShadows (V3DgetSession sessionstr) hline 0;
01147 SO3ObjectSetCastShadows (V3DgetSession sessionstr) vline 0;
01148
01149 SO3ObjectSetPosition (V3DgetSession sessionstr) hline [0.0 0.0 (itof i)];
01150 SO3ObjectSetPosition (V3DgetSession sessionstr) vline [(itof i) 0.0 0.0];
01151
01152 set lobj = hline::vline::lobj;
01153 );
01154
01155 set i = i + iGlobalUnit;
01156 );
01157
01158 set sessionstr.V3D_helperGrid = [node lobj];
01159 );
01160 0;
01161 )
01162 else if (sessionstr.V3D_helperGrid != nil) then
01163 let sessionstr.V3D_helperGrid -> [node lobj] in
01164 (
01165 let sizelist lobj -> size in
01166 let 0 -> i in
01167 while i < size do
01168 (
01169 let nth_list lobj i -> obj in
01170 SO3ObjectDestroy (V3DgetSession sessionstr) obj;
01171
01172 set i = i + 1;
01173 );
01174
01175 SO3ObjectDestroy (V3DgetSession sessionstr) node;
01176 set sessionstr.V3D_helperGrid = nil;
01177 0;
01178 )
01179 else nil;
01180 0;
01181 }
01182
01183
01184 V3DcameraPan(sessionstr, viewportstr, x, y){
01185 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
01186 let SO3CameraGetFOVy (V3DgetSession sessionstr) camera -> fovy in
01187 let if fovy <=. 0.0 then 0.000001 else fovy -> fovy in
01188 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [vx vy vw vh] in
01189 let SO3ObjectGetPosition (V3DgetSession sessionstr) camera -> [_ _ dist] in
01190 let ((itof vw)) /. atan fovy -> dx in
01191 let ((-.dist *. ((itof vw))) /. dx /. ((itof vh))) -> coef in
01192 let (itof x) *. coef -> mx in
01193 let (itof y) *. coef -> my in
01194 let [mx my 0.0] -> vect in
01195 SO3ObjectTranslate (V3DgetSession sessionstr) sessionstr.V3D_shellNavigate vect SO3_LOCAL_TS;
01196 0;
01197 }
01198
01199
01200 V3DsetShellNavPos(sessionstr, pos){
01201 SO3ObjectSetPosition (V3DgetSession sessionstr) sessionstr.V3D_shellNavigate pos;
01202 0;
01203 }
01204
01205
01206 V3DsetAmbientLight(sessionstr, color){
01207 SO3SceneSetAmbientLight (V3DgetSession sessionstr) color;
01208 0;
01209 }
01210
01211
01212 V3DgetAmbientLight(sessionstr){
01213 SO3SceneGetAmbientLight (V3DgetSession sessionstr);
01214 }
01215
01216
01217 V3DsetShadowTechnique(sessionstr, type, dist, color, self){
01218 SO3SceneSetShadowTechnique (V3DgetSession sessionstr) (if type == nil then SO3_SHADOWTYPE_NONE else type);
01219 SO3SceneSetShadowFarDistance (V3DgetSession sessionstr) (if dist == nil then 3000.0 else dist);
01220 SO3SceneSetShadowColor (V3DgetSession sessionstr) (if color == nil then 0x000000 else color);
01221 SO3SceneSetSelfShadowTexture (V3DgetSession sessionstr) (if self == nil then 1 else self);
01222 0;
01223 }
01224
01225
01226 V3DsetShadowCameraType(sessionstr, camtype, px, py, pz, pd){
01227 if camtype == SO3_PLANE_SHADOW_CAMERA then
01228 (
01229 SO3SceneSetPlaneShadowCamera (V3DgetSession sessionstr) [px py pz] pd;
01230 )
01231 else if camtype == SO3_FOCUSED_SHADOW_CAMERA then
01232 (
01233 SO3SceneSetFocusedShadowCamera (V3DgetSession sessionstr);
01234 )
01235 else if camtype == SO3_LISPSM_SHADOW_CAMERA then
01236 (
01237 SO3SceneSetLISPSMShadowCamera (V3DgetSession sessionstr);
01238 )
01239 else // SO3_DEFAULT_SHADOW_CAMERA
01240 (
01241 SO3SceneSetDefaultShadowCamera (V3DgetSession sessionstr);
01242 );
01243 0;
01244 }
01245
01246
01247 V3DgetShadowCameraType(sessionstr){
01248 SO3SceneGetShadowCameraSetup (V3DgetSession sessionstr);
01249 }
01250
01251
01252 V3DsetShadowTextureParams(sessionstr, size, count, offset, fadestart, fadestop){
01253 SO3SceneSetShadowTextureSize (V3DgetSession sessionstr) (if size == nil then 512 else size);
01254 SO3SceneSetShadowTextureCount (V3DgetSession sessionstr) (if count == nil then 1 else count);
01255 SO3SceneSetShadowDirLightTextureOffset (V3DgetSession sessionstr) (if offset == nil then 0.0 else offset);
01256 SO3SceneSetShadowTextureFadeStart (V3DgetSession sessionstr) (if fadestart == nil then 0.7 else fadestart);
01257 SO3SceneSetShadowTextureFadeEnd (V3DgetSession sessionstr) (if fadestop == nil then 0.9 else fadestop);
01258 0;
01259 }
01260
01261
01262 V3DsetObjectReceiveShadows(sessionstr, obj, bool){
01263 let SO3EntityMaterialList (V3DgetSession sessionstr) obj -> l in
01264 let sizelist l -> size in
01265 let 0 -> i in
01266 while i < size do
01267 (
01268 let nth_list l i -> mat in
01269 SO3MaterialSetReceiveShadows (V3DgetSession sessionstr) mat bool;
01270
01271 set i = i + 1;
01272 );
01273 0;
01274 }
01275
01276
01277 V3DsetSceneFog(sessionstr, mode, color, density, linearstart, linearend){
01278 let if mode != nil then mode else SO3SceneGetFogMode (V3DgetSession sessionstr) -> mode in
01279 let if color != nil then color else SO3SceneGetFogColor (V3DgetSession sessionstr) -> color in
01280 let if density != nil then density else SO3SceneGetFogDensity (V3DgetSession sessionstr) -> density in
01281 let if linearstart != nil then linearstart else SO3SceneGetFogStart (V3DgetSession sessionstr) -> linearstart in
01282 let if linearend != nil then linearend else SO3SceneGetFogEnd (V3DgetSession sessionstr) -> linearend in
01283 SO3SceneSetFog (V3DgetSession sessionstr) mode color density linearstart linearend;
01284 0;
01285 }
01286
01287
01288 V3DsetSceneAnimationState(sessionstr, state){
01289 set sessionstr.V3D_bAnimations = state;
01290 0;
01291 }
01292
01293
01294 V3DgetSceneAnimationState(sessionstr){
01295 sessionstr.V3D_bAnimations;
01296 }
01297
01298
01299 V3DaddAnimation(sessionstr, obj, name, length, speed, weight, state, loop, transmode, rotmode){
01300 let switchstr sessionstr.V3D_lAnimations name -> animexist in
01301 if animexist != nil then animexist else
01302 let if weight == nil then 1.0 else weight -> weight in
01303 let mkV3Danim [nil obj nil name state SO3_SCENENODE_ANIM nil nil nil nil] -> animstr in
01304 (
01305 set animstr.V3D_anim = SO3SceneCreateSceneNodesAnimation (V3DgetSession sessionstr) obj animstr.V3D_sAnimName length;
01306 SO3AnimationSetLoop (V3DgetSession sessionstr) animstr.V3D_anim loop;
01307 SO3AnimationSetInterpMode (V3DgetSession sessionstr) animstr.V3D_anim transmode;
01308 SO3AnimationSetRotInterpMode (V3DgetSession sessionstr) animstr.V3D_anim rotmode;
01309 SO3AnimationSetWeight (V3DgetSession sessionstr) animstr.V3D_anim weight;
01310 SO3AnimationSetSpeed (V3DgetSession sessionstr) animstr.V3D_anim speed;
01311 set sessionstr.V3D_lAnimations = [name animstr]::sessionstr.V3D_lAnimations;
01312 animstr;
01313 );
01314 }
01315
01316
01317 V3DaddMorphAnimation(sessionstr, anim, obj, name, speed, weight, state, loop){
01318 if anim == nil then nil else
01319 let switchstr sessionstr.V3D_lAnimations name -> animexist in
01320 if animexist != nil then animexist else
01321 let if weight == nil then 1.0 else weight -> weight in
01322 let mkV3Danim [anim obj nil name state SO3_VERTEX_ANIM nil nil nil nil] -> animstr in
01323 (
01324 SO3AnimationSetLoop (V3DgetSession sessionstr) animstr.V3D_anim loop;
01325 SO3AnimationSetWeight (V3DgetSession sessionstr) animstr.V3D_anim weight;
01326 SO3AnimationSetSpeed (V3DgetSession sessionstr) animstr.V3D_anim speed;
01327 set sessionstr.V3D_lAnimations = [name animstr]::sessionstr.V3D_lAnimations;
01328
01329 animstr;
01330 );
01331 }
01332
01333
01334 V3DloadSkeleton(sessionstr, obj, sklfile){
01335 SO3SceneAttachSkeleton (V3DgetSession sessionstr) obj sklfile;
01336 }
01337
01338
01339 V3DgetSkeletonRoot(sessionstr, obj){
01340 SO3GetRootBoneFromMesh (V3DgetSession sessionstr) obj;
01341 }
01342
01343
01344 V3DgetAnimationsFromMesh(sessionstr, obj){
01345 SO3ObjectGetVertexAnimations (V3DgetSession sessionstr) obj;
01346 }
01347
01348
01349 V3DgetMeshAnimationByName(sessionstr, obj, name){
01350 SO3SceneGetAnimation sessionstr.V3D_session obj name;
01351 }
01352
01353
01354 V3DdelAnimation(sessionstr, animstr){
01355 if animstr.V3D_anim == nil then nil else
01356 SO3AnimationDestroy sessionstr.V3D_session animstr.V3D_anim;
01357
01358 set sessionstr.V3D_lAnimations = V3DremoveTupFromListByName sessionstr.V3D_lAnimations animstr.V3D_sAnimName;
01359 0;
01360 }
01361
01362
01363 V3DaddAnimationKey(sessionstr, animstr, obj, pos, quat, scale, ftime){
01364 let SO3ObjectGetAnimTrack sessionstr.V3D_session obj animstr.V3D_anim -> animtrack in
01365 let if animtrack == nil then (SO3SceneCreateAnimTrack sessionstr.V3D_session obj animstr.V3D_anim SO3_NODE_TRACK) else animtrack -> animtrack in
01366 SO3AnimTrackCreateKey sessionstr.V3D_session animtrack ftime pos quat scale;
01367 0;
01368 }
01369
01370
01371 V3DdelAnimationTrack(sessionstr, animstr, obj){
01372 let SO3ObjectGetAnimTrack sessionstr.V3D_session obj animstr.V3D_anim -> animtrack in
01373 if animtrack == nil then nil else
01374 SO3AnimTrackDestroy sessionstr.V3D_session animtrack;
01375 0;
01376 }
01377
01378
01379 V3DgetAnimationByName(sessionstr, name){
01380 if name == nil then nil else
01381 let switchstr sessionstr.V3D_lAnimations name -> animstr in
01382 if animstr == nil then nil else
01383 animstr;
01384 }
01385
01386
01387 V3DsetAnimationWeight(sessionstr, animstr, weight){
01388 SO3AnimationSetWeight (V3DgetSession sessionstr) animstr.V3D_anim weight;
01389 }
01390
01391
01392 V3DgetAnimationWeight(sessionstr, animstr){
01393 SO3AnimationGetWeight (V3DgetSession sessionstr) animstr.V3D_anim;
01394 }
01395
01396
01397 V3DsetAnimationState(sessionstr, animstr, state){
01398 set animstr.V3D_bAnimState = state;
01399 }
01400
01401
01402 V3DsetAnimationLoop(sessionstr, animstr, loop){
01403 SO3AnimationSetLoop sessionstr.V3D_session animstr.V3D_anim loop;
01404 }
01405
01406
01407 V3DsetAnimationSpeed(sessionstr, animstr, speed){
01408 SO3AnimationSetSpeed sessionstr.V3D_session animstr.V3D_anim speed;
01409 }
01410
01411
01412 V3DsetAnimationInterpolationMode(sessionstr, animstr, mode){
01413 SO3AnimationSetInterpMode sessionstr.V3D_session animstr.V3D_anim mode;
01414 }
01415
01416
01417 V3DsetAnimationRotInterpolationMode(sessionstr, animstr, mode){
01418 SO3AnimationSetRotInterpMode sessionstr.V3D_session animstr.V3D_anim mode;
01419 }
01420
01421
01422 V3DgetAnimationState(sessionstr, animstr){
01423 animstr.V3D_bAnimState;
01424 }
01425
01426
01427 V3DgetAnimationLoop(sessionstr, animstr){
01428 SO3AnimationGetLoop sessionstr.V3D_session animstr.V3D_anim;
01429 }
01430
01431
01432 V3DgetAnimationSpeed(sessionstr, animstr){
01433 SO3AnimationGetSpeed sessionstr.V3D_session animstr.V3D_anim;
01434 }
01435
01436
01437 V3DgetAnimationType(animstr){
01438 animstr.V3D_iAnimType;
01439 }
01440
01441
01442 V3DsetAnimationPosition(sessionstr, animstr, pos){
01443 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim pos;
01444 }
01445
01446
01447 V3DgetAnimationPosition(sessionstr, animstr){
01448 SO3AnimationGetTimePosition sessionstr.V3D_session animstr.V3D_anim;
01449 }
01450
01451
01452 V3DgetAnimationLenght(sessionstr, animstr){
01453 SO3AnimationGetLenght sessionstr.V3D_session animstr.V3D_anim;
01454 }
01455
01456
01457 V3DsetAnimationCbPlay(animstr, cbfun){
01458 set animstr.V3D_cbAnimPlay = cbfun;
01459 }
01460
01461
01462 V3DsetAnimationCbPause(animstr, cbfun){
01463 set animstr.V3D_cbAnimPause = cbfun;
01464 }
01465
01466
01467 V3DsetAnimationCbStop(animstr, cbfun){
01468 set animstr.V3D_cbAnimStop = cbfun;
01469 }
01470
01471
01472 V3DresetAnimation(sessionstr, animstr){
01473 V3DsetAnimationState sessionstr animstr 0;
01474 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 0;
01475 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0;
01476
01477 if animstr.V3D_iAnimType == SO3_SCENENODE_ANIM then
01478 let animstr.V3D_nodePRS -> [vec quat scale] in
01479 (
01480 SO3ObjectSetPosition sessionstr.V3D_session animstr.V3D_meshAnim vec;
01481 SO3ObjectSetOrientation sessionstr.V3D_session animstr.V3D_meshAnim quat;
01482 SO3ObjectSetScale sessionstr.V3D_session animstr.V3D_meshAnim scale;
01483 0;
01484 )
01485 else
01486 (
01487 SO3ObjectResetToInitialState sessionstr.V3D_session animstr.V3D_meshAnim;
01488 0;
01489 );
01490 0;
01491 }
01492
01493
01494 V3DresetAnimations(sessionstr){
01495 let sizelist sessionstr.V3D_lAnimations -> size in
01496 let 0 -> i in
01497 while i < size do
01498 (
01499 let nth_list sessionstr.V3D_lAnimations i -> [_ animstr] in
01500 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0;
01501
01502 set i = i + 1;
01503 );
01504 0;
01505 }
01506
01507
01508 V3DpauseAnimation(sessionstr, animstr){
01509 V3DsetAnimationState sessionstr animstr 0;
01510 exec animstr.V3D_cbAnimPause with [animstr];
01511 SO3AnimationSetPause sessionstr.V3D_session animstr.V3D_anim 1;
01512 0;
01513 }
01514
01515
01516 V3DplayAnimation(sessionstr, animstr){
01517 let SO3AnimationGetLenght (V3DgetSession sessionstr) animstr.V3D_anim -> lenght in
01518 let SO3AnimationGetTimePosition (V3DgetSession sessionstr) animstr.V3D_anim -> pos in
01519 if !(SO3AnimationGetPause sessionstr.V3D_session animstr.V3D_anim) || (pos >=. lenght) then
01520 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0
01521 else nil;
01522
01523 V3DsetAnimationState sessionstr animstr 1;
01524
01525 exec animstr.V3D_cbAnimPlay with [animstr];
01526 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 1;
01527 0;
01528 }
01529
01530
01531 V3DplayAnimationFromPos(sessionstr, animstr, startpos){
01532 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim startpos;
01533 V3DsetAnimationState sessionstr animstr 1;
01534 exec animstr.V3D_cbAnimPlay with [animstr];
01535 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 1;
01536 0;
01537 }
01538
01539
01540 V3DstopAnimation(sessionstr, animstr){
01541 V3DsetAnimationState sessionstr animstr 0;
01542 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 0;
01543 exec animstr.V3D_cbAnimStop with [animstr];
01544 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0;
01545 0;
01546 }
01547
01548
01549 V3DenableAnimation(sessionstr, animstr, state){
01550 if !state then
01551 (
01552 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0;
01553 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 0;
01554
01555 if animstr.V3D_iAnimType == SO3_SCENENODE_ANIM then
01556 (
01557 /*
01558 let SO3AnimationListAnimTrack sessionstr.V3D_session animstr.V3D_anim -> l in
01559 let sizelist l -> tsize in
01560 let 0 -> t in
01561 while t < tsize do
01562 (
01563 let nth_list l t -> track in
01564 let SO3AnimTrackGetObject sessionstr.V3D_session track -> obj in
01565 SO3ObjectResetToInitialState sessionstr.V3D_session obj;
01566
01567 set t = t + 1;
01568 );*/
01569 0;
01570 )
01571 else if animstr.V3D_iAnimType == SO3_VERTEX_ANIM || animstr.V3D_iAnimType == SO3_SKELETAL_ANIM then
01572 (
01573 SO3ObjectResetToInitialState sessionstr.V3D_session animstr.V3D_meshAnim;
01574 0;
01575 )
01576 else nil;
01577
01578 )
01579 else
01580 (
01581 if animstr.V3D_iAnimType == SO3_SCENENODE_ANIM then
01582 (
01583 /*
01584 let SO3AnimationListAnimTrack sessionstr.V3D_session animstr.V3D_anim -> l in
01585 let sizelist l -> tsize in
01586 let 0 -> t in
01587 while t < tsize do
01588 (
01589 let nth_list l t -> track in
01590 let SO3AnimTrackGetObject sessionstr.V3D_session track -> obj in
01591 SO3ObjectSetInitialState sessionstr.V3D_session obj;
01592
01593 set t = t + 1;
01594 );*/
01595 0;
01596 )
01597 else if animstr.V3D_iAnimType == SO3_VERTEX_ANIM || animstr.V3D_iAnimType == SO3_SKELETAL_ANIM then
01598 (
01599 SO3ObjectSetInitialState sessionstr.V3D_session animstr.V3D_meshAnim;
01600 0;
01601 )
01602 else nil;
01603
01604 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim animstr.V3D_bAnimState;
01605 0;
01606 );
01607 0;
01608 }
01609
01610
01611 V3DenableAnimations(sessionstr, state){
01612 let sizelist sessionstr.V3D_lAnimations -> size in
01613 let 0 -> i in
01614 while i < size do
01615 (
01616 let nth_list sessionstr.V3D_lAnimations i -> [_ animstr] in
01617 if !state then
01618 (
01619 SO3AnimationSetTimePosition sessionstr.V3D_session animstr.V3D_anim 0.0;
01620 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim 0;
01621
01622 if animstr.V3D_iAnimType == SO3_SCENENODE_ANIM then
01623 (
01624 /*
01625 let SO3AnimationListAnimTrack sessionstr.V3D_session animstr.V3D_anim -> l in
01626 let sizelist l -> tsize in
01627 let 0 -> t in
01628 while t < tsize do
01629 (
01630 let nth_list l t -> track in
01631 let SO3AnimTrackGetObject sessionstr.V3D_session track -> obj in
01632 SO3ObjectResetToInitialState sessionstr.V3D_session obj;
01633
01634 set t = t + 1;
01635 );*/
01636 0;
01637 )
01638 else if animstr.V3D_iAnimType == SO3_VERTEX_ANIM || animstr.V3D_iAnimType == SO3_SKELETAL_ANIM then
01639 (
01640 SO3ObjectResetToInitialState sessionstr.V3D_session animstr.V3D_meshAnim;
01641 0;
01642 )
01643 else nil;
01644
01645 )
01646 else
01647 (
01648 if animstr.V3D_iAnimType == SO3_SCENENODE_ANIM then
01649 (
01650 /*
01651 let SO3AnimationListAnimTrack sessionstr.V3D_session animstr.V3D_anim -> l in
01652 let sizelist l -> tsize in
01653 let 0 -> t in
01654 while t < tsize do
01655 (
01656 let nth_list l t -> track in
01657 let SO3AnimTrackGetObject sessionstr.V3D_session track -> obj in
01658 SO3ObjectSetInitialState sessionstr.V3D_session obj;
01659
01660 set t = t + 1;
01661 );*/
01662 0;
01663 )
01664 else if animstr.V3D_iAnimType == SO3_VERTEX_ANIM || animstr.V3D_iAnimType == SO3_SKELETAL_ANIM then
01665 (
01666 SO3ObjectSetInitialState sessionstr.V3D_session animstr.V3D_meshAnim;
01667 0;
01668 )
01669 else nil;
01670
01671 SO3AnimationSetEnable sessionstr.V3D_session animstr.V3D_anim animstr.V3D_bAnimState;
01672 );
01673
01674 set i = i + 1;
01675 );
01676 0;
01677 }
01678
01679
01680 V3DanimationEditorValues(sessionstr, state){
01681 if !state then nil else
01682 let sizelist sessionstr.V3D_lAnimations -> size in
01683 let 0 -> i in
01684 while i < size do
01685 (
01686 let nth_list sessionstr.V3D_lAnimations i -> [_ animstr] in
01687 (
01688 let V3DgetAnimationState sessionstr animstr -> state in
01689 let V3DgetAnimationLoop sessionstr animstr -> loop in
01690 let V3DgetAnimationSpeed sessionstr animstr -> speed in
01691 let V3DgetAnimationWeight sessionstr animstr -> weight in
01692 set animstr.V3D_AnimEditorValues = [state loop speed weight];
01693
01694 set animstr.V3D_nodePRS = [(SO3ObjectGetPosition sessionstr.V3D_session animstr.V3D_meshAnim) (SO3ObjectGetOrientation sessionstr.V3D_session animstr.V3D_meshAnim) (SO3ObjectGetScale sessionstr.V3D_session animstr.V3D_meshAnim)];
01695 0;
01696 );
01697
01698 set i = i + 1;
01699 );
01700
01701 V3DresetAnimations sessionstr;
01702 V3DenableAnimations sessionstr state;
01703 V3DsetSceneAnimationState sessionstr state;
01704
01705 if state then nil else
01706 let sizelist sessionstr.V3D_lAnimations -> size in
01707 let 0 -> i in
01708 while i < size do
01709 (
01710 let nth_list sessionstr.V3D_lAnimations i -> [_ animstr] in
01711 let animstr.V3D_AnimEditorValues -> [state loop speed weight] in
01712 (
01713 V3DsetAnimationState sessionstr animstr state;
01714 V3DsetAnimationLoop sessionstr animstr loop;
01715 V3DsetAnimationSpeed sessionstr animstr speed;
01716 V3DsetAnimationWeight sessionstr animstr weight;
01717
01718 let animstr.V3D_nodePRS -> [vec quat scale] in
01719 (
01720 SO3ObjectSetPosition sessionstr.V3D_session animstr.V3D_meshAnim vec;
01721 SO3ObjectSetOrientation sessionstr.V3D_session animstr.V3D_meshAnim quat;
01722 SO3ObjectSetScale sessionstr.V3D_session animstr.V3D_meshAnim scale;
01723 );
01724 0;
01725 );
01726
01727 set i = i + 1;
01728 );
01729 0;
01730 }
01731
01732
01733 /* ********************************************************************************************* /
01734 RENDER
01735 / ********************************************************************************************* */
01736
01737 cbV3DbufferPreRender(buffer, viewstr){
01738 exec viewstr.V3D_cbPreRender with [viewstr];
01739
01740 if viewstr.V3D_bPaused then nil else
01741 exec viewstr.V3D_cbPreRenderEffects with [viewstr];
01742
01743 let [viewstr.V3D_iMoveX-(viewstr.V3D_iWinW>>1) (viewstr.V3D_iWinH>>1)-viewstr.V3D_iMoveY] -> [x y] in
01744 let sizelist viewstr.V3D_lSessions -> size in
01745 let 0 -> i in
01746 while i < size do
01747 (
01748 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
01749 (
01750 let sessionstr.V3D_selectedAxis -> [axisstr _] in
01751 // Camera rotation on mouse drag
01752 if (viewstr.V3D_iMoveClickStatus != 1) || (!sessionstr.V3D_bNavigate) || ((axisstr != nil) && axisstr.V3D_iAxisMode) then nil else
01753 let [(viewstr.V3D_iMoveX-viewstr.V3D_iClickX) (viewstr.V3D_iClickY-viewstr.V3D_iMoveY)] -> [dx dy] in
01754 let 1.0 /. (((itof viewstr.V3D_iWinW * 2) /. ((itof dx) +. 0.000001)) +. 0.000001) -> fdx in
01755 let 1.0 /. (((itof viewstr.V3D_iWinH * 2) /. ((itof dy) +. 0.000001)) +. 0.000001) -> fdy in
01756 (
01757 SO3ObjectRotateYaw sessionstr.V3D_session sessionstr.V3D_shellNavigate (-. fdx) SO3_WORLD_TS;
01758 SO3ObjectRotatePitch sessionstr.V3D_session sessionstr.V3D_shellNavigate (-. fdy) SO3_LOCAL_TS;
01759 );
01760
01761 if (viewstr.V3D_iMoveClickStatus != 16) || (!sessionstr.V3D_bNavigate) then nil else
01762 (
01763 let if viewstr.V3D_iRenderMoveX == nil then viewstr.V3D_iClickX else viewstr.V3D_iRenderMoveX -> mvx in
01764 let if viewstr.V3D_iRenderMoveY == nil then viewstr.V3D_iClickY else viewstr.V3D_iRenderMoveY -> mvy in
01765 let [(viewstr.V3D_iMoveX-mvx) (mvy-viewstr.V3D_iMoveY)] -> [dx dy] in
01766 V3DcameraPan sessionstr V3DgetDefaultViewport viewstr dx dy;
01767 );
01768
01769 let if viewstr.V3D_iRenderTick == 0 then _tickcount else viewstr.V3D_iRenderTick -> lasttick in
01770 (
01771 let sizelist viewstr.V3D_lViewport -> vsize in
01772 let 0 -> v in
01773 while v < vsize do
01774 (
01775 let nth_list viewstr.V3D_lViewport v -> [_ viewportstr] in
01776 if !(SO3DebugGetEnable viewportstr.V3D_viewport) then nil else
01777 let _tickcount -> curtick in
01778 let (curtick - viewstr.V3D_iRenderTick) -> frametime in
01779 let if frametime <= 0 then 1 else frametime -> frametime in
01780 SO3DebugSetText viewportstr.V3D_viewport strcatn "FPS : "::(itoa (1000 / frametime))::"\n"::"Frametime : "::(itoa frametime)::"\n"::"Polygon count : "::(itoa SO3BufferGetTriangleCount viewstr.V3D_buffer)::"\n"::nil;
01781
01782 set v = v + 1;
01783 );
01784 set viewstr.V3D_iRenderTick = _tickcount;
01785 );
01786
01787 V3DupdateAxisTarget viewstr sessionstr;
01788 V3DupdateHelpersTarget viewstr sessionstr;
01789 );
01790 set i = i + 1;
01791 );
01792
01793 set viewstr.V3D_iRenderMoveX = viewstr.V3D_iMoveX;
01794 set viewstr.V3D_iRenderMoveY = viewstr.V3D_iMoveY;
01795 0;
01796 }
01797
01798
01799 cbV3DbufferPostRender(buffer, viewstr){
01800 exec viewstr.V3D_cbPostRender with [viewstr];
01801 0;
01802 }
01803
01804
01805 cbV3Drender(viewstr){
01806 0;
01807 }
01808
01809
01810 cbV3DtickRender(tmr, viewstr){
01811 cbV3Drender viewstr;
01812 0;
01813 }
01814
01815
01816 V3DdeleteSession(viewstr, sessionstr){
01817 if sessionstr == nil then nil else
01818 (
01819 V3DphysDestroy sessionstr;
01820 SO3SceneDelete sessionstr.V3D_session;
01821
01822 let V3DgetSessionIndex viewstr sessionstr -> idx in
01823 set viewstr.V3D_lSessions = V3DremoveIdxFromList viewstr.V3D_lSessions idx;
01824 );
01825 0;
01826 }
01827
01828
01829 V3DcrSession(viewstr, name){
01830 let
01831 let 0 -> i in
01832 (
01833 while ((switch viewstr.V3D_lSessions i) != nil) do
01834 (
01835 set i = i + 1;
01836 );
01837 i;
01838 )
01839 -> idx in
01840
01841 let mkV3Dsession [viewstr nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] -> sessionstr in
01842 (
01843 set viewstr.V3D_lSessions = V3Dlcat viewstr.V3D_lSessions [idx sessionstr]::nil;
01844
01845 // create the new scene
01846
01847 set sessionstr.V3D_session = SO3SceneCreate viewstr.V3D_channel strcatn (itoa iV3DSessionIndex)::"."::name::nil;
01848 set iV3DSessionIndex = iV3DSessionIndex + 1;
01849
01850 set sessionstr.V3D_bHelpersState = 0;
01851
01852 // create the default camera
01853 V3DaddCamera sessionstr "default_camera";
01854
01855 // create a shell
01856 set sessionstr.V3D_shellNavigate = SO3SceneNodeCreate sessionstr.V3D_session "camshell";
01857
01858 // set the shell position
01859 SO3ObjectSetPosition sessionstr.V3D_session sessionstr.V3D_shellNavigate [0.0 0.0 0.0];
01860
01861 // set the shell orientation
01862 SO3ObjectRotatePitch sessionstr.V3D_session sessionstr.V3D_shellNavigate (-.0.5) SO3_LOCAL_TS;
01863
01864 // link the camera to the shell
01865 SO3ObjectLink sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) sessionstr.V3D_shellNavigate;
01866
01867 // define that the camera always look at this point
01868 //SO3ObjectLookAt sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) [0.0 0.0 0.0] 2;
01869
01870 SO3ObjectSetPosition sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) [0.0 0.0 (5.0 *. itof(iGlobalUnit))];
01871
01872 // set the ambient light color
01873 V3DsetAmbientLight sessionstr 0x000000;
01874
01875 set sessionstr.V3D_bNavigate = 0;
01876
01877 // helpers resources
01878 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helpers.material") "V3DdefaultResources" SO3_RESOURCE_MATERIAL;
01879 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01880 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01881 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01882 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01883 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01884 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01885 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01886 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01887 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01888
01889 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_camera.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01890 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_dummy.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01891 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_light.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01892
01893 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/default_grid_helper.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01894 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/h_line_b.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01895 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/h_line_w.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01896 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/v_line_b.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01897 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/v_line_w.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01898
01899 V3DphysCreate sessionstr;
01900
01901 sessionstr;
01902 );
01903 }
01904
01905
01906 V3DresetSession(sessionstr){
01907 SO3SceneClear sessionstr.V3D_session;
01908 SO3GroupDelete "V3DdefaultResources";
01909
01910 set sessionstr.V3D_lCamera = nil;
01911 set sessionstr.V3D_lAxis = nil;
01912 set sessionstr.V3D_lHelper = nil;
01913 set sessionstr.V3D_shellNavigate = nil;
01914 set sessionstr.V3D_lAnimations = nil;
01915 set sessionstr.V3D_prevDefaultCamera = nil;
01916 set sessionstr.V3D_defaultCamera = nil;
01917
01918 V3DphysReset sessionstr;
01919
01920 SO3GroupCreate "V3DdefaultResources";
01921
01922 V3DsetCamera sessionstr (V3DaddCamera sessionstr "default_camera") nil nil 0.01 nil;
01923
01924 // create a shell
01925 set sessionstr.V3D_shellNavigate = SO3SceneNodeCreate sessionstr.V3D_session "camshell";
01926
01927 // set the shell position
01928 SO3ObjectSetPosition sessionstr.V3D_session sessionstr.V3D_shellNavigate [0.0 0.0 0.0];
01929
01930 // set the shell orientation
01931 SO3ObjectRotatePitch sessionstr.V3D_session sessionstr.V3D_shellNavigate (-.0.5) SO3_LOCAL_TS;
01932
01933 // link the camera to the shell
01934 SO3ObjectLink sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) sessionstr.V3D_shellNavigate;
01935
01936 SO3ObjectSetPosition sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) [0.0 0.0 (5.0 *. itof(iGlobalUnit))];
01937
01938 V3DchangeCameraViewport sessionstr nil (V3DgetDefaultCamera sessionstr);
01939
01940 // helpers resources
01941 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helpers.material") "V3DdefaultResources" SO3_RESOURCE_MATERIAL;
01942 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01943 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01944 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/ang_axis_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01945 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01946 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01947 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01948 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_x.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01949 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_y.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01950 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/coords_axis_text_z.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01951
01952 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_camera.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01953 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_dummy.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01954 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/helper_light.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01955
01956 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/default_grid_helper.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01957 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/h_line_b.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01958 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/h_line_w.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01959 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/v_line_b.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01960 SO3SceneLoadResource sessionstr.V3D_session (strcat sV3DDEFAULTRESOURCESPATH "helpers/v_line_w.mesh") "V3DdefaultResources" SO3_RESOURCE_MESH;
01961
01962 if sessionstr.V3D_helperGrid == nil then nil else
01963 (
01964 set sessionstr.V3D_helperGrid = nil;
01965 V3DshowSceneGrid sessionstr 1;
01966 );
01967 0;
01968 }
01969
01970
01971 cbV3DkillFocus(win, viewstr){
01972 if !viewstr.V3D_iClickStatus then nil else
01973 (
01974 if viewstr.V3D_iClickX == nil || viewstr.V3D_iClickY == nil then nil else
01975 exec viewstr.V3D_cbUnClick with [viewstr viewstr.V3D_iClickX viewstr.V3D_iClickY viewstr.V3D_iClickStatus];
01976 set viewstr.V3D_iClickStatus = V3DCLICK_NO;
01977 );
01978
01979 if !viewstr.V3D_iMoveClickStatus then nil else
01980 (
01981 if viewstr.V3D_iMoveX == nil || viewstr.V3D_iMoveY == nil then nil else
01982 exec viewstr.V3D_cbUnClick with [viewstr viewstr.V3D_iMoveX viewstr.V3D_iMoveY viewstr.V3D_iMoveClickStatus];
01983 set viewstr.V3D_iMoveClickStatus = V3DCLICK_NO;
01984 );
01985 0;
01986 }
01987
01988
01989 V3DflashCtrlHasFocus(viewstr){
01990 let sizelist viewstr.V3D_lViewport -> sizev in
01991 let 0 -> iv in
01992 let nil -> ret in
01993 (
01994 while (iv < sizev && ret == nil) do
01995 (
01996 let nth_list viewstr.V3D_lViewport iv -> [_ viewportstr] in
01997 let sizelist viewportstr.V3D_lFlashControl -> size in
01998 let 0 -> i in
01999 while (i < size && ret == nil) do
02000 (
02001 let nth_list viewportstr.V3D_lFlashControl i -> flashctrl in
02002 if ((SO3FlashControlHasFocus flashctrl) && (SO3FlashControlGetKeyboardState flashctrl)) then
02003 set ret = flashctrl
02004 else nil;
02005
02006 set i = i + 1;
02007 );
02008
02009 set iv = iv + 1;
02010 );
02011 ret;
02012 );
02013 }
02014
02015
02016 V3DviewSetFocus(viewstr){
02017 SO3BufferSetFocus viewstr.V3D_buffer;
02018 0;
02019 }
02020
02021
02022 V3DgetInfosFromCoords(sessionstr, posx, posy){
02023 let nil -> infos in
02024 let V3DgetSessionView sessionstr -> viewstr in
02025 (
02026 let sizelist viewstr.V3D_lViewport -> size in
02027 let 0 -> i in
02028 while i < size do
02029 (
02030 let nth_list viewstr.V3D_lViewport i -> [_ viewportstr] in
02031 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [x y w h] in
02032 let if (posx > x) && (posy > y) && (posx < (x + w)) && (posy < (y + h)) then
02033 SO3ObjectGetInfo sessionstr.V3D_session (SO3ViewportGetCamera viewportstr.V3D_viewport sessionstr.V3D_session) ((itof (posx - x)) /. (itof w)) ((itof (posy - y)) /. (itof h))
02034 else nil
02035 -> objinfos in
02036 if objinfos == nil then nil else
02037 set infos = objinfos;
02038
02039 set i = i + 1;
02040 );
02041 infos;
02042 );
02043 }
02044
02045
02046 V3DgetExInfosFromCoords(sessionstr, posx, posy){
02047 let nil -> infos in
02048 let V3DgetSessionView sessionstr -> viewstr in
02049 (
02050 let sizelist viewstr.V3D_lViewport -> size in
02051 let 0 -> i in
02052 while i < size do
02053 (
02054 let nth_list viewstr.V3D_lViewport i -> [_ viewportstr] in
02055 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [x y w h] in
02056 let if (posx > x) && (posy > y) && (posx < (x + w)) && (posy < (y + h)) then
02057 SO3ObjectGetInfoEx sessionstr.V3D_session (SO3ViewportGetCamera viewportstr.V3D_viewport sessionstr.V3D_session) ((itof (posx - x)) /. (itof w)) ((itof (posy - y)) /. (itof h))
02058 else nil
02059 -> objinfos in
02060 if objinfos == nil then nil else
02061 set infos = objinfos;
02062
02063 set i = i + 1;
02064 );
02065 // obj mat F I [F F F] [F F F] [F F F] [F F] [F F] [F F] [F F F] [F F]
02066 infos;
02067 );
02068 }
02069
02070
02071 // ret [mode spacing fov]
02072 V3DviewGetStereo(viewstr){
02073 SO3BufferGetStereoVisionProperties viewstr.V3D_buffer;
02074 }
02075
02076
02077 V3DviewGetStereoMode(viewstr){
02078 let SO3BufferGetStereoVisionProperties viewstr.V3D_buffer -> [mode spacing fov] in mode;
02079 }
02080
02081
02082 V3DviewSetStereo(viewstr, mode, spacing, fov){
02083 SO3BufferSetStereoVision viewstr.V3D_buffer mode spacing fov;
02084 0;
02085 }
02086
02087
02088 V3DchangeSelectedAxis(sessionstr, objname, mode){
02089 let SO3SceneGetObject (V3DgetSession sessionstr) objname -> refobj in
02090 let (switch sessionstr.V3D_lAxis refobj) -> axisstr in
02091 set sessionstr.V3D_selectedAxis = [axisstr mode];
02092 0;
02093 }
02094
02095
02096 cbV3DviewDropFile(buffer, viewstr, x, y, lp){
02097 exec viewstr.V3D_cbDropFile with [viewstr x y lp];
02098 0;
02099 }
02100
02101
02102 cbV3DviewKeyDown(buffer, viewstr, key, ascode){
02103 if (V3DflashCtrlHasFocus viewstr) != nil then nil else
02104 (
02105 if key == 328 then // UP
02106 (
02107 let sizelist viewstr.V3D_lSessions -> size in
02108 let 0 -> i in
02109 while i < size do
02110 (
02111 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02112 if !sessionstr.V3D_bNavigate then nil else
02113 (
02114 SO3ObjectRotatePitch sessionstr.V3D_session sessionstr.V3D_shellNavigate (-.0.1) SO3_LOCAL_TS;
02115 );
02116 set i = i + 1;
02117 );
02118 )
02119 else nil;
02120 if key == 336 then // DOWN
02121 (
02122 let sizelist viewstr.V3D_lSessions -> size in
02123 let 0 -> i in
02124 while i < size do
02125 (
02126 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02127 if !sessionstr.V3D_bNavigate then nil else
02128 (
02129 SO3ObjectRotatePitch sessionstr.V3D_session sessionstr.V3D_shellNavigate (0.1) SO3_LOCAL_TS;
02130 );
02131 set i = i + 1;
02132 );
02133 )
02134 else nil;
02135 if key == 331 then // LEFT
02136 (
02137 let sizelist viewstr.V3D_lSessions -> size in
02138 let 0 -> i in
02139 while i < size do
02140 (
02141 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02142 if !sessionstr.V3D_bNavigate then nil else
02143 (
02144 SO3ObjectRotateYaw sessionstr.V3D_session sessionstr.V3D_shellNavigate (-.0.1) SO3_WORLD_TS;
02145 );
02146 set i = i + 1;
02147 );
02148 )
02149 else nil;
02150 if key == 333 then // RIGHT
02151 (
02152 let sizelist viewstr.V3D_lSessions -> size in
02153 let 0 -> i in
02154 while i < size do
02155 (
02156 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02157 if !sessionstr.V3D_bNavigate then nil else
02158 (
02159 SO3ObjectRotateYaw sessionstr.V3D_session sessionstr.V3D_shellNavigate (0.1) SO3_WORLD_TS;
02160 );
02161 set i = i + 1;
02162 );
02163 )
02164 else nil;
02165
02166 exec viewstr.V3D_cbKeyDown with [viewstr key ascode];
02167 );
02168 0;
02169 }
02170
02171
02172 cbV3DviewKeyUp(buffer, viewstr, key){
02173 if (V3DflashCtrlHasFocus viewstr) != nil then nil else
02174 (
02175 exec viewstr.V3D_cbKeyUp with [viewstr key];
02176 );
02177 0;
02178 }
02179
02180
02181 cbV3DviewDbClick(buffer, viewstr, posx, posy, btn){
02182 let (V3DflashCtrlHasFocus viewstr) -> flashctrl in
02183 if (flashctrl != nil) && (SO3FlashControlIsMouseOver flashctrl) then nil else
02184 (
02185 exec viewstr.V3D_cbDbClick with [viewstr posx posy btn];
02186 );
02187 0;
02188 }
02189
02190
02191 cbV3DviewClick(buffer, viewstr, posx, posy, btn, key){
02192 let (V3DflashCtrlHasFocus viewstr) -> flashctrl in
02193 if (flashctrl != nil) && (SO3FlashControlIsMouseOver flashctrl) then nil else
02194 (
02195 SO3BufferSetFocus viewstr.V3D_buffer;
02196 set viewstr.V3D_iClickX = posx;
02197 set viewstr.V3D_iClickY = posy;
02198 set viewstr.V3D_iClickStatus = if btn == nil then V3DCLICK_NO else btn;
02199
02200 let sizelist viewstr.V3D_lSessions -> size in
02201 let 0 -> i in
02202 while i < size do
02203 (
02204 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02205 if sessionstr.V3D_selectedAxis != nil then nil else
02206 let SO3SceneGetLastInfos (V3DgetSession sessionstr) -> infos in
02207 let infos -> [obj mat subid _ _ _ _ _ _ _ _ _ _] in
02208 let sizelist sessionstr.V3D_lAxis -> size2 in
02209 let 0 -> i2 in
02210 while (i2 < size2) && (sessionstr.V3D_selectedAxis == nil) do
02211 (
02212 let nth_list sessionstr.V3D_lAxis i2 -> [_ axisstr] in
02213 if obj == axisstr.V3D_xAxisObject then
02214 (
02215 set sessionstr.V3D_selectedAxis = [axisstr V3DAXIS_X];
02216 exec sessionstr.V3D_cbAxisClick with [sessionstr axisstr.V3D_axisFather V3DAXIS_X posx posy btn];
02217 )
02218 else if obj == axisstr.V3D_yAxisObject then
02219 (
02220 set sessionstr.V3D_selectedAxis = [axisstr V3DAXIS_Y];
02221 exec sessionstr.V3D_cbAxisClick with [sessionstr axisstr.V3D_axisFather V3DAXIS_Y posx posy btn]
02222 )
02223 else if obj == axisstr.V3D_zAxisObject then
02224 (
02225 set sessionstr.V3D_selectedAxis = [axisstr V3DAXIS_Z];
02226 exec sessionstr.V3D_cbAxisClick with [sessionstr axisstr.V3D_axisFather V3DAXIS_Z posx posy btn]
02227 )
02228 else nil;
02229
02230 set i2 = i2 + 1;
02231 );
02232
02233 set i = i + 1;
02234 );
02235
02236 exec viewstr.V3D_cbClick with [viewstr posx posy btn];
02237 );
02238 0;
02239 }
02240
02241
02242 V3DgetCursorTrans(viewstr){
02243 if viewstr.V3D_iMoveClickStatus & (V3DCLICK_LEFT|V3DCLICK_RIGHT|V3DCLICK_MIDDLE) then
02244 [(viewstr.V3D_iMoveX-viewstr.V3D_iClickX) (viewstr.V3D_iClickY-viewstr.V3D_iMoveY)]
02245 else
02246 nil;
02247 }
02248
02249
02250 V3DisClicked(viewstr){
02251 viewstr.V3D_iClickStatus;
02252 }
02253
02254
02255 V3DisMoveClicked(viewstr){
02256 viewstr.V3D_iMoveClickStatus;
02257 }
02258
02259
02260 cbV3DviewUnclick(buffer, viewstr, posx, posy, btn, key){
02261 if (V3DflashCtrlHasFocus viewstr) != nil then nil else
02262 (
02263 if viewstr.V3D_iClickStatus == V3DCLICK_NO && viewstr.V3D_iMoveClickStatus == V3DCLICK_NO then nil else
02264 (
02265 set viewstr.V3D_iClickStatus = V3DCLICK_NO;
02266 set viewstr.V3D_iMoveClickStatus = V3DCLICK_NO;
02267 set viewstr.V3D_iRenderMoveX = nil;
02268 set viewstr.V3D_iRenderMoveY = nil;
02269
02270 let sizelist viewstr.V3D_lSessions -> size in
02271 let 0 -> i in
02272 while i < size do
02273 (
02274 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02275 if sessionstr.V3D_selectedAxis == nil then nil else
02276 let sessionstr.V3D_selectedAxis -> [axisstr axisflag] in
02277 (
02278 exec sessionstr.V3D_cbAxisUnClick with [sessionstr axisstr.V3D_axisFather axisflag posx posy btn];
02279 set sessionstr.V3D_selectedAxis = nil;
02280 );
02281
02282 set i = i + 1;
02283 );
02284
02285 exec viewstr.V3D_cbUnClick with [viewstr posx posy btn];
02286 );
02287 );
02288 0;
02289 }
02290
02291
02292 cbV3DviewWheel(buffer, viewstr, posx, posy, delta, btn){
02293 if (V3DflashCtrlHasFocus viewstr) != nil then nil else
02294 (
02295 let sizelist viewstr.V3D_lSessions -> size in
02296 let 0 -> i in
02297 while i < size do
02298 (
02299 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02300 if !sessionstr.V3D_bNavigate then nil else
02301 let if iGlobalUnit > 1 then ((itof iGlobalUnit) /. 10.0) else (itof iGlobalUnit) -> unitdiv in
02302 (
02303 let SO3ObjectGetPosition sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) -> [_ _ z] in
02304 let ((itof -delta) *. (((absf z) +. 10.0) /. (100.0 /. unitdiv)) ) -> zm in
02305 if zm <. 0.0 && z <=. 0.0 then nil else
02306 SO3ObjectSetPosition sessionstr.V3D_session (V3DgetDefaultCamera sessionstr) [0.0 0.0 z +. zm];
02307 0;
02308 );
02309 set i = i + 1;
02310 );
02311
02312 exec viewstr.V3D_cbWheel with [viewstr posx posy delta btn];
02313 );
02314 0;
02315 }
02316
02317
02318 V3DgetMoveAxis(viewstr, posx, posy, btn){
02319 let sizelist viewstr.V3D_lSessions -> size in
02320 let 0 -> i in
02321 while i < size do
02322 (
02323 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02324 if sessionstr.V3D_lAxis == nil then nil else
02325 (
02326 let SO3SceneGetLastInfos (V3DgetSession sessionstr) -> infos in
02327 let infos -> [obj _ _ _ _ _ _ _ _ _ _ _ _] in
02328
02329 if sessionstr.V3D_selectedAxis != nil then
02330 let sessionstr.V3D_selectedAxis -> [selectedaxisstr axisflag] in
02331 let (V3DgetDefaultViewport viewstr) -> viewportstr in
02332 let SO3ViewportGetCamera viewportstr.V3D_viewport (V3DgetSession sessionstr) -> camera in
02333 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) camera -> [cx cy cz] in
02334 let SO3ObjectGetGlobalPosition (V3DgetSession sessionstr) selectedaxisstr.V3D_axisFather -> [ox oy oz] in
02335
02336 let SO3CameraGetFOVy sessionstr.V3D_session camera -> fovy in
02337 let if fovy <=. 0.0 then 0.000001 else fovy -> fovy in
02338
02339 let if axisflag == V3DAXIS_X then
02340 [selectedaxisstr.V3D_xAxisObject selectedaxisstr.V3D_xAxisTextObject]
02341 else if axisflag == V3DAXIS_Y then
02342 [selectedaxisstr.V3D_yAxisObject selectedaxisstr.V3D_yAxisTextObject]
02343 else if axisflag == V3DAXIS_Z then
02344 [selectedaxisstr.V3D_zAxisObject selectedaxisstr.V3D_zAxisTextObject]
02345 else nil
02346 -> [axisobj letterobj] in
02347
02348 let SO3ObjectGetScreenPixelCoord (V3DgetSession sessionstr) viewportstr.V3D_viewport axisobj -> [shpx shpy] in
02349 let SO3ObjectGetScreenPixelCoord (V3DgetSession sessionstr) viewportstr.V3D_viewport letterobj -> [lhpx lhpy] in
02350 let [(itof (lhpx-shpx)) (itof (lhpy-shpy))] -> [u v] in
02351
02352 let [(posx - viewstr.V3D_iMoveX) (posy - viewstr.V3D_iMoveY)] -> [mvx mvy] in
02353 let sqrt ((sqr(cx -. ox)) +. (sqr(cy -. oy)) +. (sqr(cz -. oz))) -> dist in
02354 let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [_ _ vw vh] in
02355
02356 // TODO find the real algo ! use global scale ?
02357 let maxf 0.000001 ((dist /. (itof vh)) *. fovy) *. 98.5 -> scale in
02358 let SO3ObjectGetParent (V3DgetSession sessionstr) selectedaxisstr.V3D_axisFather -> ofather in
02359 let if ofather == (SO3ObjectGetSceneRoot (V3DgetSession sessionstr)) then [1.0 1.0 1.0] else SO3ObjectGetGlobalScale (V3DgetSession sessionstr) ofather -> [gsx gsy gsz] in
02360 //let SO3ObjectGetGlobalScale (V3DgetSession sessionstr) selectedaxisstr.V3D_axisFather -> [gsx gsy gsz] in
02361 let if axisflag == V3DAXIS_X then gsx else if axisflag == V3DAXIS_Y then gsy else if axisflag == V3DAXIS_Z then gsz else 1.0 -> gscale in
02362 let ((scale *. (u *. (itof mvx) +. v *. (itof mvy))) /. sqr(0.001+.sqrt((sqr u)+.(sqr v)))) /. gscale -> coef in
02363 (
02364 if u == nil || v == nil then nil else
02365 (
02366 exec sessionstr.V3D_cbAxisMove with [sessionstr selectedaxisstr.V3D_axisFather axisflag mvx mvy btn coef];
02367 );
02368 0;
02369 )
02370 else
02371 (
02372 let sizelist sessionstr.V3D_lAxis -> size2 in
02373 let 0 -> i2 in
02374 while i2 < size2 do
02375 (
02376 let nth_list sessionstr.V3D_lAxis i2 -> [_ axisstr] in
02377 if axisstr.V3D_iAxisMode then
02378 (
02379 if obj == axisstr.V3D_xAxisObject then
02380 (
02381 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_xAxisObject) -> mat in
02382 (
02383 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02384 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02385 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02386 );
02387 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_yAxisObject) -> mat in
02388 (
02389 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02390 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02391 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02392 );
02393 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_zAxisObject) -> mat in
02394 (
02395 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02396 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02397 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02398 );
02399 0;
02400 )
02401 else if obj == axisstr.V3D_yAxisObject then
02402 (
02403 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_xAxisObject) -> mat in
02404 (
02405 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02406 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02407 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02408 );
02409 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_yAxisObject) -> mat in
02410 (
02411 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02412 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02413 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02414 );
02415 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_zAxisObject) -> mat in
02416 (
02417 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02418 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02419 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02420 );
02421 0;
02422 )
02423 else if obj == axisstr.V3D_zAxisObject then
02424 (
02425 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_xAxisObject) -> mat in
02426 (
02427 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02428 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02429 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02430 );
02431 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_yAxisObject) -> mat in
02432 (
02433 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02434 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02435 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02436 );
02437 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_zAxisObject) -> mat in
02438 (
02439 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02440 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02441 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 255 0 0);
02442 );
02443 0;
02444 )
02445 else
02446 (
02447 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_xAxisObject) -> mat in
02448 (
02449 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02450 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02451 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 255 0 0 0);
02452 );
02453 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_yAxisObject) -> mat in
02454 (
02455 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02456 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02457 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 255 0 0);
02458 );
02459 let hd (SO3EntityMaterialList (V3DgetSession sessionstr) axisstr.V3D_zAxisObject) -> mat in
02460 (
02461 SO3MaterialSetSelfIllumination (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02462 SO3MaterialSetAmbient (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02463 SO3MaterialSetDiffuse (V3DgetSession sessionstr) mat (make_rgba 0 0 255 0);
02464 );
02465 0;
02466 );
02467 )
02468 else nil;
02469
02470 set i2 = i2 + 1;
02471 );
02472 0;
02473 );
02474 );
02475
02476 set i = i + 1;
02477 );
02478 0;
02479 }
02480
02481
02482 cbV3DcursorMove(win, viewstr, posx, posy, btn){
02483 let (V3DflashCtrlHasFocus viewstr) -> flashctrl in
02484 if (flashctrl != nil) && (SO3FlashControlIsMouseOver flashctrl) then nil else
02485 (
02486 let if viewstr.V3D_iClickStatus == V3DCLICK_NO then nil else btn -> btn in
02487 (
02488 set viewstr.V3D_iMoveClickStatus = if btn == nil then V3DCLICK_NO else btn;
02489 V3DgetMoveAxis viewstr posx posy btn;
02490
02491 set viewstr.V3D_iMoveX = posx;
02492 set viewstr.V3D_iMoveY = posy;
02493
02494 exec viewstr.V3D_cbCursorMove with [viewstr posx posy btn];
02495 );
02496 );
02497 0;
02498 }
02499
02500
02501 V3DsetCbResizeView(viewstr, cbfun){
02502 set viewstr.V3D_cbResizeView = cbfun;
02503 0;
02504 }
02505
02506
02507 V3DsetCbPreRenderEffects(viewstr, cbfun){
02508 set viewstr.V3D_cbPreRenderEffects = cbfun;
02509 0;
02510 }
02511
02512
02513 V3DsetCbPreRender(viewstr, cbfun){
02514 set viewstr.V3D_cbPreRender = cbfun;
02515 0;
02516 }
02517
02518
02519 V3DsetCbPostRender(viewstr, cbfun){
02520 set viewstr.V3D_cbPostRender = cbfun;
02521 0;
02522 }
02523
02524
02525 V3DsetCbKeyDown(viewstr, cbfun){
02526 set viewstr.V3D_cbKeyDown = cbfun;
02527 0;
02528 }
02529
02530
02531 V3DsetCbKeyUp(viewstr, cbfun){
02532 set viewstr.V3D_cbKeyUp = cbfun;
02533 0;
02534 }
02535
02536
02537 V3DsetCbClick(viewstr, cbfun){
02538 set viewstr.V3D_cbClick = cbfun;
02539 0;
02540 }
02541
02542
02543 V3DsetCbDropFile(viewstr, cbfun){
02544 set viewstr.V3D_cbDropFile = cbfun;
02545 0;
02546 }
02547
02548
02549 V3DgetCbClick(viewstr){
02550 viewstr.V3D_cbClick;
02551 }
02552
02553
02554 V3DsetCbDbClick(viewstr, cbfun){
02555 set viewstr.V3D_cbDbClick = cbfun;
02556 0;
02557 }
02558
02559
02560 V3DgetCbDbClick(viewstr){
02561 viewstr.V3D_cbDbClick;
02562 }
02563
02564
02565 V3DsetCbUnClick(viewstr, cbfun){
02566 set viewstr.V3D_cbUnClick = cbfun;
02567 0;
02568 }
02569
02570
02571 V3DgetCbUnClick(viewstr){
02572 viewstr.V3D_cbUnClick;
02573 }
02574
02575
02576 V3DsetCbWheel(viewstr, cbfun){
02577 set viewstr.V3D_cbWheel = cbfun;
02578 0;
02579 }
02580
02581
02582 V3DgetCbWheel(viewstr){
02583 viewstr.V3D_cbWheel;
02584 }
02585
02586
02587 V3DsetCbCursorMove(viewstr, cbfun){
02588 set viewstr.V3D_cbCursorMove = cbfun;
02589 0;
02590 }
02591
02592
02593 V3DgetCbCursorMove(viewstr){
02594 viewstr.V3D_cbCursorMove;
02595 }
02596
02597
02598 V3DsetCbAxisMove(sessionstr, cbfun){
02599 set sessionstr.V3D_cbAxisMove = cbfun;
02600 0;
02601 }
02602
02603
02604 V3DsetCbAxisClick(sessionstr, cbfun){
02605 set sessionstr.V3D_cbAxisClick = cbfun;
02606 0;
02607 }
02608
02609
02610 V3DsetCbAxisUnClick(sessionstr, cbfun){
02611 set sessionstr.V3D_cbAxisUnClick = cbfun;
02612 0;
02613 }
02614
02615
02616 V3DenableKeyboard(viewstr, mode){
02617 set viewstr.V3D_bKeyboardEnabled = mode;
02618
02619 if !mode then
02620 (
02621 SO3CbBufferKeyDown viewstr.V3D_buffer nil nil ;
02622 SO3CbBufferKeyUp viewstr.V3D_buffer nil nil ;
02623 //_CBwinKeydown viewstr.V3D_win nil nil;
02624 //_CBwinKeyup viewstr.V3D_win nil nil;
02625 )
02626 else
02627 (
02628 SO3CbBufferKeyDown viewstr.V3D_buffer @cbV3DviewKeyDown viewstr;
02629 SO3CbBufferKeyUp viewstr.V3D_buffer @cbV3DviewKeyUp viewstr;
02630 //_CBwinKeydown viewstr.V3D_win @cbV3DviewKeyDown viewstr;
02631 //_CBwinKeyup viewstr.V3D_win @cbV3DviewKeyUp viewstr;
02632 );
02633 0;
02634 }
02635
02636
02637 V3DenableMouse(viewstr, mode){
02638 set viewstr.V3D_bMouseEnabled = mode;
02639 if !mode then
02640 (
02641 SO3CbBufferClick viewstr.V3D_buffer nil nil ;
02642 SO3CbBufferUnclick viewstr.V3D_buffer nil nil ;
02643 SO3CbBufferWheel viewstr.V3D_buffer nil nil ;
02644 SO3CbBufferMouseMove viewstr.V3D_buffer nil nil ;
02645 SO3CbBufferDClick viewstr.V3D_buffer nil nil ;
02646 SO3CbBufferDrop viewstr.V3D_buffer nil nil;
02647 )
02648 else
02649 (
02650 SO3CbBufferClick viewstr.V3D_buffer @cbV3DviewClick viewstr;
02651 SO3CbBufferUnclick viewstr.V3D_buffer @cbV3DviewUnclick viewstr;
02652 SO3CbBufferWheel viewstr.V3D_buffer @cbV3DviewWheel viewstr;
02653 SO3CbBufferMouseMove viewstr.V3D_buffer @cbV3DcursorMove viewstr;
02654 SO3CbBufferDClick viewstr.V3D_buffer @cbV3DviewDbClick viewstr;
02655 SO3CbBufferDrop viewstr.V3D_buffer @cbV3DviewDropFile viewstr;
02656 );
02657 0;
02658 }
02659
02660
02661 V3DenableNavigate(sessionstr, mode){
02662 set sessionstr.V3D_bNavigate = mode;
02663 0;
02664 }
02665
02666
02667 V3DsetCursor(viewstr, cursor){
02668 if (V3DflashCtrlHasFocus viewstr) != nil then nil else
02669 _SETwinCursor viewstr.V3D_win cursor;
02670 0;
02671 }
02672
02673
02674 cbV3DbufferSize(buffer, viewstr, w, h){
02675 exec viewstr.V3D_cbResizeView with [viewstr w h];
02676 0;
02677 }
02678
02679
02680 cbV3Dsize(win, viewstr, w, h){
02681 if w == 0 || h == 0 then nil else
02682 (
02683 set viewstr.V3D_iWinW = w;
02684 set viewstr.V3D_iWinH = h;
02685
02686 SO3BufferSetPositionSize viewstr.V3D_buffer 0 0 w h;
02687 );
02688 0;
02689 }
02690
02691
02692 V3DresizeView(viewstr, x, y, w, h){
02693 set viewstr.V3D_iWinX = x;
02694 set viewstr.V3D_iWinY = y;
02695 set viewstr.V3D_iWinW = w;
02696 set viewstr.V3D_iWinH = h;
02697
02698 _SIZEwindow viewstr.V3D_win viewstr.V3D_iWinW viewstr.V3D_iWinH viewstr.V3D_iWinX viewstr.V3D_iWinY;
02699 0;
02700 }
02701
02702
02703 V3DgetViewPosSize(viewstr){
02704 [viewstr.V3D_iWinX viewstr.V3D_iWinY viewstr.V3D_iWinW viewstr.V3D_iWinH];
02705 }
02706
02707
02708 V3DgetViewPos(viewstr){
02709 [viewstr.V3D_iWinX viewstr.V3D_iWinY];
02710 }
02711
02712
02713 V3DgetViewSize(viewstr){
02714 [viewstr.V3D_iWinW viewstr.V3D_iWinH];
02715 }
02716
02717
02718 V3DgetFullScreenState(viewstr){
02719 viewstr.V3D_bFullScreen;
02720 }
02721
02722
02723 V3DsetScreenInfos(viewstr, x, y, width, height, fsize, fcolor){
02724 let fcolor & 255 -> r in
02725 let (fcolor>>8) & 255 -> g in
02726 let (fcolor>>16) & 255 -> b in
02727 let make_rgba r g b 0 -> crgba in
02728
02729 let V3DgetDefaultSession viewstr -> sessionstr in
02730 let V3DgetDefaultViewport viewstr -> viewportstr in
02731 SO3DebugDisplayProperties sessionstr.V3D_session viewportstr.V3D_viewport nil crgba [x y] [width height] fsize;
02732 0;
02733 }
02734
02735
02736 V3DenableScreenInfos(viewstr, state){
02737 let V3DgetDefaultSession viewstr -> sessionstr in
02738 let V3DgetDefaultViewport viewstr -> viewportstr in
02739 (
02740 SO3DebugSetEnable viewportstr.V3D_viewport state;
02741 SO3WorldShowLines sessionstr.V3D_session state;
02742 );
02743 0;
02744 }
02745
02746
02747 V3DsetWindowedMode(viewstr){
02748 if !viewstr.V3D_bFullScreen then nil else
02749 (
02750 set viewstr.V3D_iWinW = viewstr.V3D_iOldWinW;
02751 set viewstr.V3D_iWinH = viewstr.V3D_iOldWinH;
02752
02753 //_SHOWwindow viewstr.V3D_win WINDOW_UNHIDDEN;
02754
02755 SO3BufferSetProperties viewstr.V3D_buffer 0 viewstr.V3D_iWinW viewstr.V3D_iWinH;
02756
02757 V3DviewSetFocus viewstr;
02758
02759 set viewstr.V3D_bFullScreen = 0;
02760 );
02761 0;
02762 }
02763
02764
02765 V3DEnableRender(viewstr, state){
02766 set viewstr.V3D_bState = state;
02767 0;
02768 }
02769
02770
02771 V3DenableView(viewstr, mode){
02772 if mode then
02773 (
02774 _SHOWwindow viewstr.V3D_win WINDOW_UNHIDDEN;
02775 V3DEnableRender viewstr 1;
02776 )
02777 else if !mode then
02778 (
02779 _SHOWwindow viewstr.V3D_win WINDOW_HIDDEN;
02780 V3DEnableRender viewstr 0;
02781 )
02782 else nil;
02783 0;
02784 }
02785
02786
02787 V3DsetFullScreenMode(viewstr, w, h){
02788 if viewstr.V3D_bFullScreen then nil else
02789 (
02790 //_SHOWwindow viewstr.V3D_win WINDOW_HIDDEN;
02791
02792 set viewstr.V3D_iOldWinW = viewstr.V3D_iWinW;
02793 set viewstr.V3D_iOldWinH = viewstr.V3D_iWinH;
02794
02795 set viewstr.V3D_iWinW = w;
02796 set viewstr.V3D_iWinH = h;
02797
02798 SO3BufferSetProperties viewstr.V3D_buffer 1 viewstr.V3D_iWinW viewstr.V3D_iWinH;
02799
02800 set viewstr.V3D_bFullScreen = 1;
02801 );
02802 0;
02803 }
02804
02805
02806 V3DswitchFullScreenMode(viewstr, w, h){
02807 if viewstr.V3D_bFullScreen then
02808 V3DsetWindowedMode viewstr
02809 else
02810 V3DsetFullScreenMode viewstr w h;
02811 0;
02812 }
02813
02814
02815 V3DdsFlashControl(viewportstr, flashctrl){
02816 set viewportstr.V3D_lFlashControl = remove_from_list viewportstr.V3D_lFlashControl flashctrl;
02817 SO3FlashControlDestroy flashctrl;
02818 0;
02819 }
02820
02821
02822 V3DcbFlashControlMouseIn(flashctrl, viewstr){
02823 0;
02824 }
02825
02826
02827 V3DcbFlashControlMouseOut(flashctrl, viewstr){
02828 0;
02829 }
02830
02831
02832 V3DcrFlashControl(viewstr, viewportstr, file, x, y, w, h, zorder, name, type, flag){
02833 let SO3FlashControlCreate viewstr.V3D_channel viewportstr.V3D_viewport x y w h zorder name flag -> flashctrl in
02834 (
02835 if type == 0 then SO3FlashControlLoadFile flashctrl _checkpack file else SO3FlashControlLoadUrl flashctrl file;
02836 set viewportstr.V3D_lFlashControl = flashctrl::viewportstr.V3D_lFlashControl;
02837 SO3CbInsideEventFlashControl flashctrl @V3DcbFlashControlMouseIn viewstr;
02838 SO3CbOutsideEventFlashControl flashctrl @V3DcbFlashControlMouseOut viewstr;
02839 flashctrl;
02840 );
02841 }
02842
02843
02844 V3DcrFlashControlOnMaterial(viewstr, mat, tec, pass, index, file, w, h, name, type){
02845 let V3DgetDefaultSession viewstr -> sessionstr in
02846 let SO3MaterialSetFlash viewstr.V3D_channel sessionstr.V3D_session mat tec pass index w h name -> flashctrl in
02847 (
02848 if type == 0 then SO3FlashControlLoadFile flashctrl _checkpack file else SO3FlashControlLoadUrl flashctrl file;
02849 //set viewportstr.V3D_lFlashControl = flashctrl::viewportstr.V3D_lFlashControl;
02850 flashctrl;
02851 );
02852 }
02853
02854
02855 V3DcrView(chan, fatherwin, ix, iy, iw, ih, cbinit, cbdestroy, defview){
02856 // init the ogre resources location to scol partitions
02857 SO3InitSCOLResourceLocations;
02858
02859 let mkV3Dview [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil 0 1] -> viewstr in
02860 let _CRwindow chan fatherwin ix iy iw ih WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER strcatn (itoa iV3DIndex)::".v3dwin"::nil -> win in
02861 (
02862 SO3GroupCreate "V3DdefaultResources";
02863
02864 set viewstr.V3D_channel = chan;
02865
02866 // set the buffer window
02867 set viewstr.V3D_buffer = SO3BufferCreate chan win 0 0 iw ih;
02868 SO3CbBufferSize viewstr.V3D_buffer @cbV3DbufferSize viewstr;
02869 SO3CbBufferPreRender viewstr.V3D_buffer @cbV3DbufferPreRender viewstr;
02870 SO3CbBufferPostRender viewstr.V3D_buffer @cbV3DbufferPostRender viewstr;
02871
02872 _SHOWwindow win WINDOW_HIDDEN;
02873 _CBwinKillFocus win @cbV3DkillFocus viewstr;
02874 _CBwinSize win @cbV3Dsize viewstr;
02875
02876 set viewstr.V3D_win = win;
02877 set viewstr.V3D_iWinW = iw;
02878 set viewstr.V3D_iWinH = ih;
02879 set viewstr.V3D_iWinX = ix;
02880 set viewstr.V3D_iWinY = iy;
02881
02882 set viewstr.V3D_iMoveClickStatus = V3DCLICK_NO;
02883 set viewstr.V3D_iClickStatus = V3DCLICK_NO;
02884 set viewstr.V3D_bMouseEnabled = 0;
02885 set viewstr.V3D_bKeyboardEnabled = 0;
02886 set viewstr.V3D_bPaused = 0;
02887 set viewstr.V3D_iRenderTick = _tickcount;
02888
02889 set viewstr.V3D_cbDestroy = cbdestroy;
02890 set viewstr.V3D_cbInit = cbinit;
02891
02892 // default session
02893 if !defview then nil else
02894 V3DcrSession viewstr "main";
02895
02896
02897 set iV3DIndex = iV3DIndex + 1;
02898
02899 exec viewstr.V3D_cbInit with [viewstr];
02900
02901 viewstr;
02902 );
02903 }
02904
02905
02906 V3DdsView(viewstr){
02907 let sizelist viewstr.V3D_lViewport -> size in
02908 let 0 -> i in
02909 while i < size do
02910 (
02911 let nth_list viewstr.V3D_lViewport i -> [_ viewportstr] in
02912 V3DdelViewport viewstr viewportstr;
02913
02914 set i = i + 1;
02915 );
02916
02917 let sizelist viewstr.V3D_lSessions -> size in
02918 let 0 -> i in
02919 while i < size do
02920 (
02921 let nth_list viewstr.V3D_lSessions i -> [_ sessionstr] in
02922 (
02923 SO3SceneDelete sessionstr.V3D_session;
02924 );
02925 set i = i + 1;
02926 );
02927
02928 SO3DestroyBuffer viewstr.V3D_buffer;
02929
02930 if viewstr.V3D_win == nil then nil else
02931 _DSwindow viewstr.V3D_win;
02932
02933 SO3GroupDelete "V3DdefaultResources";
02934
02935 exec viewstr.V3D_cbDestroy with [viewstr];
02936 0;
02937 }
02938
02939
02940 cbV3DdsMainWin(win, viewstr){
02941 V3DdsView viewstr;
02942 _closemachine;
02943 0;
02944 }
02945
02946
02947 cbV3DsizeMainWin(win, viewstr, w, h){
02948 V3DresizeView viewstr viewstr.V3D_iWinX viewstr.V3D_iWinY w h;
02949 0;
02950 }
02951 // -- [/filterPKG] --
02952