KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Collision_PDU.h
Go to the documentation of this file.
1 /*********************************************************************
2 
3 Copyright 2013 Karl Jones
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8 
9 1. Redistributions of source code must retain the above copyright notice, this
10  list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 For Further Information Please Contact me at
27 Karljj1@yahoo.com
28 http://p.sf.net/kdis/UserGuide
29 *********************************************************************/
30 
31 /********************************************************************
32  class: Collision_PDU
33  DIS: (5) 1278.1 - 1995
34  created: 08/10/2008
35  author: Karl Jones
36 
37  purpose: PDU Sent upon a collision event. This could be between a simulated
38  entity or another object in the simulated world (e.g., a cultural
39  feature such as a bridge or building).
40 
41  Size: 480 bits / 60 octets
42 *********************************************************************/
43 
44 #pragma once
45 
46 #include "./../Header.h"
47 #include "./../../DataTypes/EntityIdentifier.h"
48 #include "./../../DataTypes/Vector.h"
49 
50 namespace KDIS {
51 namespace PDU {
52 
54 {
55 protected:
56 
58 
60 
62 
64 
66 
68 
70 
72 
73 public:
74 
75  static const KUINT16 COLLISION_PDU_SIZE = 60;
76 
77  Collision_PDU();
78 
79  Collision_PDU( KDataStream & stream ) throw( KException );
80 
81  Collision_PDU( const Header & H, KDataStream & stream ) throw( KException );
82 
85  KFLOAT32 Mass, const KDIS::DATA_TYPE::Vector & Location );
86 
87  virtual ~Collision_PDU();
88 
89  //************************************
90  // FullName: KDIS::PDU::Collision_PDU::SetIssuingEntityID
91  // KDIS::PDU::Collision_PDU::GetIssuingEntityID
92  //!Description: Entity Issuing the collision
93  // Parameter: const EntityIdentifier & ID
94  //************************************
95  void SetIssuingEntityID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
96  const KDIS::DATA_TYPE::EntityIdentifier & GetIssuingEntityID() const;
97  KDIS::DATA_TYPE::EntityIdentifier & GetIssuingEntityID();
98 
99  //************************************
100  // FullName: KDIS::PDU::Collision_PDU::SetCollidingEntityID
101  // KDIS::PDU::Collision_PDU::GetCollidingEntityID
102  //!Description: Entity that has collided with the issuing entity
103  //! If collision is with terrain or unknown entity
104  //! the id will be ENTITY_ID_UNKNOWN
105  // Parameter: const EntityIdentifier & ID
106  //************************************
107  void SetCollidingEntityID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
108  const KDIS::DATA_TYPE::EntityIdentifier & GetCollidingEntityID() const;
109  KDIS::DATA_TYPE::EntityIdentifier & GetCollidingEntityID();
110 
111  //************************************
112  // FullName: KDIS::PDU::Collision_PDU::SetEventID
113  // KDIS::PDU::Collision_PDU::GetEventID
114  //!Description: ID generated to associate related collision events
115  //! to this one.
116  // Parameter: const EntityIdentifier & ID
117  //************************************
118  void SetEventID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
119  const KDIS::DATA_TYPE::EntityIdentifier & GetEventID() const;
120  KDIS::DATA_TYPE::EntityIdentifier & GetEventID();
121 
122  //************************************
123  // FullName: KDIS::PDU::Collision_PDU::SetCollisionType
124  // KDIS::PDU::Collision_PDU::GetCollisionType
125  //!Description: Describes the type of collision that occurred
126  // Parameter: CollisionType CT
127  //************************************
128  void SetCollisionType( KDIS::DATA_TYPE::ENUMS::CollisionType CT );
129  KDIS::DATA_TYPE::ENUMS::CollisionType GetCollisionType() const;
130 
131  //************************************
132  // FullName: KDIS::PDU::Collision_PDU::SetVelocity
133  // KDIS::PDU::Collision_PDU::GetVelocity
134  //!Description: Issuing Entity Velocity at time of collision
135  //! detection. Represented as a Linear
136  //! Velocity Vector.
137  // Parameter: const Vector & V
138  //************************************
139  void SetVelocity( const KDIS::DATA_TYPE::Vector & V );
140  const KDIS::DATA_TYPE::Vector & GetVelocity() const;
141  KDIS::DATA_TYPE::Vector & GetVelocity();
142 
143  //************************************
144  // FullName: KDIS::PDU::Collision_PDU::SetMass
145  // KDIS::PDU::Collision_PDU::GetMass
146  //!Description: Issuing entity mass in kilograms
147  // Parameter: KFLOAT32 M
148  //************************************
149  void SetMass( KFLOAT32 M );
150  KFLOAT32 GetMass() const;
151 
152  //************************************
153  // FullName: KDIS::PDU::Collision_PDU::SetLocation
154  // KDIS::PDU::Collision_PDU::GetLocation
155  //!Description: Location of collision with respect to the
156  //! issuing entity. Represented by an
157  //! Entity Coordinate Vector.
158  // Parameter: const Vector & L
159  //************************************
160  void SetLocation( const KDIS::DATA_TYPE::Vector & L );
161  const KDIS::DATA_TYPE::Vector & GetLocation() const;
162  KDIS::DATA_TYPE::Vector & GetLocation();
163 
164  //************************************
165  // FullName: KDIS::PDU::Collision_PDU::GetAsString
166  //!Description: Returns a string representation of the PDU.
167  //************************************
168  virtual KString GetAsString() const;
169 
170  //************************************
171  // FullName: KDIS::PDU::Collision_PDU::Decode
172  //!Description: Convert From Network Data.
173  // Parameter: KDataStream & stream
174  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
175  //************************************
176  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
177 
178  //************************************
179  // FullName: KDIS::PDU::Collision_PDU::Encode
180  //!Description: Convert To Network Data.
181  // Parameter: KDataStream & stream
182  //************************************
183  virtual KDataStream Encode() const;
184  virtual void Encode( KDataStream & stream ) const;
185 
186  KBOOL operator == ( const Collision_PDU & Value ) const;
187  KBOOL operator != ( const Collision_PDU & Value ) const;
188 };
189 
190 } // END namespace PDU
191 } // END namespace KDIS
KDIS::DATA_TYPE::Vector m_Location
Definition: Collision_PDU.h:71
KDIS::DATA_TYPE::Vector m_Velocity
Definition: Collision_PDU.h:67
unsigned short int KUINT16
Definition: KDefines.h:101
KDIS::DATA_TYPE::EntityIdentifier m_EventID
Definition: Collision_PDU.h:61
float KFLOAT32
Definition: KDefines.h:113
CollisionType
Definition: EnumEntityInfoInteraction.h:53
KDIS::DATA_TYPE::EntityIdentifier m_CollidingEntityID
Definition: Collision_PDU.h:59
Definition: Collision_PDU.h:53
KFLOAT32 m_f32Mass
Definition: Collision_PDU.h:69
Definition: Vector.h:71
Definition: KDefines.h:182
KUINT8 m_ui8Padding
Definition: Collision_PDU.h:65
Definition: KDataStream.h:48
KUINT8 m_ui8CollisionType
Definition: Collision_PDU.h:63
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
KDIS::DATA_TYPE::EntityIdentifier m_IssuingEntityID
Definition: Collision_PDU.h:57
#define KDIS_EXPORT
Definition: KDefines.h:82