raycasting

How to find where to cast a ray to avoid collision in Bullet?

旧巷老猫 提交于 2019-11-27 21:25:09
问题 Say we have an object at point A. It wants to find out if it can move to point B. It has limited velocity so it can only move step by step. It casts a ray at direction it is moving to. Ray collides with an object and we detect it. How to get a way to pass our ray safely (avoiding collision)? btw, is there a way to make such thing work in case of object cast, will it be as/nearly fast as with simple ray cast? Is there a way to find optimal in some vay path? 回答1: What you're asking about is

three.js orthographic camera object picking

孤街醉人 提交于 2019-11-27 06:32:21
问题 i am trying to pick objects in a scene where i use an orthographic camera. my code fragment already works, but it is not precise. i already found some answers on stackoverflow, but those are deprecated or won't work anymore at all. here is my code onMouseDown function onDocumentMouseUp( event ) { event.preventDefault(); mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5); var

Unity Physics2D.Raycast hits itself

大城市里の小女人 提交于 2019-11-27 02:16:28
I'm trying to use Physics2D.Raycast in order to check if the player is on the ground (I know that there are other approaches to check if the player is on the ground but I think that the raycast is the most reliable). The problem is that in my scenario it returns the player itself as hit and I really don't understand why and what should I do. My code (in PlayerController ) is the following: public bool IsGrounded () { Bounds bounds = this.playerCollider.bounds; Vector3 rayOrigin = bounds.center; rayOrigin.y -= bounds.extents.y; RaycastHit2D hit = Physics2D.Raycast (rayOrigin, Vector2.down, 0.1f

Orthographic camera and selecting objects with raycast

冷暖自知 提交于 2019-11-27 01:52:35
I am running into a bit of difficulty selecting objects with the orthographic camera using the raycaster. Though, I have no problem with it when I use a perspective camera. The only thing I am changing when switching between the two is the type camera. I am able to select faces on the orthographic view, but it is only loosely related to where I am clicking on the screen. When I can click far away from the object and it will still come back as if it has hit the object near its center. Any ideas on what I am missing here? I am basing much of my code on this example , and am hoping to achieve a

JavaFX Moving 3D objects with mouse on a virtual plane

∥☆過路亽.° 提交于 2019-11-27 01:41:37
问题 As I was creating my first 3D game in JavaFX - where you would be able to assemble ships from parts using the mouse. This presents a problem since JAVAFX seems to have no native metods that work for converting PerspectiveCamera screen 2D coordinates into the scene's 3D space. Here is a representation of what I'm trying to acheive. A block moved by the mouse should move on an imaginary plane that is always rotated 90 in relation to the camera: I've tried to solve the problem with trigonometry

volume rendering (using glsl) with ray casting algorithm

对着背影说爱祢 提交于 2019-11-27 00:30:44
问题 I am learning volume rendering using ray casting algorithm. I have found a good demo and tuturial in here. but the problem is that I have a ATI graphic card instead of nVidia which make me can't using the cg shader in the demo, so I want to change the cg shader to glsl shader. I have gone through the red book (7 edition) of OpenGL, but not familiar with glsl and cg. does anyone can help me change the cg shader in the demo to glsl? or is there any materials to the simplest demo of volume

ThreeJS - how to pick just one type of objects?

♀尐吖头ヾ 提交于 2019-11-26 18:37:50
问题 I'm new to ThreeJS and I have an issue with picking objects by raycasting. I have created some spheres and some lines but only want to change the spheres on mouseover. I think I need to add some condition in the raycast code but I have no idea what... Here's my code, hope anyone can help: This creates the objects: var numSpheres = 10; var angRand = [numSpheres]; var spread = 10; var radius = windowY/5; var radiusControl = 20; //sphere var sphereGeometry = new THREE.SphereGeometry(0.35, 100,

How to do 2D shadow casting in Java?

大憨熊 提交于 2019-11-26 17:20:45
问题 I'm currently trying to implement a 2D shadow casting method in Java by following this tutorial: http://ncase.me/sight-and-light/ I want to stick to Line2D and Polygon objects. Here is the main part of my code so far: for (Polygon p : Quads.polygons) { for (int i = 0; i < p.npoints; i++) { osgCtx.setStroke(new BasicStroke(0.1f)); Line2D line = new Line2D.Double(mousePos.getX(), mousePos.getY(), p.xpoints[i], p.ypoints[i]); osgCtx.draw(line); } osgCtx.setStroke(new BasicStroke(1.0f)); osgCtx

Using Layers and Bitmask with Raycast in Unity

烂漫一生 提交于 2019-11-26 16:42:38
Unity's Raycast functions has a parameter you could use to raycast to a particular GameObject. You can also use that parameter to ignore particular GameObject. For exmple the Raycast function: public static bool Raycast(Vector3 origin, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal); The layerMask parameter is used to specified which Objects should/should not receive the raycast. 1 .How do you raycast to a particular GameObject which is in a layer called "cube"? 2

Orthographic camera and selecting objects with raycast

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 09:48:07
问题 I am running into a bit of difficulty selecting objects with the orthographic camera using the raycaster. Though, I have no problem with it when I use a perspective camera. The only thing I am changing when switching between the two is the type camera. I am able to select faces on the orthographic view, but it is only loosely related to where I am clicking on the screen. When I can click far away from the object and it will still come back as if it has hit the object near its center. Any