⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ivp_actuator.hxx

📁 hl2 source code. Do not use it illegal.
💻 HXX
📖 第 1 页 / 共 2 页
字号:
// Copyright (C) Ipion Software GmbH 1999-2000. All rights reserved.

//IVP_EXPORT_PUBLIC

#ifndef WIN32
#	pragma interface
#endif

#if !defined(IVP_ACTUATOR_INCLUDED)
#	define IVP_ACTUATOR_INCLUDED

class IVP_Template_Check_Dist;
class IVP_Template_Force;
class IVP_Template_Extra;
class IVP_Template_Rot_Mot;
class IVP_Template_Spring;
class IVP_Template_Stabilizer;
class IVP_Template_Two_Point;
class IVP_Template_Four_Point;
class IVP_Template_Anchor;

#ifndef _IVP_ACTUATOR_INFO_INCLUDED
#	include "ivp_actuator_info.hxx"
#endif

#ifndef _IVP_CONTROLLER_INCLUDED
#	include "ivp_controller.hxx"
#endif

#ifndef _IVP_ACTIVE_VALUES_INCLUDED
#	include "ivu_active_value.hxx"
#endif

#ifndef _IVP_LISTENER_HULL_INCLUDED
#	include <ivp_listener_hull.hxx>
#endif



/********************************************************************************
 *	Name:	       	IVP_Template_Anchor
 *	Description:	A fixed point in an objects coordinate system.
 *			Normally used by actuators.
 *	Note:		Anchors may be used by more than one actuator.
 *			At the beginning of every PSI, the world coordinates of
 *			all anchors of the objects are calculated.
 *			To create an anchor, call IVP_Real_Object::create_anchor()
 ********************************************************************************/
class IVP_Template_Anchor {
	friend class IVP_Real_Object;
    friend class IVP_Anchor;
private:
    IVP_Real_Object *object;
    IVP_U_Point coords_world;	// coordinates in world space
public:
    IVP_Real_Object *get_object(){ return object; };
    IVP_U_Point *get_anchor_point_ws(){ return &coords_world; };
    
    // unit for all conversion methods: meters
	void set_anchor_position_ws(IVP_Real_Object *obj, const IVP_U_Point *coords_ws);
	void set_anchor_position_ws(IVP_Real_Object *obj, const IVP_DOUBLE x, const IVP_DOUBLE y, const IVP_DOUBLE z);
	void set_anchor_position_os(IVP_Real_Object *obj, const IVP_U_Float_Point *coords_os);
	void set_anchor_position_os(IVP_Real_Object *obj, const IVP_DOUBLE x, const IVP_DOUBLE y, const IVP_DOUBLE z);
#if 1
	void set_anchor_position_cs(IVP_Real_Object *obj, const IVP_U_Float_Point *coords_cs);
	void set_anchor_position_cs(IVP_Real_Object *obj, const IVP_DOUBLE x, const IVP_DOUBLE y, const IVP_DOUBLE z);
#endif
    const IVP_U_Point *get_anchor_position_ws() const { return & coords_world; };
};


/********************************************************************************
 *	Name:	       	IVP_Template_Two_Point
 *	Description:	Two anchors
 ********************************************************************************/
class IVP_Template_Two_Point {
public:
    void *client_data;		// user definable data
    IVP_Template_Anchor *anchors[2];
    IVP_Template_Two_Point();
};

/********************************************************************************
 *	Name:	       	IVP_Template_Four_Point
 *	Description:	2 pair of anchors
 ********************************************************************************/
class IVP_Template_Four_Point {
public:
    void *client_data;		// user definable data
    IVP_Template_Anchor *anchors[4];
    IVP_Template_Four_Point();
};


/********************************************************************************
 *	Name:	       	IVP_Check_Dist
 *	Description:	A actuator used for comparing  the distance between two
 *			anchors against a fixed range
 *	Input:		range:	the distance to check
 *	Output:		result of the check,
 *			the result is stored either in the info block of the Actuator
 *			and optionally in the mod_len and mod_is_outside active_floats
 *			
 *	Version Info:	its implementation is very, very fast, so several
 *			ten thousands IVP_Actuator_Check_Dist can be used at the same time.
 *			
 ********************************************************************************/

class IVP_Template_Check_Dist {
public:
    void *client_data;
    IVP_Real_Object *objects[2];	// objects the end points of the check distance is connected
    IVP_U_Point position_world_space[2];	// world position of the end points (unit: meters)
    
    IVP_FLOAT range; // distance to check (unit: meters)

    // output section
    IVP_U_Active_Terminal_Int *mod_is_outside; // optional active_int to write the result to

    IVP_Template_Check_Dist();
};


/********************************************************************************
 *	Name:	      	IVP_Template_Force
 *	Description:	Simple force, either static or dynamic (using active_floats)
 ********************************************************************************/

class IVP_Template_Force: public IVP_Template_Two_Point {
public:
    IVP_FLOAT force;                        // the force (unit: Newton)
    IVP_U_Active_Float *active_float_force;	// optional override of force

    IVP_BOOL push_first_object;         // default IVP_TRUE, apply force on first object ?
    IVP_BOOL push_second_object;	// default IVP_FALSE, apply neg. force on second object
    IVP_Template_Force();
};


/********************************************************************************
 *	Name:	      	IVP_Template_Torque
 *	Description:	Simple torque, either static or dynamic (using active_floats)
 ********************************************************************************/
class IVP_Template_Torque: public IVP_Template_Two_Point {
public:
    IVP_FLOAT torque;                        // torque force
    IVP_U_Active_Float *active_float_torque;	// optional override of torque

	IVP_FLOAT max_rotation_speed;			// max fabs(rotation speed) the torque will be applied
    IVP_U_Active_Float *active_float_max_rotation_speed;	// optional override of max_rot_speed

    IVP_U_Active_Terminal_Double *active_float_rotation_speed_out; // optional
    IVP_Template_Torque();
};


/********************************************************************************
 *	Name:	       	IVP_Template_Rot_Mot
 *	Description:	Rotation Motor
 *                      This simulates a motor (with power and a gear)
 ********************************************************************************/
class IVP_Template_Rot_Mot: public IVP_Template_Two_Point {
public:
    IVP_FLOAT max_rotation_speed; // max absolute rotation speed [ angle/sec ]
    IVP_FLOAT power;              // the power which is applied to the object [J] = [N * m/sec]
                              // neg power means going backwards
    IVP_FLOAT max_torque;         // max absolute torque [n/(m*m)]
    
    IVP_U_Active_Float *active_float_max_rotation_speed;  // optional override of static value
    IVP_U_Active_Float *active_float_power;               // optional override of static value
    IVP_U_Active_Float *active_float_max_torque;          // optional override of static value

    IVP_U_Active_Terminal_Double *active_float_rotation_speed_out;
    IVP_Template_Rot_Mot();
};


/********************************************************************************
 *	Name:	      IVP_Template_Extra 	
 *	Description:  for ipion demos only (e.g. IVP_FLOAT cam)
 *	Attention:    forget this
 *	Version Info: will be deleted
 ********************************************************************************/
class IVP_Template_Extra: public IVP_Template_Two_Point {
public:
    IVP_Extra_Info info;
};


/********************************************************************************
 *	Name:	       	IVP_Template_Stabilizer
 *	Description:	Spring which calculates the differences between two
 *                      pairs of anchors and tries to keep the distances
 *                      of the points of each pair equal
 ********************************************************************************/
class IVP_Template_Stabilizer: public IVP_Template_Four_Point {
public:
    IVP_FLOAT stabi_constant;	/* in Newton/meter or (if stabi_values_are_relative) Newton/(meter*virtual_mass)
				 * (used to create mass independent systems) */
    IVP_U_Active_Float *active_float_stabi_constant;
    IVP_Template_Stabilizer();
};




/********************************************************************************
 *	Name:	      	IVP_Anchor 	
 *	Description:	An anchor is a position in an objects space
 *			It's used by actuators, which can share one anchor.
 *	Attention:	
 *	Version Info:
 ********************************************************************************/
class IVP_Anchor {
    friend class IVP_Real_Object;
    friend class IVP_Actuator_Two_Point;
    friend class IVP_Actuator_Four_Point;
    ~IVP_Anchor();
protected:
    IVP_Anchor *anchor_next_in_object;		// linked list of anchors per object
    IVP_Anchor *anchor_prev_in_object;
public:
    IVP_Real_Object *l_anchor_object;  // might be zero
    IVP_U_Float_Point object_pos;	// original position of object space
    IVP_U_Float_Point core_pos;		// core position of anchor
    class IVP_Actuator *l_actuator;
public:
    IVP_Anchor(){;};
    void object_is_going_to_be_deleted_event(IVP_Real_Object *obj);
    
    void init_anchor(IVP_Actuator *, IVP_Template_Anchor *);	// constructor, called by IVP_Real_Object::create_anchor
    IVP_Anchor *move_anchor(IVP_U_Point *coords_ws); 	// move anchor

    IVP_Anchor *get_next_anchor(){ return anchor_next_in_object; };
    IVP_Anchor *get_prev_anchor(){ return anchor_prev_in_object; };
    
    IVP_Real_Object *anchor_get_real_object() { return l_anchor_object; };
};



/********************************************************************************
 *	Name:	      	IVP_ACTUATOR_TYPE 	
 *	Description:	Needed for debugging	
 ********************************************************************************/
enum IVP_ACTUATOR_TYPE {
    IVP_ACTUATOR_TYPE_NONE,
    IVP_ACTUATOR_TYPE_SPRING,
    IVP_ACTUATOR_TYPE_STIFF_SPRING,
    IVP_ACTUATOR_TYPE_SUSPENSION,
    IVP_ACTUATOR_TYPE_FORCE,
    IVP_ACTUATOR_TYPE_ROT_MOT,
    IVP_ACTUATOR_TYPE_STABILIZER,
    IVP_ACTUATOR_TYPE_TORQUE,
    IVP_ACTUATOR_TYPE_ETC
};

/********************************************************************************
 *	Name:	      	IVP_Actuator 	
 *	Description:	All actuators are used to control forces on objects,
 *			Normally they are attached to several (mostly two) objects
 *			using anchors.
 *			All actuators of one type should normally by grouped
 *			by an actuator_manager. At every PSI all actuator_managers
 *		        execute their actuators code
 ********************************************************************************/
class IVP_Actuator : public IVP_Controller_Dependent
{
    friend class IVP_Actuator_Manager;
protected:
public:
    //Controller Section
    IVP_U_Vector<IVP_Core> actuator_controlled_cores;
    IVP_U_Vector<IVP_Core> *get_associated_controlled_cores() { return &actuator_controlled_cores; };
    IVP_CONTROLLER_PRIORITY get_controller_priority() { return IVP_CP_ACTUATOR; };

    IVP_Actuator(IVP_Environment *env);
    virtual void anchor_will_be_deleted_event(IVP_Anchor *del_anchor); // when an object is deleted it sends events to its connected actuators
    virtual void core_is_going_to_be_deleted_event(IVP_Core *my_core);
    virtual ~IVP_Actuator();
};


/********************************************************************************
 *	Name:	       	IVP_Actuator_Two_Point	
 *	Description:	For all standard cases, two anchors per actuator are
 *			sufficient. This is the base class for all such actuators
 *	Attention:	
 *	Version Info:
 ********************************************************************************/
class IVP_Actuator_Two_Point : public IVP_Actuator
{
    friend class IVP_Actuator_Four_Point;
protected:
    IVP_Anchor anchors[2];	// the two anchors
    void unlink_from_objects();
public:    
    IVP_Actuator_Two_Point( IVP_Environment *, IVP_Template_Two_Point *two_point_templ,IVP_ACTUATOR_TYPE ac_type);
    virtual ~IVP_Actuator_Two_Point();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -