00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __GZ_TRANSFORM_H__
00024 #define __GZ_TRANSFORM_H__
00025
00032 #include "gzGroup.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00049 class gzTransform : public gzGroup
00050 {
00051 public:
00053
00054 GZ_GRAPH_EXPORT gzTransform(const gzString & name=GZ_EMPTY_STRING);
00056 GZ_GRAPH_EXPORT virtual ~gzTransform(){};
00057
00058 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00059
00060
00061
00063 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00064
00065
00066
00068
00072 GZ_GRAPH_EXPORT virtual gzVoid updateNode();
00073
00075
00078 GZ_GRAPH_EXPORT gzVoid reset(gzBool resetTransform=TRUE,gzBool resetAxis=FALSE);
00079
00080
00082
00085 GZ_GRAPH_EXPORT gzBool isActive();
00086
00088
00092 GZ_GRAPH_EXPORT gzVoid useAccumulatedTransform(gzBool on);
00093
00095 GZ_GRAPH_EXPORT gzBool useAccumulatedTransform() const;
00096
00103 GZ_GRAPH_EXPORT gzVoid setBaseID(gzULong id=0);
00107 GZ_GRAPH_EXPORT gzULong getBaseID();
00108
00109
00110
00111
00112
00113
00116 GZ_GRAPH_EXPORT gzVoid rotate(const gzVec3 &vector , gzReal rotation);
00117
00118 GZ_GRAPH_EXPORT gzVoid rotateHPR(gzReal heading , gzReal pitch , gzReal roll);
00119
00125 GZ_GRAPH_EXPORT gzVoid translate( gzReal dx , gzReal dy , gzReal dz );
00131 GZ_GRAPH_EXPORT gzVoid scale( gzReal sx , gzReal sy , gzReal sz );
00137 GZ_GRAPH_EXPORT gzVoid scale( gzReal s);
00138
00139
00140
00141 GZ_GRAPH_EXPORT gzVoid unitScale();
00142
00143
00144
00146
00150 GZ_GRAPH_EXPORT gzVoid setDirection(const gzVec3 &targetvector, gzReal roll , const gzVec3 &up=gzVec3(0,1,0));
00152
00159 GZ_GRAPH_EXPORT gzVoid setRotation(const gzVec3 &targetvector, gzReal rotation);
00160
00162
00166 GZ_GRAPH_EXPORT gzVoid setHPR( gzReal heading , gzReal pitch , gzReal roll);
00167
00169
00176 GZ_GRAPH_EXPORT gzVoid setTranslation( gzReal dx , gzReal dy , gzReal dz );
00178
00185 GZ_GRAPH_EXPORT gzVoid setScale( gzReal sx , gzReal sy , gzReal sz );
00186
00188 GZ_GRAPH_EXPORT gzVoid setScale( gzReal s );
00189
00191
00195 GZ_GRAPH_EXPORT gzVoid setOrigin( gzReal ox , gzReal oy , gzReal oz , gzBool updateAbsolute=TRUE);
00196
00198
00201 GZ_GRAPH_EXPORT gzVoid setBaseAxis( const gzVec3 &x_axis , const gzVec3 &y_axis , const gzVec3 &z_axis , gzBool updateAbsolute=TRUE);
00202
00203
00204
00205
00207
00214 GZ_GRAPH_EXPORT gzVoid setTranslation( const gzVec3 &xyz_trans );
00216
00223 GZ_GRAPH_EXPORT gzVoid setScale( const gzVec3 &xyz_scale );
00224
00226
00230 GZ_GRAPH_EXPORT gzVoid setOrigin( const gzVec3 &xyz_origin , gzBool updateAbsolute=TRUE);
00231
00233
00237 GZ_GRAPH_EXPORT gzVoid setHPR( const gzVec3 &xyz_hpr );
00238
00239
00240
00246 GZ_GRAPH_EXPORT gzBool getScale( gzReal &sx , gzReal &sy , gzReal &sz );
00250 GZ_GRAPH_EXPORT gzBool hasScale();
00251
00256 GZ_GRAPH_EXPORT gzBool getHPR(gzReal &heading , gzReal &pitch , gzReal &roll);
00257
00261 GZ_GRAPH_EXPORT gzBool hasHPR();
00262
00268 GZ_GRAPH_EXPORT gzBool getTranslation( gzReal &dx , gzReal &dy , gzReal &dz );
00272 GZ_GRAPH_EXPORT gzBool hasTranslation();
00273
00274 GZ_GRAPH_EXPORT gzBool getOrigin( gzReal &ox , gzReal &oy , gzReal &oz );
00275 GZ_GRAPH_EXPORT gzBool hasOrigin();
00276
00277 GZ_GRAPH_EXPORT gzBool getBaseAxis( gzVec3 &x_axis , gzVec3 &y_axis , gzVec3 &z_axis );
00278 GZ_GRAPH_EXPORT gzBool hasBaseAxis();
00279
00280
00281
00287 GZ_GRAPH_EXPORT gzBool getTranslation( gzVec3 &translation );
00288
00289
00290
00292 GZ_GRAPH_EXPORT gzMatrix4 & getTransform();
00294
00297 GZ_GRAPH_EXPORT gzVoid setTransform(const gzMatrix4 &transform);
00298
00300 GZ_GRAPH_EXPORT gzVoid accumulate(const gzMatrix4 &mulTransform);
00301
00302
00303
00304
00313 GZ_GRAPH_EXPORT gzVoid setMaxScale(const gzReal &maxScale);
00314
00316 GZ_GRAPH_EXPORT gzReal getMaxScale();
00317
00319
00322 GZ_GRAPH_EXPORT static gzVoid setCurrentMaxScale( gzContext *context , gzReal scale );
00323
00325
00329 GZ_GRAPH_EXPORT static gzMatrix4 & getCurrentInvertedTransform(gzContext *context);
00330
00332
00335 GZ_GRAPH_EXPORT static gzVoid resetIndex(gzContext *context);
00336
00338
00341 GZ_GRAPH_EXPORT static gzVoid resetPostIndex( gzContext *context );
00342
00344
00347 GZ_GRAPH_EXPORT static gzVoid activateIndex(gzContext *context , gzULong index);
00348
00350
00353 GZ_GRAPH_EXPORT static gzVoid activateCompiledIndex(gzContext *context , gzULong index);
00354
00355
00356
00357
00359 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00360
00362 GZ_GRAPH_EXPORT virtual gzVoid postTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00363
00364
00365
00367 GZ_GRAPH_EXPORT virtual gzVoid write(gzSerializeAdapter *adapter);
00368
00370 GZ_GRAPH_EXPORT virtual gzVoid read(gzSerializeAdapter *adapter);
00371
00373
00376 GZ_GRAPH_EXPORT virtual gzULong getDataSize(gzSerializeAdapter *adapter) const;
00377
00378
00380
00383 GZ_GRAPH_EXPORT virtual gzVoid debugOutput(gzString base , gzString anchor , gzDebugFlags features);
00384
00385
00387
00390 GZ_GRAPH_EXPORT static gzTransform * getClosestTransform(gzNode *node);
00391
00393
00398 GZ_GRAPH_EXPORT static gzMatrix4 getAccumTransform(gzNode *node);
00399
00400
00401 protected:
00402
00403 GZ_GRAPH_EXPORT gzVoid calculateTransform();
00404 GZ_GRAPH_EXPORT gzVoid calculateMaxScale();
00405
00406 gzMatrix4 m_transformMatrix;
00407 gzReal m_maxScale;
00408
00409 gzLateBindData<gzVec3> m_orientation;
00410 gzLateBindData<gzVec3> m_scale;
00411 gzLateBindData<gzVec3> m_translation;
00412 gzLateBindData<gzVec3> m_origo;
00413 gzLateBindData<gzMatrix3> m_base;
00414
00415 gzULong m_baseID;
00416
00417 gzUByte m_accum:1;
00418 gzUByte m_isActive:1;
00419
00420 };
00421
00422
00423 GZ_DECLARE_REFPTR(gzTransform);
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00440 class gzFrameTransformKeyTranslation : public gzReference
00441 {
00442 public:
00444 GZ_GRAPH_EXPORT gzFrameTransformKeyTranslation();
00445
00447 GZ_GRAPH_EXPORT virtual ~gzFrameTransformKeyTranslation();
00448
00449
00451 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00452
00453 private:
00454 friend class gzFrameTransform;
00455
00456 gzULong m_frame;
00457 gzVec3 m_position;
00458 };
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00475 class gzFrameTransformKeyScale : public gzReference
00476 {
00477 public:
00478
00480 GZ_GRAPH_EXPORT gzFrameTransformKeyScale();
00481
00483 GZ_GRAPH_EXPORT virtual ~gzFrameTransformKeyScale();
00484
00485
00487 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00488
00489 private:
00490 friend class gzFrameTransform;
00491
00492 gzULong m_frame;
00493 gzVec3 m_scale;
00494 };
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00511 class gzFrameTransformKeyRotation : public gzReference
00512 {
00513 public:
00515 GZ_GRAPH_EXPORT gzFrameTransformKeyRotation();
00516
00518 GZ_GRAPH_EXPORT virtual ~gzFrameTransformKeyRotation();
00519
00520
00522 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00523
00524 private:
00525 friend class gzFrameTransform;
00526
00527 gzULong m_frame;
00528
00529 gzMatrix4 m_accumRot;
00530
00531
00532 gzVec3 m_rotVector;
00533 gzReal m_angle;
00534 };
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00551
00555 class gzFrameTransform : public gzTransform
00556 {
00557 public:
00559
00566 GZ_GRAPH_EXPORT gzFrameTransform(const gzString & name=GZ_EMPTY_STRING);
00568 GZ_GRAPH_EXPORT virtual ~gzFrameTransform(){};
00569
00570 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00571
00573 GZ_GRAPH_EXPORT gzFrameTransform(const gzFrameTransform ©);
00574
00576 GZ_GRAPH_EXPORT gzFrameTransform & operator=(const gzFrameTransform ©);
00577
00578
00579
00581
00585 GZ_GRAPH_EXPORT virtual gzVoid updateNode();
00586
00587
00589 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00590
00591
00592
00594 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00595
00596
00597
00599 GZ_GRAPH_EXPORT gzULong getStartFrame();
00601 GZ_GRAPH_EXPORT gzULong getLastFrame();
00603 GZ_GRAPH_EXPORT gzBool hasFrames();
00604
00606
00609 GZ_GRAPH_EXPORT gzMatrix4 getFrameTransform(gzULong frame );
00610
00612 GZ_GRAPH_EXPORT gzVoid setFrameTranslation(gzULong frame , gzReal x , gzReal y , gzReal z );
00613
00615 GZ_GRAPH_EXPORT gzVoid setFrameScale(gzULong frame , gzReal sx , gzReal sy , gzReal sz );
00616
00618 GZ_GRAPH_EXPORT gzVoid setFrameRotation(gzULong frame , const gzVec3 &vector , gzReal angle);
00619
00621
00627 GZ_GRAPH_EXPORT gzVoid setFrameHPR(gzULong frame , gzReal heading , gzReal pitch , gzReal roll , const gzVec3 &base=GZ_ONE_VEC3);
00628
00630
00633 GZ_GRAPH_EXPORT gzVoid setFrameRotateTransform(gzULong frame , const gzMatrix4 & transform);
00634
00636 GZ_GRAPH_EXPORT gzBool getFrameTranslation(gzULong frame , gzReal &x , gzReal &y , gzReal &z );
00637
00639 GZ_GRAPH_EXPORT gzBool getFrameScale(gzULong frame , gzReal &x , gzReal &y , gzReal &z );
00640
00642 GZ_GRAPH_EXPORT gzBool getFrameRotation(gzULong frame , gzVec3 &vector , gzReal &angle);
00643
00645 GZ_GRAPH_EXPORT gzULong getStartTranslationFrame();
00646
00648 GZ_GRAPH_EXPORT gzULong getLastTranslationFrame();
00649
00651 GZ_GRAPH_EXPORT gzBool hasTranslationFrames();
00652
00653
00655 GZ_GRAPH_EXPORT gzULong getStartScaleFrame();
00656
00658 GZ_GRAPH_EXPORT gzULong getLastScaleFrame();
00659
00661 GZ_GRAPH_EXPORT gzBool hasScaleFrames();
00662
00663
00665 GZ_GRAPH_EXPORT gzULong getStartRotationFrame();
00666
00668 GZ_GRAPH_EXPORT gzULong getLastRotationFrame();
00669
00671 GZ_GRAPH_EXPORT gzBool hasRotationFrames();
00672
00673
00675 GZ_GRAPH_EXPORT gzVoid calculateRotations();
00676
00678
00681 GZ_GRAPH_EXPORT gzVoid setAccumulativeRotations(gzBool on=TRUE);
00682
00684 GZ_GRAPH_EXPORT gzVoid enableFrameUpdates(gzBool on=TRUE);
00685
00686 private:
00687
00688 gzBoundary getFrameBoundary(gzULong frame);
00689
00690 gzRefDList<gzFrameTransformKeyTranslation> m_keyListTranslation;
00691 gzRefDList<gzFrameTransformKeyScale> m_keyListScale;
00692 gzRefDList<gzFrameTransformKeyRotation> m_keyListRotation;
00693
00694 gzDListIterator<gzFrameTransformKeyTranslation> m_currentKeyTranslation;
00695 gzDListIterator<gzFrameTransformKeyScale> m_currentKeyScale;
00696 gzDListIterator<gzFrameTransformKeyRotation> m_currentKeyRotation;
00697
00698 gzDListIterator<gzFrameTransformKeyTranslation> m_currentNextKeyTranslation;
00699 gzDListIterator<gzFrameTransformKeyScale> m_currentNextKeyScale;
00700 gzDListIterator<gzFrameTransformKeyRotation> m_currentNextKeyRotation;
00701
00702
00703 gzFrameTransformKeyTranslation *getKeyTranslation(gzULong frame);
00704 gzFrameTransformKeyScale *getKeyScale(gzULong frame);
00705 gzFrameTransformKeyRotation *getKeyRotation(gzULong frame);
00706
00707 gzFrameTransformKeyTranslation *getNextKeyTranslation(gzULong frame);
00708 gzFrameTransformKeyScale *getNextKeyScale(gzULong frame);
00709 gzFrameTransformKeyRotation *getNextKeyRotation(gzULong frame);
00710
00711 gzBool m_accumRotations;
00712 gzBool m_isFrameUpdateEnabled;
00713 };
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00731
00735 class gzTransformBase : public gzGroup
00736 {
00737 public:
00739
00742 GZ_GRAPH_EXPORT gzTransformBase(const gzString & name=GZ_EMPTY_STRING);
00744 GZ_GRAPH_EXPORT virtual ~gzTransformBase(){};
00745
00746 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00747
00748
00750 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00751
00752
00753
00755 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00756
00758 GZ_GRAPH_EXPORT virtual gzVoid postTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00759
00760
00762
00765 GZ_GRAPH_EXPORT static gzVoid activateIndex( gzContext *context , gzULong index);
00766
00768
00771 GZ_GRAPH_EXPORT static gzVoid resetIndex( gzContext *context );
00772
00773
00774
00775
00777 GZ_GRAPH_EXPORT gzVoid setNumberOfBases(gzULong count=0);
00778
00780 GZ_GRAPH_EXPORT gzULong getNumberOfBases();
00781
00782 private:
00783
00784 gzULong m_numberOfBases;
00785 };
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00803 class gzTransformID
00804 {
00805 public:
00806
00807 gzTransformID():currentTransformIndex(0),
00808 numberOfBases(0),
00809 accumTransformChecksum(0),
00810 transformChecksum(0),
00811 currentTransformChecksum(0),
00812 changedMatrix(TRUE),
00813 hasNormal(FALSE){};
00814
00815 gzULong currentTransformIndex;
00816 gzULong numberOfBases;
00817 gzULong accumTransformChecksum;
00818 gzULong transformChecksum;
00819 gzULong currentTransformChecksum;
00820
00821 gzBool changedMatrix;
00822 gzBool hasNormal;
00823
00824
00825 gzMatrix4 mat;
00826 gzMatrix4 norm;
00827 };
00828
00829 #endif