00001 // Filename: physicsObject.cxx 00002 // Created by: charles (13Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "physicsObject.h" 00020 00021 TypeHandle PhysicsObject::_type_handle; 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function : PhysicsObject 00025 // Access : Public 00026 // Description : Default Constructor 00027 //////////////////////////////////////////////////////////////////// 00028 PhysicsObject:: 00029 PhysicsObject(void) : 00030 _terminal_velocity(_default_terminal_velocity), 00031 _mass(1.0f), 00032 _process_me(false), 00033 _oriented(true) 00034 { 00035 _position.set(0.0f, 0.0f, 0.0f); 00036 _last_position = _position; 00037 _velocity.set(0.0f, 0.0f, 0.0f); 00038 _orientation.set(1.0 ,0.0f, 0.0f, 0.0f); 00039 _rotation.set(0.0f, 0.0f, 0.0f); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function : PhysicsObject 00044 // Access : Public 00045 // Description : copy constructor 00046 //////////////////////////////////////////////////////////////////// 00047 PhysicsObject:: 00048 PhysicsObject(const PhysicsObject& copy) { 00049 operator=(copy); 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function : ~PhysicsObject 00054 // Access : Public 00055 // Description : Destructor 00056 //////////////////////////////////////////////////////////////////// 00057 PhysicsObject:: 00058 ~PhysicsObject(void) { 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function : Assignment operator 00063 // Access : Public 00064 // Description : 00065 //////////////////////////////////////////////////////////////////// 00066 const PhysicsObject &PhysicsObject:: 00067 operator =(const PhysicsObject &other) { 00068 _process_me = other._process_me; 00069 _mass = other._mass; 00070 _position = other._position; 00071 _last_position = other._last_position; 00072 _velocity = other._velocity; 00073 _orientation = other._orientation; 00074 _rotation = other._rotation; 00075 _terminal_velocity = other._terminal_velocity; 00076 _oriented = other._oriented; 00077 00078 return *this; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function : make_copy 00083 // Access : Public, virtual 00084 // Description : dynamic copy. 00085 //////////////////////////////////////////////////////////////////// 00086 PhysicsObject *PhysicsObject:: 00087 make_copy(void) const { 00088 return new PhysicsObject(*this); 00089 } 00090 00091 //////////////////////////////////////////////////////////////////// 00092 // Function : get_lcs 00093 // Access : Public 00094 // Description : returns a transform matrix to this object's 00095 // local coordinate system. 00096 //////////////////////////////////////////////////////////////////// 00097 LMatrix4f PhysicsObject:: 00098 get_lcs(void) const { 00099 LMatrix4f m = LMatrix4f::translate_mat(_position); 00100 00101 if (_oriented == true) 00102 _orientation.extract_to_matrix(m); 00103 00104 return m; 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function : get_inertial_tensor 00109 // Access : Public 00110 // Description : returns a transform matrix that represents the 00111 // object's willingness to be forced. 00112 //////////////////////////////////////////////////////////////////// 00113 LMatrix4f PhysicsObject:: 00114 get_inertial_tensor(void) const { 00115 return LMatrix4f::ident_mat(); 00116 }