ray

相机射线目标检测

梦想的初衷 提交于 2019-12-26 16:24:18
/// <summary> /// 从相机发射射线 返回hitPoint 若未射到物体,返回值为相机forward加rayRange的范围点 /// </summary> /// <param name="rayCamera"> 发射射线的相机</param> /// <param name="rayRange">未射到物体时,返回的射线可达最大范围值</param> /// <returns> 确定瞄准点 </returns> public static Vector3 CameraRayPosition(Camera rayCamera,int rayRange) { RaycastHit hit; Ray ray = new Ray(rayCamera.transform.position, rayCamera.transform.forward); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { return hit.point; } else { return rayCamera.transform.position + (rayCamera.transform.forward * rayRange); } } 来源: CSDN 作者: ysong0913 链接: https://blog.csdn.net

用 shader effect 实现雨滴落水效果!Cocos Creator 3D !

时光总嘲笑我的痴心妄想 提交于 2019-12-26 12:11:24
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> > 最近逛论坛时,看到一位大佬在分享各种 shader 特效。基于其中的水波 shader ,白玉无冰写了一个玩水效果!文章底部获取完整代码!还可以试试水哦! 先一起看看效果~ 点击任意位置,会在该位置生成一个水纹,就像是雨水落在水洼中一样~ 如何使用 effect 文件?新建一个 material ,Effect 属性选择 water , 接着将纹理图片拖到相应参数。 最后为你的模型节点选择材料。 水纹片元着色器实现原理:通过计算与点击点的距离和方向,用 sin 函数模拟水纹效果。通过计算点击时间戳和当前时间与距离,判断是否添加水纹效果。再将多个点击点叠加起来,得到 texture 最终 uv 。 主要代码如下。 for(int i = 0; i < 10; i++){ vec2 uvDir = normalize(v_uv - center[i].xy); float dis = distance(v_uv, center[i].xy); float dis_time = center[i].z - cc_time.x + dis * 3.0; if ( center[i].z > 0.0 && dis_time < 0.0 && dis_time > -0.1 ){ uv += sin_A * uvDir

Error while initializing Ray on an EC2 master node

风格不统一 提交于 2019-12-24 07:16:15
问题 I am using Ray to run a parallel loop on an Ubuntu 14.04 cluster on AWS EC2. The following Python 3 script works well on my local machine with just 4 workers (imports and local initializations left out):- ray.init() #initialize Ray @ray.remote def test_loop(n): c=tests[n,0] tout=100 rc=-1 with tmp.TemporaryDirectory() as path: #Create a temporary directory for files in filelist: #then copy in all of the sh.copy(filelist,path) #files txtfile=path+'/inputf.txt' #create the external fileId=open

can't pickle _thread.RLock objects when running tune of ray packge for python (hyper parameter tuning)

不羁的心 提交于 2019-12-24 00:36:29
问题 I am trying to do a hyper parameter tuning with the tune package of Ray. Shown below is my code: # Disable linter warnings to maintain consistency with tutorial. # pylint: disable=invalid-name # pylint: disable=g-bad-import-order from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf import matplotlib as mplt mplt.use('agg') # Must be before importing matplotlib.pyplot or pylab! import matplotlib.pyplot as plt

Using shared array in multiprocessing

人盡茶涼 提交于 2019-12-23 03:22:18
问题 I am trying to run a parallel process in python, wherein I have to extract certain polygons from a large array based on some conditions. The large array has 10k+ polygons that are indexed. In a extract_polygon function I pass (array, index). Based on index the function has to either return the polygon corresponding to that index or not based on the conditions defined. The array is never changed and is only used for reading the polygon based on the index provided. Since the array is very large

Unity3D射线

独自空忆成欢 提交于 2019-12-15 00:45:17
射线 射线分类:线段,球形 如何发射两种射线: 1.发射线段 //射线只能返回第一碰撞物体信息 Ray ray = Camera.main.ScreenToRay(Input.mousePosition); RaycastHit info; if(Physics.Raycast(ray,info,Mathf.Infinity,1<<LayerMask.NameToLayer("Item"))){ Mathf.Infinity 射线长度 无限大 LayerMask.NameToLayer("Item")只能碰撞这些层的物体 } //射线返回所有碰撞物体的信息 Ray ray = Camera.main.ScreenToRay(Input.mousePosition); RaycastHit[] infoArr =Physics.Raycast (ray,Mathf.Infinity,1<<LayerMask.NameToLayer("Item")); 2.发射球形射线 Collider[] collider = Physics.OverlapSphere(发射的位置,发射半径,层); 来源: CSDN 作者: 醉幻d落叶 链接: https://blog.csdn.net/qq_42693717/article/details/100888256

ap_uniform_sampler() missing 1 required positional argument: 'high' in Ray Tune package for python

萝らか妹 提交于 2019-12-12 13:07:11
问题 I am trying to use the Ray Tune package for hyperparameter tuning of a LSTM implemented using pure Tensorflow. I used the hyperband scheduler and HyperOptSearch algorithms for this and I am also using the trainable class method. When I try to run it I get the following error: TypeError: ap_uniform_sampler() missing 1 required positional argument: 'high' shown below is the stack trace: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In

Ray cluster configuration file_mounts section not allowing worker nodes to launch

跟風遠走 提交于 2019-12-11 15:57:50
问题 I am trying to distribute a small number of files to each node in a Ray cluster on AWS EC2, using the file_mounts block in the configuration file:- file_mounts: { "./": "./run_files" } The cluster launches with only a master node, onto which the contents of the run_files directory have been correctly copied. However, the two worker nodes that were requested do not launch. If I omit the file_mounts section, the workers launch. The Ray monitor indicates that there is a problem locating the file

Remote calls are blocking when used on methods in an Actor Object?

落花浮王杯 提交于 2019-12-11 12:40:33
问题 Executing the following will not work concurrently, instead it will first execute Run1 and block until it's completed, before it will execute Run2. @ray.remote class Test: def __init__(self): pass def Run1(self): print('Run1 Start') sleep(5) print('Run1 End') def Run2(self): print('Run2') ray.init() test = Test.remote() test.Run1.remote() test.Run2.remote() sleep(10) Output: (pid=8109) Run1 Start (pid=8109) Run1 End (pid=8109) Run2 This is a bit unexpected. How can I enforce that the methods

Computing Science CMPT 361

我的未来我决定 提交于 2019-12-05 04:49:19
Computing Science CMPT 361 Fall 2019 Assignment #3 Due date: November 27th at 11:59 pm. Ray Tracing You will write a basic ray tracer. The entire assignment can be completed in Euclidean space; there is no need for homogeneous coordinates. There are 25 points available. (a) [1 point] Window setup Use OpenGL to set up a window with a 400 x 400 pixel drawing window. Use a symbolic constant rather than 400 so that you can change resolution by changing the constant. (b) [2 points] Viewing The eyepoint is the origin, and the view is down the negative z-axis with the y-axis pointing up. The