Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] How do I draw a line in 3D

Author
Message
Softwizz
15
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 21st Jan 2020 16:13
Hello.
So in 2d if I want to draw a line between 2 sprites A & B I would do:


How do I draw a line connecting 2 objects in 3D space?
One of the reasons I want to do this is to debug raycasts as there is no built in function to show a raycast

Thanks.

The author of this post has marked a post as an answer.

Go to answer

chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Jan 2020 16:50
This post has been marked by the post author as the answer.
GetscreenXFrom3D GetscreenYfrom3D I think
I'm not a grumpy grandpa
Softwizz
15
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 21st Jan 2020 17:32 Edited at: 21st Jan 2020 17:39
Thanks chafari that is exactly it. I took the example of GetscreenXFrom3D from the help section here:
https://www.appgamekit.com/documentation/Reference/3D/GetScreenXFrom3D.htm

And modified it to test the theory, just what I needed.



Thanks again.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 22nd Jan 2020 17:53
I saw a nifty simple 3D vector line shader someone created a while back... can't find the post now though
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 22nd Jan 2020 20:28 Edited at: 22nd Jan 2020 20:30
Here is how I would do it in 3D, with the end positions, thickness and color being controlled from basic AppGameKit code:

https://forum.thegamecreators.com/thread/223376#msg2634199
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jan 2020 16:41 Edited at: 24th Jan 2020 16:49
@GaborD

Using your shader, how would I set the color of the line?

Edit, and alpha?

I got a few ideas for this, need to set color info though and I know nothing about shaders
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 24th Jan 2020 16:47 Edited at: 24th Jan 2020 18:12
You can set it with
SetShaderConstantByName(shaderID, "col", r, g, b, 0)

The rgb values shouldbe in the 0 to 1 range. (or accordingly higher if you use HDR)


Edit:

If you want it to be transparent you have to slightly change the pixel shader and then use the last entry in the setShaderConstantByName for alpha (0 to 1):


Plus you have to set the object as transparent object in your AppGameKit code so that the engine knows it has to render it in the alpha pass.
SetObjectTransparency( objID, 1 )
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 30th Jan 2020 08:43
Thanks GaborD! That was the post I was thinking of - the one I couldn't find. Very useful shader for beginners like me!

Login to post a reply

Server time is: 2024-11-22 11:52:04
Your offset time is: 2024-11-22 11:52:04