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 Studio Chat / [SOLVED] Determining color of terrain at an x.y.z position

Author
Message
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 13th Oct 2021 13:35
Hi guys I need to be able to tell the color of the terrain under my camera . Any assistance would be good. Thanks for reading

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

Go to answer

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 13th Oct 2021 15:25
It's not difficult to get a Colour Value from the Point on the Screen / Camera.
A quick search of the forums (you tried using DOT / POINT as Keywords in the search bar) and you'll fine a few topics on the matter...
No, the problem is Performance.

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 14th Oct 2021 01:34
Native Point() and Plot() would be nice!

For a game engine AGK's drawing functionality is utter rubbish

There is a few Point() functions laying around the forum but as Raven said they are expensive to run, GetImage and Memblocks to get a color ... its overkill and not something you want to do on a frame by frame basis, a "click to get color" type of setup would be fine but run a loop and say arrivederci to your FPS!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Oct 2021 02:57
how are you making the "terrain"?

is it generated from a heightmap? if so, do want the grayscale value of the image, or the texture's color?

your title specifies (all 3) x,y,z so, is it a 3d model generated elsewhere (ie, that you've applied a texture to and want the color at x/y/z of that texture?)?

need some more info on your "terrain" that might provide better advice.

Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 14th Oct 2021 08:36 Edited at: 14th Oct 2021 08:41
Yes I am using a height map with a texture and need to be able to check the color of the texture under the camera . The purpose of this is to have a motorcycle going over hills and I need the program to tell me if I 'm on the road.
Is there another way of doing what I need .
hosch
Developer
2
Years of Service
User Offline
Joined: 25th May 2021
Location:
Posted: 14th Oct 2021 10:59
This post has been marked by the post author as the answer.
There are endless ways, which makes programming as fun and sometimes complicated as it is.

- Use an array to simulate a tilemap, 1 means road, 2 means ice...
- Run the check against your heightmap itself and check for the RGB values that reflect a street
- Place invisible spheres alongside the road and check if the motorcycle is near it
and many more.

It depends on how you set things up. Your advantage is that you dont use random generation (i assume) and you know the complete layout of your map beforehand. Cache that information in a way that makes sense and access that information during the game.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 14th Oct 2021 12:53
heightmaps are all well and good but with lack of a 3d placement editor it becomes pretty cumbersome using them.

maybe load the texture up in blender and generate your world that way (use an image texture and plug it into a bump node with a color ramp) then you can mark a path, place some markers etc etc, else you need to build some kind of makeshift editor to place "something", a path, hit boxes, sphere barrier etc etc

In another language yes you would just interrogate the normal and get the texture value for that tri but AppGameKit does not expose this functionally, you could use a shader but not sure how one would get a value from a shader for position mapping ... thats beyone me!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Oct 2021 12:57 Edited at: 14th Oct 2021 13:01
i doubt the colors in your roads are unique to only roads?
if they are, great. use the texture itself in something like THIS?
if not, make a similar "color map" to define various surfaces such as asphalt, dirt, mud, and respond accordingly?
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 14th Oct 2021 13:00
Thanks for the tips I think I'm gonna try the invisible objects .
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 18th Oct 2021 07:03
I'm halfway through putting my spheres on my road and decided to get it up and running to test it out . Very good results . Haven't run into any speed issues yet but we'll see what happens when I'm done .
hosch
Developer
2
Years of Service
User Offline
Joined: 25th May 2021
Location:
Posted: 18th Oct 2021 10:48
Glad to hear. There are so many ways on solving problems in programming, it's amazing. If you get a performance hit of course, you need to rethink. Boxes and box collisions are cheaper performance wise. Plus a stretched box can cover more terrain than a sphere.
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 19th Oct 2021 18:40 Edited at: 20th Oct 2021 10:41
Got it up and running with the spheres but am going to check out the boxes too. Thanks for the advice.
Well I've tried the same method with boxes and the results are very good .
just checked the fps at many locations on the map and In the worst place I get 120fps and the highest 230fps so am very pleased with these results.
The test was with #renderer "Basic"

Login to post a reply

Server time is: 2024-04-25 01:16:28
Your offset time is: 2024-04-25 01:16:28