Ue4中的框选函数
void AHUD::GetActorsInSelectionRectangle(TSubclassOf<class AActor> ClassFilter, const FVector2D& FirstPoint, const FVector2D& SecondPoint, TArray<AActor*>& OutActors, bool bIncludeNonCollidingComponents, bool bActorMustBeFullyEnclosed)
{
// Because this is a HUD function it is likely to get called each tick,
// so make sure any previous contents of the out actor array have been cleared!
OutActors.Empty(); //Create Selection Rectangle from Points
FBox2D SelectionRectangle(); //This method ensures that an appropriate rectangle is generated,
// no matter what the coordinates of first and second point actually are.
SelectionRectangle += FirstPoint;
SelectionRectangle += SecondPoint; //The Actor Bounds Point Mapping
const FVector BoundsPointMapping[] =
{
FVector(, , ),
FVector(, , -),
FVector(, -, ),
FVector(, -, -),
FVector(-, , ),
FVector(-, , -),
FVector(-, -, ),
FVector(-, -, -)
}; //~~~ //For Each Actor of the Class Filter Type
for (TActorIterator<AActor> Itr(GetWorld(), ClassFilter); Itr; ++Itr)
{
AActor* EachActor = *Itr; //Get Actor Bounds //casting to base class, checked by template in the .h
const FBox EachActorBounds = Cast<AActor>(EachActor)->GetComponentsBoundingBox(bIncludeNonCollidingComponents); /* All Components? */ //Center
const FVector BoxCenter = EachActorBounds.GetCenter(); //Extents
const FVector BoxExtents = EachActorBounds.GetExtent(); // Build 2D bounding box of actor in screen space
FBox2D ActorBox2D();
for (uint8 BoundsPointItr = ; BoundsPointItr < ; BoundsPointItr++)
{
// Project vert into screen space.
const FVector ProjectedWorldLocation = Project(BoxCenter + (BoundsPointMapping[BoundsPointItr] * BoxExtents));
// Add to 2D bounding box
ActorBox2D += FVector2D(ProjectedWorldLocation.X, ProjectedWorldLocation.Y);
} //Selection Box must fully enclose the Projected Actor Bounds
if (bActorMustBeFullyEnclosed)
{
if(SelectionRectangle.IsInside(ActorBox2D))
{
OutActors.Add(Cast<AActor>(EachActor));
}
}
//Partial Intersection with Projected Actor Bounds
else
{
if (SelectionRectangle.Intersect(ActorBox2D))
{
OutActors.Add(Cast<AActor>(EachActor));
}
}
}
}
Ue4中的框选函数的更多相关文章
- ArcGis 中MapControl 框选
void mCtrl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) ...
- ArcGIS中使用异步回调函数查询图层Graphic
在我们的地图的操作中经常会有一些操作是需要通过画多边形或者画线来查找某一块区域内的特定的Graphics比如我们在做的交警的项目中通过框选来查找某一块区域中的摄像机,某一块区域中的警力.警情.警员等相 ...
- QTableView中嵌入复选框CheckBox 的四种方法总结
搜索了一下,QTableView中嵌入复选框CheckBox方法有四种: 第一种不能之前显示,必须双击/选中后才能显示,不适用. 第二种比较简单,通常用这种方法. 第三种只适合静态显示静态数据用 第四 ...
- python QQTableView中嵌入复选框CheckBox四种方法
搜索了一下,QTableView中嵌入复选框CheckBox方法有四种: 第一种不能之前显示,必须双击/选中后才能显示,不适用. 第二种比较简单,通常用这种方法. 第三种只适合静态显示静态数据用 第四 ...
- jQuery+SpringMVC中的复选框选择与传值
一.checkbox选择 在jQuery中,选中checkbox通用的两种方式: $("#cb1").attr("checked","checked& ...
- 在word中做复选框打对勾钩
在word中做复选框打对勾钩 现在终于搞明白正确的操作方法 一.你在word里输入2610,按alt+X就能出 空checkbox 你在word里输入2611,按alt+X就能出 打了勾的checkb ...
- nodetree中 前面复选框禁用插件
nodetree中 前面复选框的去掉插件 extendTreeCheck.js /** * tree方法扩展 * 作者:小雪转中雪 */ $.extend($.fn.tree.methods, { / ...
- Jquery获取当前页面中的复选框选中的内容
在使用$.post提交数据时,有一个数据是复选框获取数据,所以在当前页面获取到复选框选中的值并提交到后端卡住了一下,解决方法如下: 这两个input就是复选框的内容: str += "< ...
- Unity3D中画拉选框(绘制多选框)
问题分析: 需要根据鼠标事件,摁下鼠标开始绘制选择框,抬起鼠标结束绘制. 实现思路: 该需求是屏幕画线,Unity内置了GL类 封装了OpenGL,可以通过GL类来实现一些简单的画图操作,这里也是使 ...
随机推荐
- 'XCTest/XCTest.h' file not found
直接写解决方法吧:在报错的 Target 中的 Building Settings 中 Framework Search Paths 里面添加 $(PLATFORM_DIR)/Developer/Li ...
- @RequestMapping详解
简介: @RequestMapping RequestMapping是一个用来处理请求地址映射的注解,可用于类或方法上.用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径. RequestM ...
- 重温WCF之构建一个简单的WCF(一)(2)通过Windows Service寄宿服务和WCF中实现操作重载
参考地址:http://www.cnblogs.com/zhili/p/4039111.html 一.如何在Windows Services中寄宿WCF服务 第一步:创建Windows 服务项目,具体 ...
- My97DatePicker使用技巧
My97DatePicker使用是很常用的控件,总结一下常用使用技巧: 1.onpicked是事件,也就选择日期之后触发事件: 2.isShowClear:是否显示清理按钮: 3.maxDate:最大 ...
- jQuery函数attr()和prop()的区别
在jQuery中,attr()函数和prop()函数都用于设置或获取指定的属性,它们的参数和用法也几乎完全相同. 但不得不说的是,这两个函数的用处却并不相同.下面我们来详细介绍这两个函数之间的区别. ...
- JAVA 使用线程的几种方式
之前放在自己网站上的例子,因为网站关闭,已经找不到了,想用的时候,没有的话又重新翻书是很麻烦的事情.所以重新记录一下,以备将来查看. 第一种,让任务类继承Runable接口,然后将任务类对象放入Thr ...
- 莫队算法 2038: [2009国家集训队]小Z的袜子(hose)
链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 2038: [2009国家集训队]小Z的袜子(hose) Time Limit: 20 ...
- C和C++混合编程(__cplusplus 与 external "c" 的使用)
转自:http://blog.csdn.net/ljfth/article/details/3965871 第一种理解比如说你用C++开发了一个DLL库,为了能够让C语言也能够调用你的DLL输出(Ex ...
- apache https配置步骤
转自:http://www.cnblogs.com/best-jobs/p/3298258.html 1. 确认是否安装ssl模块 是否有mod_ssl.so文件 2. 生成证书和密钥 linux ...
- 2015最新移动App设计尺寸视觉规范【图文版】(转)
如今手机app的屏幕设计尺寸参差不齐,仿佛来到了移动界面尺寸战国时代,每家移动设备制造公司都为了迎合大众的口味,各家都在2014年大放光彩.2015年也将会是我们移动APP设计界快速发展的一年. 因为 ...