CppSceneObjectClassFile.cpp.template 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #include "@.h"
  2. #include "math/mathIO.h"
  3. #include "console/consoleTypes.h"
  4. #include "core/stream/bitStream.h"
  5. IMPLEMENT_CO_NETOBJECT_V1(@);
  6. @::@()
  7. {
  8. // Flag this object so that it will always
  9. // be sent across the network to clients
  10. mNetFlags.set( Ghostable | ScopeAlways );
  11. // Set it as a "static" object that casts shadows
  12. mTypeMask |= StaticObjectType | StaticShapeObjectType;
  13. }
  14. @::~@()
  15. {
  16. }
  17. bool @::onAdd()
  18. {
  19. if (!Parent::onAdd())
  20. return false;
  21. // Set up a 1x1x1 bounding box
  22. mObjBox.set( Point3F( -0.5f, -0.5f, -0.5f ),
  23. Point3F( 0.5f, 0.5f, 0.5f ) );
  24. resetWorldBox();
  25. // Add this object to the scene
  26. addToScene();
  27. return true;
  28. }
  29. void @::onRemove()
  30. {
  31. // Remove this object from the scene
  32. removeFromScene();
  33. Parent::onRemove();
  34. }
  35. void @::initPersistFields()
  36. {
  37. Parent::initPersistFields();
  38. }
  39. void @::inspectPostApply()
  40. {
  41. Parent::inspectPostApply();
  42. // Flag the network mask to send the updates
  43. // to the client object
  44. setMaskBits( TransformMask );
  45. }
  46. void @::setTransform(const MatrixF & mat)
  47. {
  48. // Let SceneObject handle all of the matrix manipulation
  49. Parent::setTransform( mat );
  50. // Dirty our network mask so that the new transform gets
  51. // transmitted to the client object
  52. setMaskBits( TransformMask );
  53. }
  54. U32 @::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
  55. {
  56. // Allow the Parent to get a crack at writing its info
  57. U32 retMask = Parent::packUpdate( conn, mask, stream );
  58. // Write our transform information
  59. if ( stream->writeFlag( mask & TransformMask ) )
  60. {
  61. mathWrite(*stream, getTransform());
  62. mathWrite(*stream, getScale());
  63. }
  64. return retMask;
  65. }
  66. void @::unpackUpdate(NetConnection *conn, BitStream *stream)
  67. {
  68. // Let the Parent read any info it sent
  69. Parent::unpackUpdate(conn, stream);
  70. if ( stream->readFlag() ) // TransformMask
  71. {
  72. mathRead(*stream, &mObjToWorld);
  73. mathRead(*stream, &mObjScale);
  74. setTransform( mObjToWorld );
  75. }
  76. }
  77. DefineEngineMethod( @, postApply, void, (),,
  78. "A utility method for forcing a network update.\n")
  79. {
  80. object->inspectPostApply();
  81. }