Raycast laser dot?
by Brian M · in Torque 3D Professional · 01/21/2014 (8:09 am) · 8 replies
Hi all,
Been looking through a bunch of old resources for something to do this, but keep coming up empty or with something that is too outdated and/or seems way to complicated...
Basically what I want to do is have a raycast from the player's eye place a little red dot where the raycast hits the first object.
This is for the Oculus Rift, where we can't really use mouse clicking for object selection because the mouse cursor does not render in stereo.
I already am piggybacking off the Awesomium integration kit, which does constant raycasting in front of the player's eye for any Awshape web-enabled objects, and I am able to detect and select objects that I am looking at, but since there is no crosshair in the Rift it can be difficult to zone in on a small clickable button for example.
If my raycast check could also fire an invisible beam, that would place a red dot where I am looking, that could act as an in-world targeting cursor. Then using the Rift I could just move my head around and zone in on the clickable buttons by positioning the red dot over them.
I don't really need any fancy crosshair functionality, it doesn't need to follow my weapon and I would prefer to not go the "image on image" routine and mount a light on the weapon... Seems to me there must be a simple way to just enhance the raycast so it draws a dot at the end of the beam.
Anyone know how to achieve this? As I said, I already have the co-ordinates for start of the raycast, and it is working in terms of selecting whatever I am looking directly at, I just want some sort of marker that confirms what I am about to click on, hence a tiny red dot or something similar.
Many thanks
Been looking through a bunch of old resources for something to do this, but keep coming up empty or with something that is too outdated and/or seems way to complicated...
Basically what I want to do is have a raycast from the player's eye place a little red dot where the raycast hits the first object.
This is for the Oculus Rift, where we can't really use mouse clicking for object selection because the mouse cursor does not render in stereo.
I already am piggybacking off the Awesomium integration kit, which does constant raycasting in front of the player's eye for any Awshape web-enabled objects, and I am able to detect and select objects that I am looking at, but since there is no crosshair in the Rift it can be difficult to zone in on a small clickable button for example.
If my raycast check could also fire an invisible beam, that would place a red dot where I am looking, that could act as an in-world targeting cursor. Then using the Rift I could just move my head around and zone in on the clickable buttons by positioning the red dot over them.
I don't really need any fancy crosshair functionality, it doesn't need to follow my weapon and I would prefer to not go the "image on image" routine and mount a light on the weapon... Seems to me there must be a simple way to just enhance the raycast so it draws a dot at the end of the beam.
Anyone know how to achieve this? As I said, I already have the co-ordinates for start of the raycast, and it is working in terms of selecting whatever I am looking directly at, I just want some sort of marker that confirms what I am about to click on, hence a tiny red dot or something similar.
Many thanks
#2
01/21/2014 (8:15 am)
It sounds like you want to either use a PostFX to paint the dot, or place a decal where the raycast ends.
#3
You could extract the position:
And then render a tiny red particle emitter at the location of the raycast.
01/21/2014 (8:29 am)
A raycast return is actually something like this:%ray = %object %posx %posy %posz %normx %normy %normz;
You could extract the position:
%position = getWords(%ray, 1, 2);
And then render a tiny red particle emitter at the location of the raycast.
#4
Trying to keep it really simple :)
It has to be something like that, so the stereo rendering will pick it up and display it in both Rift viewports. PostFX may not be the best solution for that, as it may conflict with the barrel distortion PostFX that the Rift does.
So... At the risk of sounding like a noob, is there a quick way to do the decal placing at the end of the raycast, using just a few commands? And how would I get it to move in real time, be constantly deleting it and recreating it as the user looks around?
Thanks for this
01/21/2014 (8:31 am)
Yes, something like placing a decal where the raycast ends would work. Trying to keep it really simple :)
It has to be something like that, so the stereo rendering will pick it up and display it in both Rift viewports. PostFX may not be the best solution for that, as it may conflict with the barrel distortion PostFX that the Rift does.
So... At the risk of sounding like a noob, is there a quick way to do the decal placing at the end of the raycast, using just a few commands? And how would I get it to move in real time, be constantly deleting it and recreating it as the user looks around?
Thanks for this
#5
I'd love to see a script if you don't mind i'm using the oculus as well and this could be handy :)
As for a laser sight you can try this I know you didn't want to use a light but I have used this and it worked well
http://www.garagegames.com/community/resources/view/20898
Just use the laser part of it and mount it to the eye node and it should be what you want and if you make sure shadow is enabled as said in the thread it will stop after it hits the first person.
Also you could just use a red image as the cookie on the light to make it a solid image dot on everything which will make visibility much better :)
(For a cool look at what a cookie could be check https://www.garagegames.com/community/forums/viewthread/102155/3)
01/21/2014 (3:30 pm)
Hi Brian I'd love to see a script if you don't mind i'm using the oculus as well and this could be handy :)
As for a laser sight you can try this I know you didn't want to use a light but I have used this and it worked well
http://www.garagegames.com/community/resources/view/20898
Just use the laser part of it and mount it to the eye node and it should be what you want and if you make sure shadow is enabled as said in the thread it will stop after it hits the first person.
Also you could just use a red image as the cookie on the light to make it a solid image dot on everything which will make visibility much better :)
(For a cool look at what a cookie could be check https://www.garagegames.com/community/forums/viewthread/102155/3)
#6
Thanks, we actually use that resource on our shuttles as a spotlight, never occurred to me to adapt it to this end...
So, it's sort of working, I get the dot ahead of me, and it moves side to side but not up and down with my aim. I'm wondering if it is not mounted properly to the eye - we want to make sure it's mounted to the eye camera so it tracks.
Going to keep at it :)
01/21/2014 (5:39 pm)
Hey NiN,Thanks, we actually use that resource on our shuttles as a spotlight, never occurred to me to adapt it to this end...
So, it's sort of working, I get the dot ahead of me, and it moves side to side but not up and down with my aim. I'm wondering if it is not mounted properly to the eye - we want to make sure it's mounted to the eye camera so it tracks.
Going to keep at it :)
#7
Yeah I like that resource for a flashlight in a horror game it works well :)
I'm not sure what you can do besides maybe mount it to a node next to the eye or anywhere on the head for now then see if the up and down translates for that if it does then maybe another node just below the eye specifically for the dot?
Also one other thing you could do with this is you could have an icon for the cookie then in script change the icon to something else for the dot that lets the user know that the button can be triggered then change back once you move away from a shape that can be triggered.
01/21/2014 (6:13 pm)
Hmm could it be because the eye node moves when looking around but the camera just rotates up and down for the up and down view?Yeah I like that resource for a flashlight in a horror game it works well :)
I'm not sure what you can do besides maybe mount it to a node next to the eye or anywhere on the head for now then see if the up and down translates for that if it does then maybe another node just below the eye specifically for the dot?
Also one other thing you could do with this is you could have an icon for the cookie then in script change the icon to something else for the dot that lets the user know that the button can be triggered then change back once you move away from a shape that can be triggered.
#8
Alternatively, I'm hoping Jeff Faust can come up with a fix for his AFX, so the object highlighting will work in the Rift.
In non-rift mode our AFX build does really nice glow highlighting of objects - we adjusted the engine to piggyback off the Awesomium raycast that shoots out from your view, to simulate moving the mouse over objects. So we have it working in the Rift that whatever you look at is where your mouse cursor is, and you right-click to select what is there - solves the clickable object issue, if only I could get some sort of working highlighting or laser pointer that can tell the player what is ready to be clicked on, since some of our buttons etc are pretty small.
Here are a few screen caps illustrating the current problem with AFX and the highlighting when using the Rift... If we can figure this out then the objects will highlight in both ports in the Rift, and we have a working solution for exploring a world and clicking on things :)
A selectable tower, higlighted in standard view:

A selectable tower, higlighted in rift view:

A selectable Cheetah, higlighted in standard view:

A selectable Cheetah, higlighted in rift view:

Rift view of the bridge with players beaming in using Astral Passport spell from AFX, and Sulu has been clicked on to select him (note the AFX zodiac/selectron at his feet in both viewports, but his glow highlight is wrong):

01/21/2014 (6:53 pm)
Yes that's a great idea about swapping out the image... Will look at that once we figure out the up and down motion.Alternatively, I'm hoping Jeff Faust can come up with a fix for his AFX, so the object highlighting will work in the Rift.
In non-rift mode our AFX build does really nice glow highlighting of objects - we adjusted the engine to piggyback off the Awesomium raycast that shoots out from your view, to simulate moving the mouse over objects. So we have it working in the Rift that whatever you look at is where your mouse cursor is, and you right-click to select what is there - solves the clickable object issue, if only I could get some sort of working highlighting or laser pointer that can tell the player what is ready to be clicked on, since some of our buttons etc are pretty small.
Here are a few screen caps illustrating the current problem with AFX and the highlighting when using the Rift... If we can figure this out then the objects will highlight in both ports in the Rift, and we have a working solution for exploring a world and clicking on things :)
A selectable tower, higlighted in standard view:

A selectable tower, higlighted in rift view:

A selectable Cheetah, higlighted in standard view:

A selectable Cheetah, higlighted in rift view:

Rift view of the bridge with players beaming in using Astral Passport spell from AFX, and Sulu has been clicked on to select him (note the AFX zodiac/selectron at his feet in both viewports, but his glow highlight is wrong):

Torque Owner Jeff Raab
[ghc]games
They have it where when you click in the mission, it moves a decal to that location. You'd do something similar, just updating the laser dot decal's position to the raycasted point you're already collecting.