/project/max5_modifier/max_joint.cpp

http://narutortsproject.googlecode.com/ · C++ · 831 lines · 517 code · 154 blank · 160 comment · 47 complexity · 1f1e5cf6912dbc0b90cbd79d5c099c38 MD5 · raw file

  1. #include <crtdbg.h>
  2. #include "max5_modifier_mod.h"
  3. #include "max_joint.h"
  4. JointObjectClassDesc joint_object_class_desc;
  5. int JointObjectClassDesc::IsPublic()
  6. {
  7. return 1;
  8. };
  9. void * JointObjectClassDesc::Create(BOOL loading)
  10. {
  11. return new JointObject;
  12. };
  13. const TCHAR * JointObjectClassDesc::ClassName()
  14. {
  15. static char class_name[MAX_STRING_LENGTH];
  16. strcpy_s(class_name, MAX_STRING_LENGTH, JOINTOBJECT_CLASS_NAME);
  17. return class_name;
  18. };
  19. const TCHAR* JointObjectClassDesc::InternalName()
  20. {
  21. static char class_name[MAX_STRING_LENGTH];
  22. strcpy_s(class_name, MAX_STRING_LENGTH, JOINTOBJECT_CLASS_NAME);
  23. return class_name;
  24. };
  25. HINSTANCE JointObjectClassDesc::HInstance()
  26. {
  27. return hInstance;
  28. }
  29. SClass_ID JointObjectClassDesc::SuperClassID()
  30. {
  31. //return WSM_OBJECT_CLASS_ID;
  32. return GEOMOBJECT_CLASS_ID;
  33. };
  34. Class_ID JointObjectClassDesc::ClassID()
  35. {
  36. return Class_ID (JOINTOBJECT_CLASS_ID, JOINTOBJECT_CLASS_SID);
  37. };
  38. const TCHAR* JointObjectClassDesc::Category()
  39. {
  40. static char class_category[MAX_STRING_LENGTH];
  41. strcpy_s(class_category, MAX_STRING_LENGTH, JOINTOBJECT_CATEGORY);
  42. return class_category;
  43. };
  44. class JointObjectValidator : public PBValidator
  45. {
  46. // pick only
  47. BOOL Validate(PB2Value &v)
  48. {
  49. if (!v.r)
  50. return FALSE;
  51. //static Object *ob;
  52. //ob = (((INode *)v.r)->EvalWorldState(0)).obj;
  53. //if ( ob && (ob->ClassID() == Class_ID(WAYPOINT_CLASS_ID, WAYPOINT_CLASS_SID)) )
  54. return TRUE;
  55. //else
  56. // return FALSE;
  57. }
  58. };
  59. static JointObjectValidator joint_object_point_validator;
  60. class JointObjectPBAccessor : public PBAccessor
  61. {
  62. public:
  63. void TabChanged(tab_changes changeCode, Tab<PB2Value>* tab, ReferenceMaker* owner, ParamID id, int tabIndex, int count)
  64. {
  65. }
  66. void Get(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t, Interval &valid)
  67. {
  68. JointObject* joint_object = (JointObject*) owner;
  69. switch (id)
  70. {
  71. case JO_NODE0:
  72. {
  73. /*ICustButton *iBut = GetICustButton(GetDlgItem(giz->hGizmoParams, IDC_EDIT));
  74. if (GetCOREInterface()->GetSubObjectLevel() == 0)
  75. iBut->Enable(FALSE);
  76. else iBut->Enable(TRUE);
  77. iBut->SetType(CBT_CHECK);
  78. iBut->SetHighlightColor(GREEN_WASH);
  79. ReleaseICustButton(iBut);*/
  80. }
  81. };
  82. }
  83. void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t) // set from v
  84. {
  85. JointObject* joint_object = (JointObject*) owner;
  86. switch (id)
  87. {
  88. case JO_NODE0:
  89. {
  90. //way_point->SetNodeR(WP_NODE_R0, v.i > 0, t);
  91. }
  92. };
  93. }
  94. };
  95. static JointObjectPBAccessor joint_object_point_accessor;
  96. static ParamBlockDesc2 JointObjectDescParam
  97. (
  98. 0, _T("JointObjectParameters"), 0, &joint_object_class_desc, P_AUTO_CONSTRUCT+P_AUTO_UI, 0,
  99. //rollout
  100. IDD_DIALOG_JOINT, "Parameters", 0, 0, NULL,
  101. // params
  102. WP_NODE0, _T("nodePicker1"), TYPE_INODE, 0, "NODE1",
  103. p_ui, TYPE_PICKNODEBUTTON, IDC_BUTTON_BODY1,
  104. end,
  105. WP_NODE1, _T("nodePicker2"), TYPE_INODE, 0, "NODE2",
  106. p_ui, TYPE_PICKNODEBUTTON, IDC_BUTTON_BODY2,
  107. end,
  108. end
  109. );
  110. IObjParam* JointObject::ip = 0;
  111. JointObject* JointObject::editOb = 0;
  112. IParamMap2* JointObject::pmapParam = 0;
  113. //Call back
  114. class JointObjectCreateCallBack: public CreateMouseCallBack {
  115. JointObject* ob;
  116. Point3 p0,p1;
  117. IPoint2 sp0, sp1;
  118. BOOL square;
  119. public:
  120. int proc( ViewExp *vpt,int msg, int point, int flags, IPoint2 m, Matrix3& mat );
  121. void SetObj(JointObject *obj) { ob = obj; }
  122. };
  123. int JointObjectCreateCallBack::proc( ViewExp *vpt,int msg, int point, int flags, IPoint2 m, Matrix3& mat )
  124. {
  125. Point3 d;
  126. if (msg == MOUSE_FREEMOVE)
  127. {
  128. //vpt->SnapPreview(m,m,NULL, SNAP_IN_3D);
  129. } else
  130. if ( msg == MOUSE_POINT || msg == MOUSE_MOVE)
  131. {
  132. if (point == 0)
  133. {
  134. // Find the node and plug in the wire color
  135. ULONG handle;
  136. ob->NotifyDependents(FOREVER, (PartID)&handle, REFMSG_GET_NODE_HANDLE);
  137. INode *node;
  138. node = GetCOREInterface()->GetINodeByHandle(handle);
  139. if (node)
  140. {
  141. Point3 color = GetUIColor(COLOR_POINT_OBJ);
  142. node->SetWireColor(RGB(color.x*255.0f, color.y*255.0f, color.z*255.0f));
  143. }
  144. ob->suspendSnap = TRUE;
  145. #ifdef _3D_CREATE
  146. mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_3D));
  147. #else
  148. mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE));
  149. #endif
  150. } else
  151. if (point == 1)
  152. {
  153. #ifdef _3D_CREATE
  154. mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_3D));
  155. #else
  156. mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE));
  157. #endif
  158. if (msg==MOUSE_POINT)
  159. {
  160. ob->suspendSnap = FALSE;
  161. return 0;
  162. }
  163. return CREATE_STOP;
  164. }
  165. } else
  166. if (msg == MOUSE_ABORT)
  167. {
  168. return CREATE_ABORT;
  169. }
  170. return TRUE;
  171. };
  172. static JointObjectCreateCallBack joint_object_create_call_back;
  173. JointObject::JointObject()
  174. {
  175. pblock = 0;
  176. joint_object_class_desc.MakeAutoParamBlocks(this);
  177. //SetAFlag(A_OBJ_CREATING);
  178. };
  179. JointObject::~JointObject()
  180. {
  181. };
  182. void JointObject::SetNodeR(int node_id, bool val, TimeValue time)
  183. {
  184. pblock->SetValue(node_id, time, BOOL(val));
  185. };
  186. bool JointObject::GetNodeR(int node_id, TimeValue time)
  187. {
  188. BOOL val = FALSE;
  189. pblock->GetValue(node_id, time, val, FOREVER);
  190. return val;
  191. };
  192. RefResult JointObject::NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message )
  193. {
  194. switch (message)
  195. {
  196. case REFMSG_CHANGE:
  197. {
  198. if (editOb==this)
  199. InvalidateUI();
  200. /*if (pblock)
  201. {
  202. for (int i = WP_NODE0; i <= WP_NODE4; i ++)
  203. {
  204. INode* node = 0;
  205. if (pblock->GetValue(i, changeInt.Start(), node, FOREVER) && node)
  206. {
  207. Class_ID node_class = node->ClassID();
  208. Object * node_obj = node->EvalWorldState(changeInt.Start()).obj;
  209. if (node_obj)
  210. {
  211. Class_ID obj_class = node_obj->ClassID();
  212. if (obj_class != Class_ID(WAYPOINT_CLASS_ID, WAYPOINT_CLASS_SID))
  213. pblock->SetValue(i, changeInt.Start(), 0);
  214. }
  215. };
  216. }
  217. }*/
  218. break;
  219. };
  220. }
  221. return(REF_SUCCEED);
  222. };
  223. int JointObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
  224. {
  225. Matrix3 tm(1);
  226. HitRegion hitRegion;
  227. DWORD savedLimits;
  228. Point3 pt(0,0,0);
  229. vpt->getGW()->setTransform(tm);
  230. GraphicsWindow *gw = vpt->getGW();
  231. Material *mtl = gw->getMaterial();
  232. tm = inode->GetObjectTM(t);
  233. MakeHitRegion(hitRegion, type, crossing, 4, p);
  234. gw->setRndLimits(((savedLimits = gw->getRndLimits())|GW_PICK)&~GW_ILLUM);
  235. gw->setHitRegion(&hitRegion);
  236. gw->clearHitCode();
  237. DrawAndHit(t, inode, vpt);
  238. //if (showAxis) {
  239. //DrawAxis(vpt,tm,axisLength,screenSize);
  240. //}
  241. //vpt->getGW()->setTransform(tm);
  242. //vpt->getGW()->marker(&pt,X_MRKR);
  243. gw->setRndLimits(savedLimits);
  244. if ((hitRegion.type != POINT_RGN) && !hitRegion.crossing)
  245. return TRUE;
  246. return gw->checkHitCode();
  247. return 0;
  248. }
  249. void JointObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt)
  250. {
  251. if(suspendSnap)
  252. return;
  253. /*
  254. Matrix3 tm = inode->GetObjectTM(t);
  255. GraphicsWindow *gw = vpt->getGW();
  256. gw->setTransform(tm);
  257. Matrix3 invPlane = Inverse(snap->plane);
  258. // Make sure the vertex priority is active and at least as important as the best snap so far
  259. if(snap->vertPriority > 0 && snap->vertPriority <= snap->priority)
  260. {
  261. Point2 fp = Point2((float)p->x, (float)p->y);
  262. Point2 screen2;
  263. IPoint3 pt3;
  264. Point3 thePoint(0,0,0);
  265. // If constrained to the plane, make sure this point is in it!
  266. if(snap->snapType == SNAP_2D || snap->flags & SNAP_IN_PLANE)
  267. {
  268. Point3 test = thePoint * tm * invPlane;
  269. if(fabs(test.z) > 0.0001) // Is it in the plane (within reason)?
  270. return;
  271. }
  272. gw->wTransPoint(&thePoint,&pt3);
  273. screen2.x = (float)pt3.x;
  274. screen2.y = (float)pt3.y;
  275. // Are we within the snap radius?
  276. int len = (int)Length(screen2 - fp);
  277. if(len <= snap->strength)
  278. {
  279. // Is this priority better than the best so far?
  280. if(snap->vertPriority < snap->priority)
  281. {
  282. snap->priority = snap->vertPriority;
  283. snap->bestWorld = thePoint * tm;
  284. snap->bestScreen = screen2;
  285. snap->bestDist = len;
  286. } else
  287. if(len < snap->bestDist)
  288. {
  289. snap->priority = snap->vertPriority;
  290. snap->bestWorld = thePoint * tm;
  291. snap->bestScreen = screen2;
  292. snap->bestDist = len;
  293. }
  294. }
  295. }*/
  296. };
  297. void JointObject::SetExtendedDisplay(int flags)
  298. {
  299. extDispFlags = flags;
  300. };
  301. int JointObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
  302. {
  303. DrawAndHit(t, inode, vpt);
  304. return 0;
  305. };
  306. CreateMouseCallBack* JointObject::GetCreateMouseCallBack()
  307. {
  308. joint_object_create_call_back.SetObj(this);
  309. return(&joint_object_create_call_back);
  310. };
  311. void JointObject::BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev)
  312. {
  313. editOb = this;
  314. this->ip = ip;
  315. joint_object_class_desc.BeginEditParams(ip, this, flags, prev);
  316. /*static TCHAR stringBuf[MAX_STRING_LENGTH];
  317. strcpy_s(stringBuf, MAX_STRING_LENGTH, NARUTO_PARAMETERS);
  318. if (pmapParam)
  319. {
  320. // Left over from last one created
  321. pmapParam->SetParamBlock(pblock);
  322. } else
  323. {
  324. // Gotta make a new one.
  325. pmapParam = CreateCPParamMap(
  326. WayPointdescParam, WAYPOINT_PARAMDESC_LENGTH,
  327. pblock,
  328. ip,
  329. hInstance,
  330. MAKEINTRESOURCE(IDD_DIALOG_WAYPOINT),
  331. stringBuf, 0);
  332. }
  333. way_point_dlg_proc.SetObject(this);
  334. pmapParam->SetUserDlgProc(&way_point_dlg_proc);*/
  335. };
  336. //On close custom menu
  337. void JointObject::EndEditParams(IObjParam *ip, ULONG flags, Animatable *next)
  338. {
  339. editOb = NULL;
  340. this->ip = NULL;
  341. joint_object_class_desc.EndEditParams(ip, this, flags, next);
  342. ClearAFlag(A_OBJ_CREATING);
  343. /*
  344. if(IsDlgButtonChecked(pmapParam->GetHWnd(), IDC_GRID_HOME_INTENSITY ))
  345. dlgGridColor = GRID_COLOR_HOME_INT;
  346. else if(IsDlgButtonChecked(pmapParam->GetHWnd(), IDC_GRID_HOME_COLOR ))
  347. dlgGridColor = GRID_COLOR_HOME;
  348. else if(IsDlgButtonChecked(pmapParam->GetHWnd(), IDC_GRID_OBJECT_COLOR ))
  349. dlgGridColor = GRID_COLOR_OBJECT;
  350. else
  351. dlgGridColor = GRID_COLOR_GRAY;
  352. */
  353. /*if (flags & END_EDIT_REMOVEUI )
  354. {
  355. DestroyCPParamMap(pmapParam);
  356. pmapParam = 0;
  357. }
  358. this->ip = 0;
  359. way_point_dlg_proc.SetObject(0);*/
  360. };
  361. TCHAR* JointObject::GetObjectName()
  362. {
  363. return JOINTOBJECT_NAME;
  364. };
  365. ObjectState JointObject::Eval(TimeValue time)
  366. {
  367. return ObjectState(this);
  368. };
  369. void JointObject::DeleteThis()
  370. {
  371. delete this;
  372. };
  373. Class_ID JointObject::ClassID()
  374. {
  375. return Class_ID (JOINTOBJECT_CLASS_ID, JOINTOBJECT_CLASS_SID);
  376. };
  377. int JointObject::GetParamBlockIndex(int id)
  378. {
  379. if (pblock && id >= 0 && id < pblock->NumParams())
  380. return id;
  381. else
  382. return -1;
  383. };
  384. void JointObject::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp *vpt, Box3& box )
  385. {
  386. Matrix3 tm;
  387. tm = inode->GetObjectTM(t);
  388. Box3 lbox;
  389. GetLocalBoundBox(t, inode, vpt, lbox);
  390. box = Box3(tm.GetTrans(), tm.GetTrans());
  391. for (int i=0; i<8; i++)
  392. {
  393. box += lbox * tm;
  394. }
  395. };
  396. void JointObject::GetLocalBoundBox(TimeValue t, INode *inode, ViewExp *vpt, Box3& box )
  397. {
  398. Matrix3 tm = inode->GetObjectTM(t);
  399. float size = 20.0;
  400. int screenSize = 0;
  401. //pblock2->GetValue(pointobj_size, t, size, FOREVER);
  402. //pblock2->GetValue(pointobj_screensize, t, screenSize, FOREVER);
  403. float zoom = 1.0f;
  404. if (screenSize)
  405. {
  406. zoom = vpt->GetScreenScaleFactor(tm.GetTrans())*0.005f;
  407. }
  408. if (zoom==0.0f) zoom = 1.0f;
  409. size *= zoom;
  410. box = Box3(Point3(0,0,0), Point3(0,0,0));
  411. box += Point3(size*0.5f, 0.0f, 0.0f);
  412. box += Point3( 0.0f, size*0.5f, 0.0f);
  413. box += Point3( 0.0f, 0.0f, size*0.5f);
  414. box += Point3(-size*0.5f, 0.0f, 0.0f);
  415. box += Point3( 0.0f, -size*0.5f, 0.0f);
  416. box += Point3( 0.0f, 0.0f, -size*0.5f);
  417. box.EnlargeBy(10.0f/zoom);
  418. };
  419. Interval JointObject::ObjectValidity(TimeValue t)
  420. {
  421. return FOREVER;
  422. };
  423. RefTargetHandle JointObject::Clone(RemapDir& remap)
  424. {
  425. JointObject* new_joint = new JointObject();
  426. new_joint->ReplaceReference(0,remap.CloneRef(pblock));
  427. BaseClone(this, new_joint, remap);
  428. return(new_joint);
  429. };
  430. Animatable* JointObject::SubAnim(int i)
  431. {
  432. return pblock;
  433. }
  434. IParamArray* JointObject::GetParamBlock()
  435. {
  436. return (IParamArray*)pblock;
  437. };
  438. IParamBlock2* JointObject::GetParamBlock(int i)
  439. {
  440. return pblock;
  441. }
  442. IParamBlock2* JointObject::GetParamBlockByID(short id)
  443. {
  444. return pblock;
  445. }
  446. RefTargetHandle JointObject::GetReference(int i)
  447. {
  448. return pblock;
  449. }
  450. void JointObject::SetReference(int i, RefTargetHandle rtarg)
  451. {
  452. pblock=(IParamBlock2*)rtarg;
  453. }
  454. void JointObject::InvalidateUI()
  455. {
  456. //pointobj_param_blk.InvalidateUI(pblock2->LastNotifyParamID());
  457. };
  458. void JointObject::UpdateParamblockFromVars()
  459. {
  460. SuspendAnimate();
  461. AnimateOff();
  462. ResumeAnimate();
  463. };
  464. void JointObject::DrawLine(ViewExp *vpt, float x1, float y1, float z1, float x2, float y2, float z2)
  465. {
  466. Point3 pts[2];
  467. pts[0] = Point3(x1, y1, z1); pts[1] = Point3(x2, y2, z2);
  468. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  469. }
  470. void JointObject::DrawArrow(ViewExp *vpt, float x, float y, float z, float size, bool arrow1, bool arrow2)
  471. {
  472. float x1 = x/3.0f;
  473. float y1 = y/3.0f;
  474. float z1 = z/3.0f;
  475. float x2 = 0.75f*x;
  476. float y2 = 0.75f*y;
  477. float z2 = 0.75f*z;
  478. vpt->getGW()->setColor( LINE_COLOR, 0.0f, 1.0f, 0.0f);
  479. DrawLine(vpt, 0.0f, 0.0f, 0.0f, x, y, z);
  480. float d = size/4.0f;
  481. vpt->getGW()->setColor(LINE_COLOR, 1.0f, 1.0f, 0.0f);
  482. //Arrow 1
  483. if (arrow1)
  484. {
  485. DrawLine(vpt, x2, y2, z2, x, y, z);
  486. DrawLine(vpt, x2-d, y2, z2, x, y, z);
  487. DrawLine(vpt, x2+d, y2, z2, x, y, z);
  488. DrawLine(vpt, x2, y2-d, z2, x, y, z);
  489. DrawLine(vpt, x2, y2+d, z2, x, y, z);
  490. DrawLine(vpt, x2, y2, z2-d, x, y, z);
  491. DrawLine(vpt, x2, y2, z2+d, x, y, z);
  492. };
  493. if (arrow2)
  494. {
  495. DrawLine(vpt, x1, y1, z1, 0.0f, 0.0f, 0.0f);
  496. DrawLine(vpt, x1-d, y1, z1, 0.0f, 0.0f, 0.0f);
  497. DrawLine(vpt, x1+d, y1, z1, 0.0f, 0.0f, 0.0f);
  498. DrawLine(vpt, x1, y1-d, z1, 0.0f, 0.0f, 0.0f);
  499. DrawLine(vpt, x1, y1+d, z1, 0.0f, 0.0f, 0.0f);
  500. DrawLine(vpt, x1, y1, z1-d, 0.0f, 0.0f, 0.0f);
  501. DrawLine(vpt, x1, y1, z1+d, 0.0f, 0.0f, 0.0f);
  502. };
  503. };
  504. int JointObject::DrawAndHit(TimeValue t, INode *inode, ViewExp *vpt)
  505. {
  506. float size;
  507. int centerMarker, axisTripod, cross, box, screenSize, drawOnTop;
  508. DWORD dw_color = inode->GetWireColor();
  509. Color color(dw_color);
  510. Interval ivalid = FOREVER;
  511. size = 20.0f;
  512. centerMarker = 0;
  513. axisTripod = 0;
  514. cross = 1;
  515. box = 0;
  516. screenSize = 0;
  517. drawOnTop = 0;
  518. //pblock2->GetValue(pointobj_size, t, size, ivalid);
  519. //pblock2->GetValue(pointobj_centermarker, t, centerMarker, ivalid);
  520. //pblock2->GetValue(pointobj_axistripod, t, axisTripod, ivalid);
  521. //pblock2->GetValue(pointobj_cross, t, cross, ivalid);
  522. //pblock2->GetValue(pointobj_box, t, box, ivalid);
  523. //pblock2->GetValue(pointobj_screensize, t, screenSize, ivalid);
  524. //pblock2->GetValue(pointobj_drawontop, t, drawOnTop, ivalid);
  525. Matrix3 tm(1);
  526. Matrix3 tm_base(1);
  527. Point3 pt(0,0,0);
  528. Point3 pts[5];
  529. tm_base = vpt->getGW()->getTransform();
  530. vpt->getGW()->setTransform(tm);
  531. tm = inode->GetObjectTM(t);
  532. int limits = vpt->getGW()->getRndLimits();
  533. if (drawOnTop)
  534. vpt->getGW()->setRndLimits(limits & ~GW_Z_BUFFER);
  535. if (inode->Selected())
  536. {
  537. vpt->getGW()->setColor( TEXT_COLOR, GetUIColor(COLOR_SELECTION) );
  538. vpt->getGW()->setColor( LINE_COLOR, GetUIColor(COLOR_SELECTION) );
  539. } else if (!inode->IsFrozen() && !inode->Dependent())
  540. {
  541. //vpt->getGW()->setColor( TEXT_COLOR, GetUIColor(COLOR_POINT_AXES) );
  542. //vpt->getGW()->setColor( LINE_COLOR, GetUIColor(COLOR_POINT_AXES) );
  543. vpt->getGW()->setColor( TEXT_COLOR, color);
  544. vpt->getGW()->setColor( LINE_COLOR, color);
  545. }
  546. if (axisTripod) {
  547. //DrawAxis(vpt, tm, size, screenSize);
  548. }
  549. size *= 0.5f;
  550. float zoom = vpt->GetScreenScaleFactor(tm.GetTrans())*0.005f;
  551. if (screenSize)
  552. {
  553. tm.Scale(Point3(zoom,zoom,zoom));
  554. }
  555. vpt->getGW()->setTransform(tm);
  556. if (!inode->IsFrozen() && !inode->Dependent() && !inode->Selected())
  557. {
  558. //vpt->getGW()->setColor(LINE_COLOR, GetUIColor(COLOR_POINT_OBJ));
  559. vpt->getGW()->setColor( LINE_COLOR, color);
  560. }
  561. if (centerMarker) {
  562. vpt->getGW()->marker(&pt,X_MRKR);
  563. }
  564. //if (cross)
  565. {
  566. // X
  567. pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(size, 0.0f, 0.0f);
  568. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  569. // Y
  570. pts[0] = Point3(0.0f, -size, 0.0f); pts[1] = Point3(0.0f, size, 0.0f);
  571. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  572. // Z
  573. pts[0] = Point3(0.0f, 0.0f, -size); pts[1] = Point3(0.0f, 0.0f, size);
  574. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  575. }
  576. {
  577. pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(0.0f, 0.0f, size);
  578. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  579. pts[0] = Point3( size, 0.0f, 0.0f); pts[1] = Point3(0.0f, 0.0f, size);
  580. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  581. pts[0] = Point3(0.0f, -size, 0.0f); pts[1] = Point3(0.0f, 0.0f, size);
  582. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  583. pts[0] = Point3(0.0f, size, 0.0f); pts[1] = Point3(0.0f, 0.0f, size);
  584. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  585. pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(0.0f, 0.0f, -size);
  586. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  587. pts[0] = Point3( size, 0.0f, 0.0f); pts[1] = Point3(0.0f, 0.0f, -size);
  588. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  589. pts[0] = Point3(0.0f, -size, 0.0f); pts[1] = Point3(0.0f, 0.0f, -size);
  590. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  591. pts[0] = Point3(0.0f, size, 0.0f); pts[1] = Point3(0.0f, 0.0f, -size);
  592. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  593. pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(0.0f, -size, 0.0f);
  594. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  595. pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(0.0f, size, 0.0f);
  596. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  597. pts[0] = Point3(size, 0.0f, 0.0f); pts[1] = Point3(0.0f, -size, 0.0f);
  598. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  599. pts[0] = Point3(size, 0.0f, 0.0f); pts[1] = Point3(0.0f, size, 0.0f);
  600. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  601. }
  602. //Link to another node
  603. if (pblock)
  604. {
  605. Matrix3 matrix_base = inode->GetObjectTM(t);
  606. Point3 pos_base = matrix_base.GetRow(3);
  607. for (int node_i = JO_NODE0; node_i <= JO_NODE1; node_i ++)
  608. {
  609. INode* node = 0;
  610. if (pblock->GetValue(node_i, t, node, FOREVER) && node)
  611. {
  612. Matrix3 matrix = node->GetObjectTM(t);
  613. vpt->getGW()->setColor( LINE_COLOR, 0.0f, 1.0f, 0.0f);
  614. Point3 pos = matrix.GetRow(3);
  615. Point3 delta_pos = pos-pos_base;
  616. BOOL arrow_1 = FALSE;
  617. BOOL arrow_2 = FALSE;
  618. pblock->GetValue(node_i+WP_NODE_R0, t, arrow_1, FOREVER);
  619. pblock->GetValue(node_i+WP_NODE_B0, t, arrow_2, FOREVER);
  620. DrawArrow(vpt, delta_pos.x, delta_pos.y, delta_pos.z, size, arrow_1, arrow_2);
  621. }
  622. }
  623. };
  624. if (box)
  625. {
  626. // Make the box half the size
  627. size = size * 0.5f;
  628. // Bottom
  629. pts[0] = Point3(-size, -size, -size);
  630. pts[1] = Point3(-size, size, -size);
  631. pts[2] = Point3( size, size, -size);
  632. pts[3] = Point3( size, -size, -size);
  633. vpt->getGW()->polyline(4, pts, NULL, NULL, TRUE, NULL);
  634. // Top
  635. pts[0] = Point3(-size, -size, size);
  636. pts[1] = Point3(-size, size, size);
  637. pts[2] = Point3( size, size, size);
  638. pts[3] = Point3( size, -size, size);
  639. vpt->getGW()->polyline(4, pts, NULL, NULL, TRUE, NULL);
  640. // Sides
  641. pts[0] = Point3(-size, -size, -size);
  642. pts[1] = Point3(-size, -size, size);
  643. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  644. pts[0] = Point3(-size, size, -size);
  645. pts[1] = Point3(-size, size, size);
  646. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  647. pts[0] = Point3( size, size, -size);
  648. pts[1] = Point3( size, size, size);
  649. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  650. pts[0] = Point3( size, -size, -size);
  651. pts[1] = Point3( size, -size, size);
  652. vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL);
  653. }
  654. vpt->getGW()->setTransform(tm_base);
  655. vpt->getGW()->setRndLimits(limits);
  656. return 1;
  657. };
  658. IOResult JointObject::Load(ILoad *iload)
  659. {
  660. //WAYPOINT_CHUNKID
  661. return IO_OK;
  662. };
  663. IOResult JointObject::Save(ISave *isave)
  664. {
  665. //useless
  666. //isave->BeginChunk(WAYPOINT_CHUNKID);
  667. //isave->EndChunk();
  668. return IO_OK;
  669. };