Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.5 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: pipe.h
  3. //
  4. // Desc: PIPE base class
  5. //
  6. // Copyright (c) 1994-2000 Microsoft Corporation
  7. //-----------------------------------------------------------------------------
  8. #ifndef __pipe_h__
  9. #define __pipe_h__
  10. // pipe drawing status
  11. enum
  12. {
  13. PIPE_ACTIVE,
  14. PIPE_STUCK,
  15. PIPE_OUT_OF_NODES
  16. };
  17. // pipe types
  18. enum
  19. {
  20. TYPE_NORMAL,
  21. TYPE_FLEX_REGULAR,
  22. TYPE_FLEX_TURNING
  23. };
  24. // ways pipe choose directions
  25. enum
  26. {
  27. CHOOSE_DIR_RANDOM_WEIGHTED,
  28. CHOOSE_DIR_CHASE // when chasing a lead pipe
  29. };
  30. // ways pipe choose start positions
  31. enum
  32. {
  33. CHOOSE_STARTPOS_RANDOM,
  34. CHOOSE_STARTPOS_FURTHEST // furthest from last position
  35. };
  36. //-----------------------------------------------------------------------------
  37. // Name: PIPE class
  38. // Desc: - Describes a pipe that draws thru the node array
  39. // - Could have more than one pipe drawing in each array at same time
  40. // - Pipe has position and direction in node array
  41. //-----------------------------------------------------------------------------
  42. class STATE;
  43. class PIPE
  44. {
  45. public:
  46. int m_type;
  47. IPOINT3D m_curPos; // current node position of pipe
  48. D3DMATERIAL8* m_pMat;
  49. STATE* m_pState; // for state value access
  50. void SetChooseDirectionMethod( int method );
  51. void SetChooseStartPosMethod( int method );
  52. int ChooseNewDirection();
  53. BOOL IsStuck(); // if pipe is stuck or not
  54. BOOL NowhereToRun() { return m_status == PIPE_OUT_OF_NODES; }
  55. PIPE( STATE *state );
  56. virtual ~PIPE();
  57. virtual void Start() = 0;
  58. virtual void Draw() = 0;
  59. protected:
  60. float m_radius; // ideal radius (fluctuates for FPIPE)
  61. int m_status; // ACTIVE/STUCK/STOPPED, etc.
  62. int m_lastDir; // last direction taken by pipe
  63. int m_notchVec; // current notch vector
  64. int m_weightStraight; // current weighting of going straight
  65. ID3DXMatrixStack* m_pWorldMatrixStack;
  66. BOOL SetStartPos(); // starting node position
  67. void ChooseMaterial();
  68. void UpdateCurrentPosition( int dir );
  69. void TranslateToCurrentPosition();
  70. void align_plusz( int newDir );
  71. private:
  72. int m_chooseDirMethod;
  73. int m_chooseStartPosMethod;
  74. int GetBestDirsForChase( int *bestDirs );
  75. };
  76. extern void align_plusz( int newDir );
  77. extern int notchTurn[NUM_DIRS][NUM_DIRS][NUM_DIRS];
  78. #endif // __pipe_h__