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

📄 parsevisual.h

📁 2002年
💻 H
字号:
#ifndef __PARSEVISUAL_H__
#define __PARSEVISUAL_H__


#include "serverparam.h"
#include "clientparam.h"

#include "types.h"
#include "smp_datastruct.h"
#include "worldmodel.h"

const int CP_num_stored_markerinfos = 3;
const int CP_num_stored_infos = 3;

//an unknown player in sight info
struct VisualUnkPlayer{
/* Receive Info*/
	Vector seenpos;
	TimedData<Vector> seench;
	Time t;						//seen time
	bool recognized;
	bool Is_side_known;
	bool tackling;
	float armdir;
/* Update Info*/
	Vector pos;
	VisualUnkPlayer(){
		Is_side_known = true;
	}
	void update();
	inline void Recognize(){ recognized = true; }
/*Other*/
	inline float seen_rel_angle(){return seenpos.y;}
	inline float seen_distance(){return seenpos.x;}
	void set_polar(float dist, float angle, Time t){
		seenpos.x = dist;
		seenpos.y = angle;
		this->t = t;
		recognized = false;
	}
	void set_other_info(float arm, bool Istackle){
		armdir = arm;
		tackling = Istackle;
	}
};

class VisualInfoProcess
{
protected:
	TimedDataArray<MarkerType, CP_num_stored_markerinfos> ClosestMarker;
	TimedDataArray<Index<VisualUnkPlayer, SP_team_size>, CP_num_stored_infos> My_Unk_Players;
	TimedDataArray<Index<VisualUnkPlayer, SP_team_size>, CP_num_stored_infos> Their_Unk_Players;
	TimedDataArray<Index<VisualUnkPlayer, SP_team_size>, CP_num_stored_infos> Teamless_Players;
	MarkerType MyGoal;
	MarkerType TheirGoal;

	void UpdateUnkPlayers(Time t);
public:	
	Time updated_sight_time;

	TimedDataArray<bool, CP_num_stored_infos> rec_sight_info;	//是否收到视觉消息	TimedDataArray<VIEWWIDTH, CP_num_stored_infos> view_widths;	//视觉模式
	Index<Time, CP_num_stored_infos> updated_sight;

	VIEWQUALITY ViewQuality;
	VIEWWIDTH ViewWidth;
	VIEWWIDTH LastViewWidth;
	VIEWWIDTH NextViewWidth;

	/**********************  Seen Objects   ********************************/
	Timed2D_Array<MarkerType, SP_num_markers+1, CP_num_stored_markerinfos> SeenMarkers;
	TimedDataArray<int, CP_num_stored_markerinfos> num_seenmarkers;
	Timed2D_Array<SideLine, SP_num_lines+1, CP_num_stored_markerinfos> SeenLines;
	TimedDataArray<int, CP_num_stored_markerinfos> num_seenlines;
	MarkerType LastClosestMarker;
protected:
	/*******************  Visual Information   ********************************/		
	void Parse_Sight(Time time,char* SensoryInfo);
	void Parse_Fullstate(Time time, char* SensoryInfo);

	void IdentifyMyGoalie(UNum No,bool IsGoalie);
	void IdentifyTheirGoalie(UNum No,bool IsGoalie);
	
	void SeeMarker(MarkerType marker,AngleDeg ang,Time time);
	void SeeMarker(MarkerType marker,float dist,AngleDeg ang,Time time);
	void SeeLine(SideLine line,AngleDeg ang,Time time);
	void SeeLine(SideLine line,float dist,AngleDeg ang,Time time);
	
	void SeeBall(AngleDeg ang,Time time);
	void SeeBall(float dist,AngleDeg ang,Time time);
	void SeeBall(float dist,AngleDeg ang,float distChng,float dirChng,Time time);
	void SeePlayer(AngleDeg ang,Time time);
	void SeePlayer(float dist,AngleDeg ang,Time time);
	void SeePlayer(char player_side,AngleDeg ang,Time time);
	void SeePlayer(char player_side,float dist,AngleDeg ang,Time time);
	void SeePlayer(char player_side,UNum NO,AngleDeg ang,Time time,bool IsGoalie);
	void SeePlayer(char player_side,UNum NO,float dist,AngleDeg ang,Time time,bool IsGoalie);
	void SeePlayer(char player_side,UNum NO,float dist,AngleDeg ang,float distChng,
		float dirChng,AngleDeg facedir,AngleDeg neckdir,Time time,bool IsGoalie);
	
	void FullSeePlayer(Time time, char playerside, int No, float posx, float posy, float velx, float vely, float bodyangle, float neckangle, int stamina, float effort, float recovery);
	void FullSeeBall(Time time, float posx, float posy, float velx, float vely);
	/************************************************************************/
public:
	VisualInfoProcess(){ 
		updated_sight_time = -1;
	};
	virtual ~VisualInfoProcess(){};
	/*Visual Mode*/
    int MySightInterval();
	static int SightInterval(VIEWWIDTH view_width, VIEWQUALITY quality = VQ_High);
	/*******************  Visual Information   ********************************/
	MarkerType ClosestGoal();
	MarkerType ClosestFlag();
	MarkerType GetClosestMarker(Time time){ return ClosestMarker.IsDataKnown(time) ? ClosestMarker.Data(time) : No_Marker;}	
};

class ParseVisualV7 : public VisualInfoProcess
{
protected:
	char *SightInfo;
	Time time;		
	float dist,ang, dirChng, distChng;
	ObjType object_type;
	char player_side;
	bool IsGoalie ;
	UNum player_number;
	float facedir, neckdir;
	MarkerType marker ;
	SideLine  line ;
	VIEWQUALITY view_qual;
	MarkerType closestMarker ;
	bool processThisMarker;
	float closestMarkerDist;

protected:
	virtual void Parse_Sight(Time time, char *SightInfo);
	virtual void ParseName();
	virtual void ParseData();
	virtual void ParsePlayerName();
	virtual void ParseFlagName();
	virtual void OBJisLine();
	virtual void OBJisBall();
	virtual void OBJisMarker();
	virtual void OBJisPlayer();

};

class ParseVisualV8 : public ParseVisualV7
{
protected:
	float	armdir;
	bool	tackling;

	virtual void ParseData();
	void OBJisPlayer();
protected:
	void SeePlayer(char player_side, UNum NO,float dist,AngleDeg ang,float distChng, float dirChng, AngleDeg facedir, AngleDeg neckdir, 	AngleDeg arm, bool tackling, Time time,bool IsGoalie);	
	void SeePlayer(char player_side, UNum NO,AngleDeg ang, AngleDeg arm, bool tackling, Time time,bool IsGoalie);
	void SeePlayer(char player_side, float dist, AngleDeg ang, AngleDeg arm, bool tackling, Time time);
	void SeePlayer(char player_side, UNum NO,float dist, AngleDeg ang, AngleDeg arm, bool tackling, Time time, bool IsGoalie);
	void SeePlayer(char player_side, AngleDeg ang,AngleDeg arm, bool tackling, Time time);
private:
	inline bool CheckEnd(){
		if (*SightInfo == ')') {
			tackling = false;
			return true;
		}
		if (*(SightInfo+1) == 't'){
			SightInfo+=2;
			tackling = true;
			return true;
		}
		return false;
	}
};

#endif //__PARSEVISUAL_H__

⌨️ 快捷键说明

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