Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
PhysicsObject Class Reference

A body on which physics will be applied. More...

#include "physicsObject.h"

Inheritance diagram for PhysicsObject:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase BaseParticle OrientedParticle PointParticle ZSpinParticle

Public Types

typedef pvector< PT(PhysicsObject)> Vector
 

Public Member Functions

 PhysicsObject ()
 Default Constructor. More...
 
 PhysicsObject (const PhysicsObject &copy)
 copy constructor More...
 
virtual ~PhysicsObject ()
 Destructor. More...
 
virtual void add_impact (const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse)
 Adds an impulse and/or torque (i.e. More...
 
void add_impulse (const LVector3 &impulse)
 Adds an impulse force (i.e. More...
 
virtual void add_local_impact (const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse)
 Adds an impulse and/or torque (i.e. More...
 
void add_local_impulse (const LVector3 &impulse)
 Adds an impulse force (i.e. More...
 
void add_local_torque (const LRotation &torque)
 Adds an torque force (i.e. More...
 
void add_torque (const LRotation &torque)
 Adds an torque force (i.e. More...
 
virtual TypeHandle force_init_type ()
 
bool get_active () const
 
LVector3 get_implicit_velocity () const
 
virtual LMatrix4 get_inertial_tensor () const
 returns a transform matrix that represents the object's willingness to be forced. More...
 
LPoint3 get_last_position () const
 
virtual LMatrix4 get_lcs () const
 returns a transform matrix to this object's local coordinate system. More...
 
PN_stdfloat get_mass () const
 
const std::string & get_name ()
 
LOrientation get_orientation () const
 
bool get_oriented () const
 
LPoint3 get_position () const
 
LRotation get_rotation () const
 
PN_stdfloat get_terminal_velocity () const
 
virtual TypeHandle get_type () const
 
LVector3 get_velocity () const
 
virtual PhysicsObjectmake_copy () const
 dynamic copy. More...
 
const PhysicsObjectoperator= (const PhysicsObject &other)
 
virtual void output (std::ostream &out) const
 Write a string representation of this instance to <out>. More...
 
void reset_orientation (const LOrientation &orientation)
 set the orientation while clearing the rotation velocity. More...
 
void reset_position (const LPoint3 &pos)
 use this to place an object in a completely new position, that has nothing to do with its last position. More...
 
void set_active (bool flag)
 
void set_last_position (const LPoint3 &pos)
 
void set_mass (PN_stdfloat)
 
void set_name (const std::string &name)
 
void set_orientation (const LOrientation &orientation)
 
void set_oriented (bool flag)
 
void set_position (const LPoint3 &pos)
 
void set_position (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
 
void set_rotation (const LRotation &rotation)
 
void set_terminal_velocity (PN_stdfloat tv)
 
void set_velocity (const LVector3 &vel)
 
void set_velocity (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
 
virtual void write (std::ostream &out, int indent=0) const
 Write a string representation of this instance to <out>. More...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
bool unref_if_one () const
 Atomically decreases the reference count of this object if it is one. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_active
 Process Flag Query. More...
 
 get_implicit_velocity
 Velocity Query over the last dt. More...
 
 get_last_position
 Get the position of the physics object at the start of the most recent do_physics. More...
 
 get_mass
 Get the mass in slugs (or kilograms). More...
 
 get_orientation
 get current orientation. More...
 
 get_oriented
 See set_oriented(). More...
 
 get_position
 Position Query. More...
 
 get_rotation
 get rotation per second. More...
 
 get_terminal_velocity
 tv query More...
 
 get_velocity
 Velocity Query per second. More...
 
 set_active
 Process Flag assignment. More...
 
 set_last_position
 Last position assignment. More...
 
 set_mass
 Set the mass in slugs (or kilograms). More...
 
 set_orientation
 
 set_oriented
 Set flag to determine whether this object should do any rotation or orientation calculations. More...
 
 set_position
 Vector position assignment. More...
 
 set_rotation
 set rotation as a quaternion delta per second. More...
 
 set_terminal_velocity
 tv assignment More...
 
 set_velocity
 Vector velocity assignment. More...
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Static Public Attributes

static ConfigVariableDouble _default_terminal_velocity
 

Detailed Description

A body on which physics will be applied.

If you're looking to add physical motion to your class, do NOT derive from this. Derive from Physical instead.

Definition at line 27 of file physicsObject.h.

Constructor & Destructor Documentation

◆ PhysicsObject() [1/2]

PhysicsObject::PhysicsObject ( )

Default Constructor.

Definition at line 24 of file physicsObject.cxx.

Referenced by make_copy().

◆ PhysicsObject() [2/2]

PhysicsObject::PhysicsObject ( const PhysicsObject copy)

copy constructor

Definition at line 41 of file physicsObject.cxx.

◆ ~PhysicsObject()

PhysicsObject::~PhysicsObject ( )
virtual

Destructor.

Definition at line 49 of file physicsObject.cxx.

Member Function Documentation

◆ add_impact()

void PhysicsObject::add_impact ( const LPoint3 &  offset,
const LVector3 &  force 
)
virtual

Adds an impulse and/or torque (i.e.

an instantanious change in velocity) based on how well the offset and impulse align with the center of mass (aka position). If you wanted to immitate this function you could work out the impulse and torque and call add_impulse and add_torque respectively. offset and force are in global (or parent) coordinates.

Definition at line 103 of file physicsObject.cxx.

◆ add_impulse()

void PhysicsObject::add_impulse ( const LVector3 &  impulse)
inline

Adds an impulse force (i.e.

an instantanious change in velocity). This is a quicker way to get the velocity, add a vector to it and set that value to be the new velocity.

Definition at line 127 of file physicsObject.I.

◆ add_local_impact()

void PhysicsObject::add_local_impact ( const LPoint3 &  offset_from_center_of_mass,
const LVector3 &  force 
)
virtual

Adds an impulse and/or torque (i.e.

an instantanious change in velocity) based on how well the offset and impulse align with the center of mass (aka position). If you wanted to immitate this function you could work out the impulse and torque and call add_impulse and add_torque respectively. offset and force are in local coordinates.

Definition at line 86 of file physicsObject.cxx.

◆ add_local_impulse()

void PhysicsObject::add_local_impulse ( const LVector3 &  impulse)
inline

Adds an impulse force (i.e.

an instantanious change in velocity). This is a quicker way to get the velocity, add a vector to it and set that value to be the new velocity.

Definition at line 105 of file physicsObject.I.

◆ add_local_torque()

void PhysicsObject::add_local_torque ( const LRotation &  torque)
inline

Adds an torque force (i.e.

an instantanious change in velocity). This is a quicker way to get the angular velocity, add a vector to it and set that value to be the new angular velocity.

Definition at line 94 of file physicsObject.I.

◆ add_torque()

void PhysicsObject::add_torque ( const LRotation &  torque)
inline

Adds an torque force (i.e.

an instantanious change in velocity). This is a quicker way to get the angular velocity, add a vector to it and set that value to be the new angular velocity.

Definition at line 116 of file physicsObject.I.

◆ get_inertial_tensor()

LMatrix4 PhysicsObject::get_inertial_tensor ( ) const
virtual

returns a transform matrix that represents the object's willingness to be forced.

Definition at line 144 of file physicsObject.cxx.

◆ get_lcs()

LMatrix4 PhysicsObject::get_lcs ( ) const
virtual

returns a transform matrix to this object's local coordinate system.

Definition at line 130 of file physicsObject.cxx.

Referenced by ActorNode::update_transform().

◆ make_copy()

PhysicsObject * PhysicsObject::make_copy ( ) const
virtual

dynamic copy.

Reimplemented in BaseParticle, ZSpinParticle, PointParticle, and OrientedParticle.

Definition at line 74 of file physicsObject.cxx.

References PhysicsObject().

◆ output()

void PhysicsObject::output ( std::ostream &  out) const
virtual

Write a string representation of this instance to <out>.

Reimplemented in ZSpinParticle, PointParticle, OrientedParticle, and BaseParticle.

Definition at line 152 of file physicsObject.cxx.

◆ reset_orientation()

void PhysicsObject::reset_orientation ( const LOrientation &  orientation)
inline

set the orientation while clearing the rotation velocity.

Definition at line 56 of file physicsObject.I.

◆ reset_position()

void PhysicsObject::reset_position ( const LPoint3 &  pos)
inline

use this to place an object in a completely new position, that has nothing to do with its last position.

Definition at line 45 of file physicsObject.I.

◆ write()

void PhysicsObject::write ( std::ostream &  out,
int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Reimplemented in ZSpinParticle, PointParticle, OrientedParticle, and BaseParticle.

Definition at line 162 of file physicsObject.cxx.

References get_implicit_velocity, and indent().

Referenced by BaseParticle::write(), ActorNode::write(), and Physical::write().

Member Data Documentation

◆ get_active

bool PhysicsObject::get_active
inline

Process Flag Query.

Definition at line 103 of file physicsObject.h.

◆ get_implicit_velocity

LVector3 PhysicsObject::get_implicit_velocity
inline

Velocity Query over the last dt.

Definition at line 108 of file physicsObject.h.

Referenced by write().

◆ get_last_position

LPoint3 PhysicsObject::get_last_position
inline

Get the position of the physics object at the start of the most recent do_physics.

Definition at line 106 of file physicsObject.h.

◆ get_mass

PN_stdfloat PhysicsObject::get_mass
inline

Get the mass in slugs (or kilograms).

Definition at line 104 of file physicsObject.h.

◆ get_orientation

LOrientation PhysicsObject::get_orientation
inline

get current orientation.

Definition at line 111 of file physicsObject.h.

◆ get_oriented

bool PhysicsObject::get_oriented
inline

See set_oriented().

Definition at line 110 of file physicsObject.h.

◆ get_position

LPoint3 PhysicsObject::get_position
inline

Position Query.

Definition at line 105 of file physicsObject.h.

Referenced by LinearIntegrator::integrate(), and ParticleSystem::update().

◆ get_rotation

LRotation PhysicsObject::get_rotation
inline

get rotation per second.

Definition at line 112 of file physicsObject.h.

◆ get_terminal_velocity

PN_stdfloat PhysicsObject::get_terminal_velocity
inline

tv query

Definition at line 109 of file physicsObject.h.

◆ get_velocity

LVector3 PhysicsObject::get_velocity
inline

Velocity Query per second.

Definition at line 107 of file physicsObject.h.

◆ set_active

void PhysicsObject::set_active
inline

Process Flag assignment.

Definition at line 103 of file physicsObject.h.

Referenced by ActorNode::ActorNode().

◆ set_last_position

void PhysicsObject::set_last_position
inline

Last position assignment.

Definition at line 106 of file physicsObject.h.

Referenced by LinearIntegrator::integrate().

◆ set_mass

void PhysicsObject::set_mass
inline

Set the mass in slugs (or kilograms).

Definition at line 104 of file physicsObject.h.

◆ set_oriented

void PhysicsObject::set_oriented
inline

Set flag to determine whether this object should do any rotation or orientation calculations.

Optimization.

Definition at line 110 of file physicsObject.h.

Referenced by OrientedParticle::OrientedParticle(), and PointParticle::PointParticle().

◆ set_position

void PhysicsObject::set_position
inline

Vector position assignment.

Piecewise position assignment.

This is also used as the center of mass.

Definition at line 105 of file physicsObject.h.

◆ set_rotation

void PhysicsObject::set_rotation
inline

set rotation as a quaternion delta per second.

Definition at line 112 of file physicsObject.h.

◆ set_terminal_velocity

void PhysicsObject::set_terminal_velocity
inline

tv assignment

Definition at line 109 of file physicsObject.h.

◆ set_velocity

void PhysicsObject::set_velocity
inline

Vector velocity assignment.

Piecewise velocity assignment.

Definition at line 107 of file physicsObject.h.


The documentation for this class was generated from the following files: