亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? navigationcell.cpp

?? 一個(gè)人工智能方面的小程序,用OPENGL和VC++做到,希望對(duì)大家有所啟發(fā)
?? CPP
字號(hào):
/* Copyright (C) Greg Snook, 2000.  * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Greg Snook, 2000" */#define NAVIGATIONCELL_CPP/****************************************************************************************\	NavigationCell.cpp	NavigationCell component implementation for the Navimesh sample program.	Included as part of the Game Programming Gems sample code.	Created 3/18/00 by Greg Snook	greg@mightystudios.com    ------------------------------------------------------------------------------------- 	Notes/Revisions:\****************************************************************************************/#include "navigationcell.h"#include "navigationheap.h"#include <stdlib.h>#include <assert.h>/*	ClassifyPathToCell------------------------------------------------------------------------------------------		Classifies a Path in relationship to this cell. A path is represented by a 2D line	where Point A is the start of the path and Point B is the desired position.	If the path exits this cell on a side which is linked to another cell, that cell index	is returned in the NextCell parameter and SideHit contains the side number of the wall 	exited through.		If the path collides with a side of the cell which has no link (a solid edge), 	SideHit contains the side number (0-2) of the colliding wall.	In either case PointOfIntersection will contain the point where the path intersected	with the wall of the cell if it is provided by the caller.	------------------------------------------------------------------------------------------*/NavigationCell::PATH_RESULT NavigationCell::ClassifyPathToCell(const Line2D& MotionPath, NavigationCell** pNextCell, CELL_SIDE& Side, vector2* pPointOfIntersection)const{	int InteriorCount = 0;	// Check our MotionPath against each of the three cell walls	for (int i=0; i<3; ++i)	{		// Classify the MotionPath endpoints as being either ON_LINE,		// or to its LEFT_SIDE or RIGHT_SIDE. 		// Since our triangle vertices are in clockwise order, 		// we know that points  to the right of each line are inside the cell.		// Points to the left are outside. 		// We do this test using the ClassifyPoint function of Line2D		// If the destination endpoint of the MotionPath 		// is Not on the right side of this wall...		if (m_Side[i].ClassifyPoint(MotionPath.EndPointB()) != Line2D::RIGHT_SIDE)		{			// ..and the starting endpoint of the MotionPath 			// is Not on the left side of this wall...			if (m_Side[i].ClassifyPoint(MotionPath.EndPointA()) != Line2D::LEFT_SIDE)			{				// Check to see if we intersect the wall 				// using the Intersection function of Line2D				Line2D::LINE_CLASSIFICATION IntersectResult = MotionPath.Intersection(m_Side[i], pPointOfIntersection);								if (IntersectResult == Line2D::SEGMENTS_INTERSECT || IntersectResult == Line2D::A_BISECTS_B)				{					// record the link to the next adjacent cell					// (or NULL if no attachement exists)					// and the enumerated ID of the side we hit.					*pNextCell = m_Link[i];					Side = (CELL_SIDE)i;					return (EXITING_CELL);				}			}		}		else		{			// The destination endpoint of the MotionPath is on the right side.			// Increment our InteriorCount so we'll know how many walls we were			// to the right of.			InteriorCount++;		}	}	// An InteriorCount of 3 means the destination endpoint of the MotionPath 	// was on the right side of all walls in the cell. 	// That means it is located within this triangle, and this is our ending cell.	if (InteriorCount == 3)	{		return (ENDING_CELL);	}	// We only reach here is if the MotionPath does not intersect the cell at all.	return (NO_RELATIONSHIP);}/*	ProjectPathOnCellWall------------------------------------------------------------------------------------------		ProjectPathOnCellWall projects a path intersecting the wall with the wall itself. This	can be used to convert a path colliding with a cell wall to a resulting path moving	along the wall. The input parameter MotionPath MUST contain a starting point (EndPointA)	which is the point of intersection with the path and cell wall number [SideNumber]	and an ending point (EndPointB) which resides outside of the cell.	------------------------------------------------------------------------------------------*/void NavigationCell::ProjectPathOnCellWall(CELL_SIDE SideNumber, Line2D& MotionPath)const{	// compute the normalized vector of the cell wall in question	vector2 WallNormal = m_Side[SideNumber].EndPointB() - m_Side[SideNumber].EndPointA();	WallNormal.normalize();	// determine the vector of our current movement	vector2 MotionVector = MotionPath.EndPointB() - MotionPath.EndPointA();	// compute dot product of our MotionVector and the normalized cell wall	// this gives us the magnatude of our motion along the wall	float DotResult = DotProduct(MotionVector,WallNormal);    	// our projected vector is then the normalized wall vector times our new found magnatude	MotionVector = (DotResult * WallNormal);	// redirect our motion path along the new reflected direction	MotionPath.SetEndPointB(MotionPath.EndPointA() + MotionVector);	//	// Make sure starting point of motion path is within the cell	//	vector2 NewPoint = MotionPath.EndPointA();	ForcePointToCellCollumn(NewPoint);	MotionPath.SetEndPointA(NewPoint);	//	// Make sure destination point does not intersect this wall again	//	NewPoint = MotionPath.EndPointB();	ForcePointToWallInterior(SideNumber, NewPoint);	MotionPath.SetEndPointB(NewPoint);}//:	ForcePointToWallInterior//----------------------------------------------------------------------------------------////	Force a 2D point to the interior side of the specified wall. ////-------------------------------------------------------------------------------------://bool NavigationCell::ForcePointToWallInterior(CELL_SIDE SideNumber, vector2& TestPoint)const{	float Distance = m_Side[SideNumber].SignedDistance(TestPoint);	float Epsilon = 0.001f;	if (Distance <= Epsilon)	{		if (Distance <= 0.0f)		{			Distance -= Epsilon;		}		Distance = (float)fabs(Distance);		Distance = (Epsilon>Distance ? Epsilon : Distance);		// this point needs adjustment		vector2 Normal = m_Side[SideNumber].Normal();		TestPoint += (Normal * Distance);		return (true);	}	return (false);}//:	ForcePointToWallInterior//----------------------------------------------------------------------------------------////	Force a 3D point to the interior side of the specified wall. ////-------------------------------------------------------------------------------------://bool NavigationCell::ForcePointToWallInterior(CELL_SIDE SideNumber, vector3& TestPoint)const{	vector2 TestPoint2D(TestPoint.x,TestPoint.z);	bool PointAltered = ForcePointToWallInterior(SideNumber, TestPoint2D);	if (PointAltered)	{		TestPoint.x = TestPoint2D.x;		TestPoint.z = TestPoint2D.y;	}	return (PointAltered);}//:	ForcePointToCellCollumn//----------------------------------------------------------------------------------------////	Force a 2D point to the interior cell by forcing it to the interior of each wall ////-------------------------------------------------------------------------------------://bool NavigationCell::ForcePointToCellCollumn(vector2& TestPoint)const{	bool PointAltered = false;	// create a motion path from the center of the cell to our point	Line2D TestPath(vector2(m_CenterPoint.x, m_CenterPoint.z), TestPoint);	vector2 PointOfIntersection;	CELL_SIDE Side;	NavigationCell* NextCell;	PATH_RESULT result = ClassifyPathToCell(TestPath, &NextCell, Side, &PointOfIntersection);	// compare this path to the cell.	if (result == EXITING_CELL)	{		vector2 PathDirection(PointOfIntersection.x - m_CenterPoint.x, PointOfIntersection.y - m_CenterPoint.z);		PathDirection *= 0.9f;		TestPoint.x = m_CenterPoint.x + PathDirection.x;		TestPoint.y = m_CenterPoint.z + PathDirection.y;		return (true);	}	else if (result == NO_RELATIONSHIP)	{		TestPoint.x = m_CenterPoint.x;		TestPoint.y = m_CenterPoint.z;		return (true);	}	return (false);}//:	ForcePointToCellCollumn//----------------------------------------------------------------------------------------////	Force a 3D point to the interior cell by forcing it to the interior of each wall ////-------------------------------------------------------------------------------------://bool NavigationCell::ForcePointToCellCollumn(vector3& TestPoint)const{	vector2 TestPoint2D(TestPoint.x,TestPoint.z);	bool PointAltered = ForcePointToCellCollumn(TestPoint2D);	if (PointAltered)	{		TestPoint.x=TestPoint2D.x;		TestPoint.z=TestPoint2D.y;	}	return (PointAltered);}//:	ProcessCell//----------------------------------------------------------------------------------------////	Process this cells neighbors using A* ////-------------------------------------------------------------------------------------://bool NavigationCell::ProcessCell(NavigationHeap* pHeap){	if (m_SessionID==pHeap->SessionID())	{		// once we have been processed, we are closed		m_Open  = false;		// querry all our neigbors to see if they need to be added to the Open heap		for (int i=0;i<3;++i)		{			if (m_Link[i])			{				// abs(i-m_ArrivalWall) is a formula to determine which distance measurement to use.				// The Distance measurements between the wall midpoints of this cell				// are held in the order ABtoBC, BCtoCA and CAtoAB. 				// We add this distance to our known m_ArrivalCost to compute				// the total cost to reach the next adjacent cell.				m_Link[i]->QueryForPath(pHeap, this, m_ArrivalCost+m_WallDistance[abs(i-m_ArrivalWall)]);			}		}		return(true);	}	return(false);}//:	QueryForPath//----------------------------------------------------------------------------------------////	Process this cell using the A* heuristic ////-------------------------------------------------------------------------------------://bool NavigationCell::QueryForPath(NavigationHeap* pHeap, NavigationCell* Caller, float arrivalcost){	if (m_SessionID!=pHeap->SessionID())	{		// this is a new session, reset our internal data		m_SessionID = pHeap->SessionID();		if (Caller)		{			m_Open  = true;			ComputeHeuristic(pHeap->Goal());			m_ArrivalCost = arrivalcost;			// remember the side this caller is entering from			if (Caller == m_Link[0])			{				m_ArrivalWall = 0;			}			else if (Caller == m_Link[1])			{				m_ArrivalWall = 1;			}			else if (Caller == m_Link[2])			{				m_ArrivalWall = 2;			}		}		else		{			// we are the cell that contains the starting location			// of the A* search.			m_Open  = false;			m_ArrivalCost = 0;			m_Heuristic = 0;			m_ArrivalWall = 0;		}		// add this cell to the Open heap		pHeap->AddCell(this);		return(true);	}	else if (m_Open)	{		// m_Open means we are already in the Open Heap.		// If this new caller provides a better path, adjust our data		// Then tell the Heap to resort our position in the list.		if ((arrivalcost + m_Heuristic) < (m_ArrivalCost + m_Heuristic))		{				m_ArrivalCost = arrivalcost;				// remember the side this caller is entering from				if (Caller == m_Link[0])				{					m_ArrivalWall = 0;				}				else if (Caller == m_Link[1])				{					m_ArrivalWall = 1;				}				else if (Caller == m_Link[2])				{					m_ArrivalWall = 2;				}				// ask the heap to resort our position in the priority heap				pHeap->AdjustCell(this);				return(true);		}	}	// this cell is closed	return(false);}//:	ComputeHeuristic//----------------------------------------------------------------------------------------////	Compute the A* Heuristic for this cell given a Goal point ////-------------------------------------------------------------------------------------://void NavigationCell::ComputeHeuristic(const vector3& Goal){	// our heuristic is the estimated distance (using the longest axis delta) between our	// cell center and the goal location	float XDelta = fabs(Goal.x - m_CenterPoint.x);	float YDelta = fabs(Goal.y - m_CenterPoint.y);	float ZDelta = fabs(Goal.z - m_CenterPoint.z);#ifdef _WIN32	m_Heuristic = __max(__max(XDelta,YDelta), ZDelta);#else	m_Heuristic = max(max(XDelta,YDelta), ZDelta);#endif}//****************************************************************************************// end of file      ( NavigationCell.cpp )

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产激情91久久精品导航 | 26uuu另类欧美| 99久久精品情趣| 久久精品噜噜噜成人88aⅴ| 国产精品久久久久国产精品日日| 91精品国产手机| 99久久免费视频.com| 精品在线播放免费| 亚洲成人777| 亚洲欧美另类图片小说| 国产亚洲精品久| 欧美一区二区二区| 91国产福利在线| 99视频在线观看一区三区| 老司机一区二区| 日欧美一区二区| 亚洲自拍偷拍麻豆| 亚洲丝袜精品丝袜在线| 国产亚洲精品aa午夜观看| 欧美一区二区女人| 欧美日产在线观看| 欧美亚洲动漫制服丝袜| 一本久久a久久精品亚洲| 丁香六月综合激情| 国产一区中文字幕| 精品在线你懂的| 久久精品免费看| 麻豆精品一区二区| 青青草原综合久久大伊人精品优势 | 国产免费成人在线视频| 精品国产一区二区精华| 日韩欧美精品在线视频| 欧美一级xxx| 欧美精品xxxxbbbb| 91精品久久久久久蜜臀| 欧美日韩一区二区三区四区五区 | 亚洲成人综合视频| 亚洲一级不卡视频| 亚洲国产成人精品视频| 亚洲国产日韩精品| 午夜国产精品影院在线观看| 亚洲国产aⅴ天堂久久| 亚洲va国产天堂va久久en| 亚洲国产色一区| 天堂精品中文字幕在线| 亚洲成人先锋电影| 日本强好片久久久久久aaa| 亚洲成人激情综合网| 日韩av一区二| 国产精品主播直播| 国产69精品久久99不卡| 成人av在线网站| 色综合一区二区三区| 欧美视频日韩视频| 欧美一区二区三区婷婷月色 | 欧美国产禁国产网站cc| 中文字幕中文在线不卡住| 一区二区三区四区在线免费观看| 亚洲精品视频在线看| 亚洲国产综合色| 看片网站欧美日韩| 国产美女主播视频一区| 99久久精品免费观看| 欧美色图12p| 久久网站热最新地址| 国产免费成人在线视频| 一区二区三区国产| 男人的j进女人的j一区| 国产乱码一区二区三区| av日韩在线网站| 欧美日韩免费电影| 日韩免费观看2025年上映的电影 | 成人影视亚洲图片在线| 一本高清dvd不卡在线观看| 欧美一区二区三区在线观看视频| 国产清纯美女被跳蛋高潮一区二区久久w| 国产精品久久久久7777按摩| 天天色天天操综合| 国产不卡一区视频| 欧美日韩久久一区| 久久久久国产精品麻豆ai换脸| 亚洲精选一二三| 免费在线观看一区二区三区| 成人黄色一级视频| 4438x成人网最大色成网站| 久久久不卡网国产精品一区| 亚洲一区视频在线| 国产乱码精品1区2区3区| 在线观看日韩毛片| 久久一区二区三区国产精品| 一区二区三区色| 国产高清不卡一区| 欧美高清精品3d| 国产精品久久久久久一区二区三区 | 欧美日韩专区在线| 国产人妖乱国产精品人妖| 五月天激情综合| 91网站黄www| 精品久久久久久久人人人人传媒 | 久久精品国产久精国产爱| 北条麻妃国产九九精品视频| 日韩午夜三级在线| 亚洲一区二区三区不卡国产欧美 | 欧美精品乱码久久久久久| 国产精品美女久久久久aⅴ| 免费人成黄页网站在线一区二区| 99久久99久久精品国产片果冻| 欧美成人精品二区三区99精品| 亚洲蜜桃精久久久久久久| 国产成人综合网站| 精品久久久久久综合日本欧美 | 国产白丝精品91爽爽久久| 欧美高清激情brazzers| 亚洲精品国产无天堂网2021| 国产不卡在线一区| 亚洲精品一线二线三线| 日韩电影一区二区三区| 欧美日韩专区在线| 一区二区三区在线免费| 91视频精品在这里| 国产欧美va欧美不卡在线| 韩国中文字幕2020精品| 欧美成人一区二区三区| 蜜桃在线一区二区三区| 91精品国产美女浴室洗澡无遮挡| 一区二区三区高清| 色狠狠综合天天综合综合| 亚洲日本成人在线观看| av电影在线观看完整版一区二区| 久久久久国产精品麻豆ai换脸| 黑人精品欧美一区二区蜜桃| 欧美zozozo| 蜜臀a∨国产成人精品| 欧美一级国产精品| 美女在线观看视频一区二区| 日韩一区二区中文字幕| 蜜臂av日日欢夜夜爽一区| 日韩欧美国产精品| 久久精品国产一区二区三区免费看| 日韩一区二区三| 久久99久久精品欧美| 久久夜色精品国产欧美乱极品| 国产美女娇喘av呻吟久久| 久久久国产精品不卡| 成人黄色软件下载| 亚洲欧美另类图片小说| 欧美系列在线观看| 琪琪一区二区三区| 精品成人在线观看| 国产福利一区二区| 亚洲色图清纯唯美| 欧美揉bbbbb揉bbbbb| 久久草av在线| 中文字幕欧美激情| 91搞黄在线观看| 日韩精品91亚洲二区在线观看| 日韩一级黄色片| 国产黄色精品视频| 亚洲人成人一区二区在线观看 | 国产精品一区二区三区四区| 国产精品三级视频| 色婷婷av一区二区三区软件| 亚洲一区二区欧美日韩| 日韩精品自拍偷拍| a在线欧美一区| 亚洲国产精品视频| 欧美v日韩v国产v| 播五月开心婷婷综合| 亚洲一线二线三线久久久| 日韩欧美自拍偷拍| 成人午夜免费视频| 亚洲最新在线观看| 久久综合狠狠综合久久综合88 | 久久99热狠狠色一区二区| 中文字幕欧美国产| 欧美精品一级二级三级| 国产精品亚洲综合一区在线观看| 中文字幕亚洲成人| 欧美人成免费网站| 懂色av一区二区在线播放| 一区二区三区四区在线| 欧美mv日韩mv国产网站| 91视频免费观看| 激情六月婷婷久久| 亚洲国产精品麻豆| 国产精品无人区| 欧美zozozo| 欧美综合天天夜夜久久| 久久成人麻豆午夜电影| 亚洲综合自拍偷拍| 欧美激情中文字幕一区二区| 欧美日韩精品免费| av不卡在线播放| 国产美女一区二区三区| 丝袜美腿高跟呻吟高潮一区| 国产精品久久福利| 26uuu久久综合| 欧美二区在线观看| 色系网站成人免费| 国产成人av自拍|