iltcsbase.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. // Base class for ILTClient and ILTServer. This is just here for b/w compatibility.
  2. #ifndef __ILTCSBASE_H__
  3. #define __ILTCSBASE_H__
  4. #include "ltbasedefs.h"
  5. #include "iltmath.h"
  6. #include "iltcommon.h"
  7. // Forward declarations of base interface classes
  8. class ILTPhysics;
  9. class ILTModel;
  10. class ILTTransform;
  11. class ILTLightAnim;
  12. class ILTSoundMgr;
  13. class ILTCSBase
  14. {
  15. public:
  16. inline ILTMath* GetMathLT() {return &m_MathLT;}
  17. inline ILTCommon* Common() {return m_pCommonLT;}
  18. inline ILTPhysics* Physics() {return m_pPhysicsLT;}
  19. inline ILTModel* GetModelLT() {return m_pModelLT;}
  20. inline ILTTransform* GetTransformLT() {return m_pTransformLT;}
  21. inline ILTLightAnim* GetLightAnimLT() {return m_pLightAnimLT;}
  22. inline ILTSoundMgr* SoundMgr() {return m_pSoundMgr;}
  23. // Messaging functions. ALL these functions are obsolete. Use the LMessage functions.
  24. public:
  25. // Start a data message for writing. A data message is used to write an HMESSAGEWRITE into another
  26. // already open HMESSAGEWRITE. When the data message is complete, first call
  27. // WriteToMessageHMessageWrite to write it into the other HMESSAGE, then call EndMessageHMessageWrite to free it.
  28. virtual HMESSAGEWRITE StartHMessageWrite()=0;
  29. virtual LTRESULT WriteToMessageFloat(HMESSAGEWRITE hMessage, float val);
  30. virtual LTRESULT WriteToMessageByte(HMESSAGEWRITE hMessage, uint8 val);
  31. virtual LTRESULT WriteToMessageWord(HMESSAGEWRITE hMessage, uint16 val);
  32. virtual LTRESULT WriteToMessageDWord(HMESSAGEWRITE hMessage, uint32 val);
  33. virtual LTRESULT WriteToMessageString(HMESSAGEWRITE hMessage, char *pStr);
  34. virtual LTRESULT WriteToMessageVector(HMESSAGEWRITE hMessage, LTVector *pVal); // 12 bytes
  35. virtual LTRESULT WriteToMessageCompVector(HMESSAGEWRITE hMessage, LTVector *pVal); // 9 bytes
  36. virtual LTRESULT WriteToMessageCompPosition(HMESSAGEWRITE hMessage, LTVector *pVal); // 7 bytes
  37. virtual LTRESULT WriteToMessageRotation(HMESSAGEWRITE hMessage, LTRotation *pVal);
  38. virtual LTRESULT WriteToMessageHString(HMESSAGEWRITE hMessage, HSTRING hString);
  39. // Writes a HMESSAGEWRITE into an already opened HMESSAGEWRITE.
  40. // Inputs:
  41. // hMessage - HMESSAGEWRITE written to.
  42. // hDataMessage - HMESSAGEWRITE written from.
  43. virtual LTRESULT WriteToMessageHMessageWrite(HMESSAGEWRITE hMessage, HMESSAGEWRITE hDataMessage);
  44. // Writes a HMESSAGEREAD into an already opened HMESSAGEWRITE.
  45. // Inputs:
  46. // hMessage - HMESSAGEWRITE written to.
  47. // hDataMessage - HMESSAGEREAD written from.
  48. virtual LTRESULT WriteToMessageHMessageRead(HMESSAGEWRITE hMessage, HMESSAGEREAD hDataMessage);
  49. // Helper so you don't have to FormatString and FreeString..
  50. virtual LTRESULT WriteToMessageFormattedHString(HMESSAGEWRITE hMessage, int messageCode, ...);
  51. // Note: you can't send object references to the client yet, so the client can't
  52. // even read object references.
  53. // You can't write object references in a HMESSAGEWRITE passed in MID_SAVEOBJECT.
  54. virtual LTRESULT WriteToMessageObject(HMESSAGEWRITE hMessage, HOBJECT hObj);
  55. // Use this only while saving objects (inside MID_SAVEOBJECT).
  56. virtual LTRESULT WriteToLoadSaveMessageObject(HMESSAGEWRITE hMessage, HOBJECT hObject);
  57. // When your OnMessage function is called, use the handle you're given
  58. // to read the message data with these functions.
  59. virtual float ReadFromMessageFloat(HMESSAGEREAD hMessage);
  60. virtual uint8 ReadFromMessageByte(HMESSAGEREAD hMessage);
  61. virtual uint16 ReadFromMessageWord(HMESSAGEREAD hMessage);
  62. virtual uint32 ReadFromMessageDWord(HMESSAGEREAD hMessage);
  63. virtual void ReadFromMessageVector(HMESSAGEREAD hMessage, LTVector *pVal); // 12 bytes
  64. virtual void ReadFromMessageCompVector(HMESSAGEREAD hMessage, LTVector *pVal); // 9 bytes
  65. virtual void ReadFromMessageCompPosition(HMESSAGEREAD hMessage, LTVector *pVal); // 7 bytes
  66. virtual void ReadFromMessageRotation(HMESSAGEREAD hMessage, LTRotation *pVal);
  67. virtual HOBJECT ReadFromMessageObject(HMESSAGEREAD hMessage);
  68. virtual HSTRING ReadFromMessageHString(HMESSAGEREAD hMessage);
  69. // Use this only while loading objects (inside MID_LOADOBJECT).
  70. virtual LTRESULT ReadFromLoadSaveMessageObject(HMESSAGEREAD hMessage, HOBJECT *hObject);
  71. // Reads a data message from an HMESSAGEREAD. The returned HMESSAGEREAD can then be used in the
  72. // ReadFromMessageX functions. This will create a new HMESSAGEREAD which must be
  73. // freed with a call to EndHMessageRead().
  74. // Inputs:
  75. // hMessage - HMESSAGEREAD read from.
  76. virtual HMESSAGEREAD ReadFromMessageHMessageRead(HMESSAGEREAD hMessage);
  77. // Frees a HMESSAGEREAD created from a call of ReadFromMessageHMessageRead.
  78. virtual void EndHMessageRead(HMESSAGEREAD hMessage);
  79. // Frees a HMESSAGEWRITE created from a call of StartHMessageWrite.
  80. virtual void EndHMessageWrite(HMESSAGEWRITE hMessage);
  81. // Reset reading (so you can read the message again).
  82. // This is useful if you read out of a message and subclasses
  83. // will be reading out of it. Note: the message will AUTOMATICALLY
  84. // reset when you hit the end, so you won't need this in most cases.
  85. virtual void ResetRead(HMESSAGEREAD hRead);
  86. // Get an animation index from a model.
  87. // Returns -1 if the animation doesn't exist (or if the object isn't a model).
  88. virtual HMODELANIM GetAnimIndex(HOBJECT hObj, char *pAnimName) = 0;
  89. // If the object is a model, this sets its current animation.
  90. virtual void SetModelAnimation(HOBJECT hObj, HMODELANIM hAnim) = 0;
  91. // Returns the animation the model is currently on. (HMODELANIM)-1 if none.
  92. virtual HMODELANIM GetModelAnimation(HOBJECT hObj) = 0;
  93. // Get/Set the looping state of the model. The default state is TRUE.
  94. virtual void SetModelLooping(HOBJECT hObj, LTBOOL bLoop) = 0;
  95. virtual LTBOOL GetModelLooping(HOBJECT hObj) = 0;
  96. // Starts the current animation over.
  97. virtual LTRESULT ResetModelAnimation(HOBJECT hObj) = 0;
  98. // Tells what the playback state of the model is (a combination of the
  99. // MS_ bits defined in basedefs_de.h).
  100. virtual uint32 GetModelPlaybackState(HOBJECT hObj) = 0;
  101. // Free unused model files
  102. virtual LTRESULT FreeUnusedModels() = 0;
  103. // A better BPrint.. prints right to the console (doesn't do any network stuff) and
  104. // doesn't matter if you're connected yet.
  105. virtual void CPrint(char *pMsg, ...) = 0;
  106. // Find out what containers contain the given point.
  107. // Returns the number of containers filled in.
  108. virtual uint32 GetPointContainers(LTVector *pPoint, HOBJECT *pList, uint32 maxListSize) = 0;
  109. // Get the container's container code (can only be set in the ObjectCreateStruct during creation).
  110. // Returns LTFALSE if the object isn't a container.
  111. virtual LTBOOL GetContainerCode(HOBJECT hObj, uint16 *pCode) = 0;
  112. // Open a file up. Pass in the relative filename.
  113. // Free the file by calling DStream::Release().
  114. virtual LTRESULT OpenFile(char *pFilename, ILTStream **pStream) = 0;
  115. // Copies a file. This function is useful for copying files out of the
  116. // rez file to a temporary file, so you can do special operations on it like
  117. // LoadLibrary.
  118. virtual LTRESULT CopyFile( const char *pszSourceFile, const char *pszDestFile ) = 0;
  119. // String functions. Strings are reference counted objects that cannot
  120. // be manipulated. When you create one with FormatString or CreateString,
  121. // the reference count is 1. When you copy a string with CopyString, the
  122. // reference count is incremented. When you free one with FreeString,
  123. // it decrements the reference count.. when the reference count goes to
  124. // zero, it deletes the string. If you forget to free up any strings,
  125. // LithTech will spit out a message telling you about it..
  126. // In Windows, messageCode comes from your resource DLL. The messages
  127. // need to be formatted with %1!s! %2!s! (the number is the argument
  128. // number and the !s! says its a string). You can also use !f! and !d!
  129. // for floating point and whole number.
  130. virtual HSTRING FormatString(int messageCode, ...) = 0;
  131. // Copy a string.. much more efficient than CreateString().
  132. virtual HSTRING CopyString(HSTRING hString) = 0;
  133. virtual HSTRING CreateString(char *pString) = 0;
  134. virtual void FreeString(HSTRING hString) = 0;
  135. virtual LTBOOL CompareStrings(HSTRING hString1, HSTRING hString2) = 0;
  136. virtual LTBOOL CompareStringsUpper(HSTRING hString1, HSTRING hString2) = 0;
  137. // Get the string's data.. you really should only use this for strings
  138. // that you stored off and want to pass to the engine for a filename
  139. // or something.. Most strings could be in some format other than ANSI.
  140. virtual char* GetStringData(HSTRING hString) = 0;
  141. // Get the floating point value of a console variable. If the hVar is
  142. // NULL, then it returns 0.
  143. virtual float GetVarValueFloat(HCONSOLEVAR hVar) = 0;
  144. // Get the string value of a console variable. If the hVar is
  145. // NULL, then it returns NULL.
  146. virtual char* GetVarValueString(HCONSOLEVAR hVar) = 0;
  147. // Returns the current time, in seconds, since the shell started
  148. virtual LTFLOAT GetTime() = 0;
  149. // Returns the time since the last shell update.
  150. virtual LTFLOAT GetFrameTime() = 0;
  151. // Remove the object from the world. Note: the object won't be removed
  152. // or deleted until the end of the frame.
  153. virtual LTRESULT RemoveObject(HOBJECT hObj) = 0;
  154. // OBSOLETE: Use CommonLT version.
  155. uint32 GetObjectType(HOBJECT hObj) {uint32 temp; Common()->GetObjectType(hObj, &temp); return temp;}
  156. // OBSOLETE: Use MathLT functions. NOTE: PARAMETER ORDERINGS ARE DIFFERENT
  157. // FOR SOME OF THE FUNCTIONS.
  158. public:
  159. virtual LTRESULT GetRotationVectors(LTRotation *pRotation,
  160. LTVector *pUp, LTVector *pRight, LTVector *pForward);
  161. virtual void GetRotationVectorsFromMatrix(LTMatrix *pMat,
  162. LTVector *pUp, LTVector *pRight, LTVector *pForward);
  163. virtual void RotateAroundAxis(LTRotation *pRotation, LTVector *pAxis, float amount);
  164. virtual void EulerRotateX(LTRotation *pRotation, float amount);
  165. virtual void EulerRotateY(LTRotation *pRotation, float amount);
  166. virtual void EulerRotateZ(LTRotation *pRotation, float amount);
  167. virtual void AlignRotation(LTRotation *pRotation, LTVector *pVector, LTVector *pUp);
  168. virtual LTRESULT SetupEuler(LTRotation *pRotation, float pitch, float yaw, float roll);
  169. virtual LTRESULT InterpolateRotation(LTRotation *pDest, LTRotation *pRot1, LTRotation *pRot2, float t);
  170. virtual void SetupTransformationMatrix( LTMatrix *pMat, LTVector *pTranslation, LTRotation *pRotation );
  171. virtual void SetupTranslationMatrix( LTMatrix *pMat, LTVector *pTranslation );
  172. virtual void SetupRotationMatrix(LTMatrix *pMat, LTRotation *pRot);
  173. virtual void SetupTranslationFromMatrix( LTVector *pTranslation, LTMatrix *pMat );
  174. virtual void SetupRotationFromMatrix(LTRotation *pRot, LTMatrix *pMat);
  175. virtual void SetupRotationAroundPoint(LTMatrix *pMat, LTRotation *pRot, LTVector *pPoint);
  176. protected:
  177. ILTMath m_MathLT;
  178. ILTCommon *m_pCommonLT;
  179. ILTPhysics *m_pPhysicsLT;
  180. ILTModel *m_pModelLT;
  181. ILTTransform *m_pTransformLT;
  182. ILTLightAnim *m_pLightAnimLT;
  183. ILTSoundMgr *m_pSoundMgr;
  184. };
  185. #endif // __ILTCSBASE_H__