-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from dipsywong98/dynamic-arm
dynamic number of arm segments
- Loading branch information
Showing
6 changed files
with
461 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,100 @@ | ||
// This camera stuff mostly by ehsu | ||
|
||
#ifndef CAMERA_H | ||
#define CAMERA_H | ||
|
||
#include "vec.h" | ||
#include "mat.h" | ||
|
||
//==========[ class Camera ]=================================================== | ||
|
||
typedef enum { kActionNone, kActionTranslate, kActionRotate, kActionZoom, kActionTwist,} MouseAction_t; | ||
|
||
class Camera { | ||
|
||
protected: | ||
|
||
float mElevation; | ||
float mAzimuth; | ||
float mDolly; | ||
float mTwist; // Not implemented yet | ||
|
||
Vec3f mLookAt; | ||
|
||
Vec3f mPosition; | ||
Vec3f mUpVector; | ||
bool mDirtyTransform; | ||
|
||
void calculateViewingTransformParameters(); | ||
|
||
Vec3f mLastMousePosition; | ||
MouseAction_t mCurrentMouseAction; | ||
int lastScroll; | ||
|
||
|
||
public: | ||
|
||
//---[ Constructors ]---------------------------------- | ||
|
||
// defaults to (0,0,0) facing down negative z axis | ||
Camera(); | ||
|
||
//---[ Settings ]-------------------------------------- | ||
|
||
inline void setElevation( float elevation ) | ||
{ | ||
// don't want elevation to be negative | ||
if (elevation<0) elevation+=6.28318530717f; | ||
mElevation = elevation; mDirtyTransform = true; | ||
} | ||
inline float getElevation() const | ||
{ return mElevation; } | ||
|
||
inline void setAzimuth( float azimuth ) | ||
{ mAzimuth = azimuth; mDirtyTransform = true; } | ||
inline float getAzimuth() const | ||
{ return mAzimuth; } | ||
|
||
inline void setDolly( float dolly ) | ||
{ mDolly = dolly; mDirtyTransform = true; } | ||
inline float getDolly() const | ||
{ return mDolly; } | ||
|
||
inline void setTwist( float twist ) | ||
{ mTwist = twist; mDirtyTransform = true; } | ||
inline float getTwist() const | ||
{ return mTwist; } | ||
|
||
inline void setLookAt( const Vec3f &lookAt ) | ||
{ mLookAt = lookAt; mDirtyTransform = true;} | ||
inline Vec3f getLookAt() const | ||
{ return mLookAt; } | ||
|
||
inline void frameAll() | ||
{ | ||
mElevation = 6.7054; | ||
mAzimuth = 2.7193; | ||
mDolly = -30; | ||
mLookAt = Vec3<float>(0.5, 2, -0.5); | ||
mPosition = Vec3<float>(-9.5, 15, 21.5); | ||
mDirtyTransform = true; | ||
} | ||
|
||
//---[ Interactive Adjustment ]------------------------ | ||
// these should be used from a mouse event handling routine that calls | ||
// the startX method on a mouse down, updateX on mouse move and finally | ||
// endX on mouse up. | ||
//----------------------------------------------------- | ||
void clickMouse( MouseAction_t action, int x, int y ); | ||
void dragMouse( int x, int y ); | ||
void releaseMouse( int x, int y ); | ||
|
||
//---[ Viewing Transform ]-------------------------------- | ||
void applyViewingTransform(); | ||
|
||
// gluLookAt equivalent | ||
void lookAt(Vec3f eye, Vec3f at, Vec3f up); | ||
}; | ||
|
||
// This camera stuff mostly by ehsu | ||
|
||
#ifndef CAMERA_H | ||
#define CAMERA_H | ||
|
||
#include "modelerglobals.h" | ||
#include "vec.h" | ||
#include "mat.h" | ||
|
||
//==========[ class Camera ]=================================================== | ||
|
||
typedef enum { kActionNone, kActionTranslate, kActionRotate, kActionZoom, kActionTwist,} MouseAction_t; | ||
|
||
class Camera { | ||
|
||
protected: | ||
|
||
float mElevation; | ||
float mAzimuth; | ||
float mDolly; | ||
float mTwist; // Not implemented yet | ||
|
||
Vec3f mLookAt; | ||
|
||
Vec3f mPosition; | ||
Vec3f mUpVector; | ||
bool mDirtyTransform; | ||
|
||
void calculateViewingTransformParameters(); | ||
|
||
Vec3f mLastMousePosition; | ||
MouseAction_t mCurrentMouseAction; | ||
int lastScroll; | ||
|
||
|
||
public: | ||
|
||
//---[ Constructors ]---------------------------------- | ||
|
||
// defaults to (0,0,0) facing down negative z axis | ||
Camera(); | ||
|
||
//---[ Settings ]-------------------------------------- | ||
|
||
inline void setElevation( float elevation ) | ||
{ | ||
// don't want elevation to be negative | ||
if (elevation<0) elevation+=6.28318530717f; | ||
mElevation = elevation; mDirtyTransform = true; | ||
} | ||
inline float getElevation() const | ||
{ return mElevation; } | ||
|
||
inline void setAzimuth( float azimuth ) | ||
{ mAzimuth = azimuth; mDirtyTransform = true; } | ||
inline float getAzimuth() const | ||
{ return mAzimuth; } | ||
|
||
inline void setDolly( float dolly ) | ||
{ mDolly = dolly; mDirtyTransform = true; } | ||
inline float getDolly() const | ||
{ return mDolly; } | ||
|
||
inline void setTwist( float twist ) | ||
{ mTwist = twist; mDirtyTransform = true; } | ||
inline float getTwist() const | ||
{ return mTwist; } | ||
|
||
inline void setLookAt( const Vec3f &lookAt ) | ||
{ mLookAt = lookAt; mDirtyTransform = true;} | ||
inline Vec3f getLookAt() const | ||
{ return mLookAt; } | ||
|
||
inline void frameAll(double e) | ||
{ | ||
mElevation = 6.7054; | ||
mAzimuth = 2.7193; | ||
mDolly = -10*e; | ||
mLookAt = Vec3<float>(0.5, 2, -0.5); | ||
mPosition = Vec3<float>(-3.5, 5, 7.5); | ||
mDirtyTransform = true; | ||
} | ||
|
||
//---[ Interactive Adjustment ]------------------------ | ||
// these should be used from a mouse event handling routine that calls | ||
// the startX method on a mouse down, updateX on mouse move and finally | ||
// endX on mouse up. | ||
//----------------------------------------------------- | ||
void clickMouse( MouseAction_t action, int x, int y ); | ||
void dragMouse( int x, int y ); | ||
void releaseMouse( int x, int y ); | ||
|
||
//---[ Viewing Transform ]-------------------------------- | ||
void applyViewingTransform(); | ||
|
||
// gluLookAt equivalent | ||
void lookAt(Vec3f eye, Vec3f at, Vec3f up); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.