raycasting

Convert 3D Raycast to Raycast2D

不羁岁月 提交于 2019-12-01 14:25:30
I have this code below which could control a touched player among 3 players. I was able to implement it by like sort of "cheating" by way of adding a 3D cube behind a 2D sprite since my game should be in 2D and I am having hard time implementing it in 2D. I'm really confused on how to do it in 2D because I'm really confuse on the parameters. Although I already implemented it by the way mentioned above, I still want to implement it in pure 2D. And because I have this problem when the selected player moves, the sprite moves faster. public GameObject target = null; // Use this for initialization

Changing Raycaster position dynamically

若如初见. 提交于 2019-12-01 12:17:27
I have a canvas, inside that I have several cubes. I use Raycaster to select them and change their colors. But the canvas is inside of a draggable object and when I move around I cannot change the colors, the color changing works in the original position. I think I also have to change the dimensions of the Raycaster. How can I do that? Here is the example . Almaz Vildanov try to change a code as follows: function onDocumentMouseDown( event ) { event.preventDefault(); var x = event.offsetX == undefined ? event.layerX : event.offsetX; var y = event.offsetY == undefined ? event.layerY : event

GPU ray casting (single pass) with 3d textures in spherical coordinates

好久不见. 提交于 2019-12-01 11:33:11
i' am implementing an algorithm of volume rendering "GPU ray casting single pass". For this, i used a float array of intensity values as 3d textures ( this 3d textures describes a regular 3d grid in spherical coordinates ). Here there are example of array values: 75.839354473071637, 64.083049468866022, 65.253933716444365, 79.992431196592577, 84.411485976957096, 0.0000000000000000, 82.020319431382831, 76.808403454586994, 79.974774618246158, 0.0000000000000000, 91.127273013466336, 84.009956557448433, 90.221356094672814, 87.567422484025627, 71.940263118478072, 0.0000000000000000, 0

RayCasting in Libgdx 3d

社会主义新天地 提交于 2019-11-29 15:20:13
Alright so I've been trying for quite some time too Raycast in libgdx for 3d collision detection based on where im looking.. But I've drawn a blank and doesn't seem to be any documentation anywhere. Would someone be kind enough to send me in the right direction? It is actually really easy with libgdx to achieve what you are trying to do. The following is what I'm using to do a ray test and find the closest collision object that my ray would hit. Let's assume it is located in a class called BulletUtil . private static final Vector3 rayFrom = new Vector3(); private static final Vector3 rayTo =

Why do I get bad performance with SDL2 and SDL_RenderCopy inside a double for loop over all pixels?

帅比萌擦擦* 提交于 2019-11-29 11:10:58
I am programming a raycasting game using SDL2. When drawing the floor, I need to call SDL_RenderCopy pixelwise. This leads to a bottleneck which drops the framerate below 10 fps. I am looking for performance boosts but can't seem to find some. Here's a rough overview of the performance drop: int main() { while(true) { for(x=0; x<800; x++) { for(y=0; y<600; y++) { SDL_Rect src = { 0, 0, 1, 1 }; SDL_Rect dst = { x, y, 1, 1 }; SDL_RenderCopy(ren, tx, &src, &dst); // this drops the framerate below 10 } } SDL_RenderPresent(ren); } } You should probably be using texture streaming for this. Basically

3D Screenspace Raycasting/Picking DirectX9

霸气de小男生 提交于 2019-11-28 14:27:50
I need to convert a 2D mouse coordinate to a 3D world coordinate based on a specific depth (it's for raycasting). I'm not directly using DirectX in C++, I'm using a proprietary language, but if you give me an answer in C++ or pseudocode (C++ preferred) I can convert it. I have access to the world matrix, view matrix and projection matrix and a variety of matrix manipulation functions. If it's necessary to multiply a vector4 by a matrix4, the only function I have available that takes both a vector4 and a matrix4 is transformVector4(vector4Source,matrix4Source) . I'm not sure which order it

three.js orthographic camera object picking

二次信任 提交于 2019-11-28 11:40:51
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 pos = camera.position; var ray = new THREE.Raycaster(pos, vector.unproject(camera).sub(camera.position

RayCasting in Libgdx 3d

牧云@^-^@ 提交于 2019-11-28 08:28:10
问题 Alright so I've been trying for quite some time too Raycast in libgdx for 3d collision detection based on where im looking.. But I've drawn a blank and doesn't seem to be any documentation anywhere. Would someone be kind enough to send me in the right direction? 回答1: It is actually really easy with libgdx to achieve what you are trying to do. The following is what I'm using to do a ray test and find the closest collision object that my ray would hit. Let's assume it is located in a class

JavaFX Moving 3D objects with mouse on a virtual plane

爱⌒轻易说出口 提交于 2019-11-28 07:03:41
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 without much success. I've not attached a code snippet as I'm looking for a more generic mathematical

volume rendering (using glsl) with ray casting algorithm

无人久伴 提交于 2019-11-28 04:34:38
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 rendering using ray casting (of course in glsl). here is the cg shader of the demo. and it can work on my