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

📄 ivp_actuator.hxx

📁 hl2 source code. Do not use it illegal.
💻 HXX
📖 第 1 页 / 共 2 页
字号:
    IVP_Anchor *get_actuator_anchor(int i) { return &anchors[i]; }

    void *client_data;
    void ensure_actuator_in_simulation();
    IVP_DOUBLE calc_len(); 				// calc the distance between both anchors, it's only valid during the PSI  
};


/********************************************************************************
 *	Name:	       	IVP_Actuator_Four_Point	
 *	Description:	For stabilizer e.g.
 ********************************************************************************/
class IVP_Actuator_Four_Point : public IVP_Actuator
{
protected:
    IVP_Anchor anchors[4];	// the four anchors
public:
    void *client_data;
    

    IVP_Actuator_Four_Point( IVP_Environment *, IVP_Template_Four_Point *four_point_templ,
			     IVP_ACTUATOR_TYPE ac_type);
    virtual ~IVP_Actuator_Four_Point();
    
    IVP_Anchor *get_actuator_anchor(int i) { return &anchors[i]; }
};




/********************************************************************************
 *	Name:	     	IVP_Actuator_Force
 *	Description:	Forces push one or two objects at the anchor position.
 *			The force value can be controlled by an IVP_Active_Float 
 *	Attention:	To create a force use the IVP_Environment->create_force function
 *                      Constantly changing the force value will cause that
 *			the involved objects are never taken out of simulation.
 *			(What means unnessary CPU consumption when e.g.
 *                      invisible trees are rattled unnecessesarily.)
 ********************************************************************************/

class IVP_Actuator_Force: public IVP_Actuator_Two_Point
{
    friend class IVP_Force_Manager;

    IVP_FLOAT force;                        // the force 
    IVP_BOOL push_first_object:1;
    IVP_BOOL push_second_object:1;
protected:
    friend class IVP_Environment;

    // To create a new force actuator, use the method IVP_Environment->create_force
    IVP_Actuator_Force(IVP_Environment *env, IVP_Template_Force *templ);
public:
    void set_force(IVP_DOUBLE new_force);
    virtual ~IVP_Actuator_Force();

    void do_simulation_controller(IVP_Event_Sim *,IVP_U_Vector<IVP_Core> *core_list);
};


class IVP_Actuator_Force_Active: public IVP_Actuator_Force, IVP_U_Active_Float_Listener
{
    IVP_U_Active_Float *active_float_force;	// optional override of force
protected:
    void active_float_changed(IVP_U_Active_Float *calling_mod); // for wakup
    friend class IVP_Environment;
    IVP_Actuator_Force_Active(IVP_Environment *env, IVP_Template_Force *templ);
public:
    // to create a new use the IVP_Environment->create_force function
    virtual ~IVP_Actuator_Force_Active();
};


/********************************************************************************
 *	Name:	      	IVP_Actuator_Rot_Mot	
 *	Description:	rotation motors allows to rotate objects around a given
 *			axis. (E.g. car wheels, wind mills)
 *	Note:		Values can be changed on the fly using IVP_U_Active_Floats
 ********************************************************************************/
class IVP_Actuator_Rot_Mot: public IVP_Actuator_Two_Point
{
    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)]
    
    
    friend class IVP_Rot_Mot_Manager;

    IVP_U_Float_Point axis_in_core_coord_system;
    IVP_DOUBLE rot_inertia;
    
    //void do_rot_mot(IVP_DOUBLE d_time);
    IVP_U_Active_Terminal_Double *active_float_rotation_speed_out;
protected:
    friend class IVP_Environment;
    IVP_Actuator_Rot_Mot(IVP_Environment *env, IVP_Template_Rot_Mot *templ);
public:
    IVP_FLOAT rot_speed_out;		// used to export the last rotation speed
    void set_max_rotation_speed( IVP_DOUBLE );
    void set_power(IVP_DOUBLE);
    IVP_FLOAT get_power() { return power; };
    void set_max_torque(IVP_DOUBLE);

    void do_simulation_controller(IVP_Event_Sim *,IVP_U_Vector<IVP_Core> *core_list);
  
    virtual ~IVP_Actuator_Rot_Mot();
};


class IVP_Actuator_Rot_Mot_Active: public IVP_Actuator_Rot_Mot, public IVP_U_Active_Float_Listener {
    IVP_U_Active_Float *active_float_max_rotation_speed;
    IVP_U_Active_Float *active_float_power;
    IVP_U_Active_Float *active_float_max_torque;
    void active_float_changed(IVP_U_Active_Float *calling_mod); // for wakup
public:
    IVP_Actuator_Rot_Mot_Active(IVP_Environment *env, IVP_Template_Rot_Mot *templ);
    ~IVP_Actuator_Rot_Mot_Active();
};


/********************************************************************************
 *	Name:	      	IVP_Actuator_Torque	
 *	Description:	torques allows to rotate objects around a given
 *			axis. (E.g. car wheels, wind mills)
 *	Note:		Values can be changed on the fly [e.g. by using IVP_U_Active_Floats]
 ********************************************************************************/
class IVP_Actuator_Torque: public IVP_Actuator_Two_Point
{
    IVP_FLOAT max_rotation_speed; // max absolute rotation speed [ angle/sec ]
    IVP_FLOAT torque;              // the torque which is applied to the object = [N*m]
                              // neg torque means going backwards
    IVP_U_Float_Point axis_in_core_coord_system;
    IVP_DOUBLE rot_inertia;
    
    IVP_U_Active_Terminal_Double *active_float_rotation_speed_out;
protected:
    friend class IVP_Environment;

    void do_simulation_controller(IVP_Event_Sim *,IVP_U_Vector<IVP_Core> *core_list);

    IVP_Actuator_Torque(IVP_Environment *env, IVP_Template_Torque *templ);
public:
    IVP_FLOAT rot_speed_out;		// used to export the last rotation speed
    void set_max_rotation_speed( IVP_DOUBLE );
    void set_torque(IVP_DOUBLE);
    IVP_FLOAT get_torque() { return torque; };
    
    virtual ~IVP_Actuator_Torque();
};


class IVP_Actuator_Torque_Active: public IVP_Actuator_Torque, public IVP_U_Active_Float_Listener {
    IVP_U_Active_Float *active_float_max_rotation_speed;
    IVP_U_Active_Float *active_float_torque;
    void active_float_changed(IVP_U_Active_Float *calling_mod); // for wakup
public:
    IVP_Actuator_Torque_Active(IVP_Environment *env, IVP_Template_Torque *templ);
    ~IVP_Actuator_Torque_Active();
};

/********************************************************************************
 *	Name:	    	IVP_Listener_Check_Dist_Event
 *	Description:	Callback for check dists events
 ********************************************************************************/
class IVP_Listener_Check_Dist_Event {
public:
    virtual void check_dist_event(IVP_Actuator_Check_Dist *, IVP_BOOL distance_shorter_than_range)=0;
    virtual void check_dist_is_going_to_be_deleted_event(IVP_Actuator_Check_Dist *)=0;	// has to remove itself from IVP_Actuator_Check_Dist
};


/********************************************************************************
 *	Name:	     	IVP_Anchor_Check_Dist  	
 *	Description:	A fixed object space point needed for check dists
 *	Attention:	
 ********************************************************************************/
class IVP_Anchor_Check_Dist : public IVP_Listener_Hull
{
public:
    IVP_HULL_ELEM_TYPE get_type(){ return IVP_HULL_ELEM_ANCHOR; };
    virtual void hull_limit_exceeded_event(IVP_Hull_Manager *, IVP_HTIME);
    virtual void hull_manager_is_going_to_be_deleted_event(IVP_Hull_Manager *);

    IVP_Real_Object *real_object;
    IVP_Actuator_Check_Dist *l_actuator_check_dist;
    IVP_U_Float_Point object_pos;	// original position of object space

    IVP_Anchor_Check_Dist(){; };
    void init_anchor_check_dist(IVP_Real_Object *object, IVP_U_Point *position_world_space, IVP_Actuator_Check_Dist *my_act_check_dist);
    virtual ~IVP_Anchor_Check_Dist();
};

/********************************************************************************
 *	Name:	       	IVP_Actuator_Check_Dist
 *	Description:	compares the distance of two check anchors against a predefined
 *			distance.
 *	Note:		the implementation of this check_dist actuator is pretty
 *			fast as long as anchors between check dists are shared.
 *	Version Info:	In future releases check dists may not subclass IVP_Actuator_Two_Point
 ********************************************************************************/
class IVP_Actuator_Check_Dist
{
    IVP_Anchor_Check_Dist anchors[2];	// the two anchors
    IVP_FLOAT range;
    
    /** Listeners */    
    IVP_U_Vector<IVP_Listener_Check_Dist_Event> listeners_check_dist_event;
    IVP_U_Active_Terminal_Int *mod_is_outside; // optional active_int to write the result to

    void fire_check_dist_event(IVP_BOOL distance_shorter_than_range);
    void fire_check_dist_is_going_to_be_deleted_event( );
protected:
    friend class IVP_Anchor_Check_Dist;
    void hull_limit_exceeded_event();		// internal use
    friend class IVP_Environment;
    IVP_Actuator_Check_Dist(IVP_Environment *env, IVP_Template_Check_Dist *check_dist);
public:    
    void *client_data;		// user definable data
    IVP_BOOL is_outside;

    void set_range(IVP_DOUBLE value);
    
    void add_listener_check_dist_event(IVP_Listener_Check_Dist_Event *listener);
    void remove_listener_check_dist_event(IVP_Listener_Check_Dist_Event *listener);
    
    ~IVP_Actuator_Check_Dist();
};



// INTERN_START
/********************************************************************************
 *	Name:	       	IVP_Actuator_Extra
 *	Description:	not for public use yet
 *			used for various demo purposes
 *	Version Info:	beautification is needed, 
 ********************************************************************************/
class IVP_Actuator_Extra: public IVP_Actuator_Two_Point, public IVP_U_Active_Float_Listener
{
    friend class IVP_Extra_Manager;
    IVP_Extra_Info info;
public:
    IVP_U_Point current_float_cam_pos;
    
    IVP_U_Point current_look_point;
    IVP_BOOL current_vals_are_set;  // for first time

    IVP_U_Point *get_float_cam_props(IVP_DOUBLE *fc_height_out, IVP_DOUBLE *fc_target_height_out, IVP_DOUBLE *fc_dist_out, IVP_DOUBLE *fc_speed_out); // returns &current_float_cam_pos
    
    IVP_DOUBLE get_force();	// needed by bomb

    void do_float_cam(IVP_DOUBLE d_time);
    void do_puck_force(IVP_DOUBLE d_time);
    void do_simulation_controller(IVP_Event_Sim *,IVP_U_Vector<IVP_Core> *core_list);
  
    void active_float_changed(IVP_U_Active_Float *calling_mod); // for bombs

    void calc_float_cam_matrix(IVP_U_Matrix *cam_matrix_out);
    IVP_Actuator_Extra(IVP_Environment *env, IVP_Template_Extra *templ);
    virtual ~IVP_Actuator_Extra();
};
// INTERN_END





/********************************************************************************
 *	Name:	       	IVP_Stabilizer_Info
 *	Description:	Values to IVP_Actuator_Stabilizer,
 *			tries to eliminate differences between two distances,
 *			useable for stabilization of a car axis.
 *	Attention:	Too high stabi constants result in higher frequency than
 *			PSI rate and will cause high unnatural speeds of objects
 ********************************************************************************/
class IVP_Actuator_Stabilizer: public IVP_Actuator_Four_Point
{
    friend class IVP_Stabilizer_Manager;
    IVP_Environment *l_environment;

protected:
    IVP_FLOAT stabi_constant;
    friend class IVP_Environment;
    IVP_Actuator_Stabilizer(IVP_Environment *env, IVP_Template_Stabilizer *stabi);
    void do_simulation_controller(IVP_Event_Sim *,IVP_U_Vector<IVP_Core> *core_list);
public:
    void set_stabi_constant(IVP_DOUBLE);
    
    virtual ~IVP_Actuator_Stabilizer();
};

#if !defined( IVP_ACTUATOR_SPRING_INCLUDED )
#	include <ivp_actuator_spring.hxx>
#endif

#endif /* ifndef IVP_ACTUATOR_INCLUDED */

⌨️ 快捷键说明

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