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.

DarkBASIC Professional Discussion / Terrain RGB paiting using projection , how to?

Author
Message
haliop
User Banned
Posted: 2nd Jun 2010 09:51
hi, i am trying to paint RGB colors on a terrain im using Van B method for Projection and MemBlock image , the terrain is simple just a terrain from the Box HeightMap.

i have found that painting on a terrain is not like painting on a plane and i think its becouse of the limbs created by a terrain since its not a one part like a plane , so how should i approach it? if anyone can help , pls it will be awesome. ty.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Jun 2010 10:34 Edited at: 2nd Jun 2010 10:40
The first thing you have to realize is that a terrain isn't flat. So when you used the pick screen command, use raycasting to find the intersection point between the camera to pick screen vector with the terrain. Sparky's DLL should come in very handy for this. It returns which object was hit by the mouse, and also where the object was hit (x#, y#, z#) (as well as the normal but I don't think you'll be needing that).

If you got which object was hit, it's time to find which pixel is underneath that position. Usually, the plain has a size of (sx#, sz#), and an image of (Width,Height) is stretched uniformly over that plain. In that case, you can find the pixel position using:



Where TerrainX/Y are the coordinates of the corner of your image. You might have to alter some things in order for it to work with your type of terrains.
Then you can use these coordinates to change the image data on the plain.

There are more methods that allow you to draw on terrains where the image is not uniformly stretched over the image, and when the terrain is also rotated arbitrarely. Unfortunately these things tend get a bit harder, as more math sneaks in.

Cheers!
Sven B

haliop
User Banned
Posted: 2nd Jun 2010 11:20
i have only one object.. the terrain.
i just want to clear something about the code snippet.
pixelX , Y = U,V
Width / Height = image size?
sx,sz ?
x,z?
terrainX,Z ?

so instead of using dbPickObject i need to use Sparkys?

wait after reading it again , the code snipper wont work on terrain?
i dont mind more math i just dont know how to understand it..
if i will then no problem i will find a way , but unfortunatly for me im not so good with math.
haliop
User Banned
Posted: 2nd Jun 2010 11:29
how about if i put a plain with the same size as the terrain beneth the terrain itself?
that could possible be right no? and also much less time to calculate the actuall painting
i'll try it now , since its just RGB i dont see anyproblem using a fake plain..
haliop
User Banned
Posted: 2nd Jun 2010 11:56
ok now after testing with the fake plain i understand how heights are miss calculated.

so whats the fix for it?, altough if i stay Fixed parralel to the Z axis no problem there , however there is a possiblity to rotate the Fake Plain towards the Camera oriantation or something alike but i think thats not a good solution.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jun 2010 12:50
Pick Object, has to be .

Just check what object is under the mouse when you click, if it's your terrain object then store the pick vectors and apply the paint.
I'm sure I made a simple example of painting an advanced terrain like this - will check tonight and post it here if I can find it.


Health, Ammo, and bacon and eggs!
haliop
User Banned
Posted: 2nd Jun 2010 15:45
ok tnx , for now im using this code


with a fake plain beneth the terain and i can paint only from above fixed to Z axes.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jun 2010 18:04
I think this might be the example your already using, but uploading here just in case.

That just checks object 1 with PICK OBJECT, and handles advanced terrains with multiple limbs fine. If you are using lots of seperate objects then you would need to specify the object range, then find out the image it's textured with. I suggest having a band of objects and images, so terrain 100 uses image 100, or at least an image you can work out from just the object number. Depends on how the terrain is handled.


Health, Ammo, and bacon and eggs!
haliop
User Banned
Posted: 2nd Jun 2010 19:36
yeah i understand however using the code i am using right now there is a problem with hieght +Y .

currently im aiming for a demonstration of an algo which fill the terrain with "Stamps" so im using just the normal terrain object from DarkGDK system nothing too expensive.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 3rd Jun 2010 21:49
Hope this helps,it does use sparky`s and matrix1 dll`s but thats the easiest and quickest way i could get this to work for you.

If you need any help then just ask.
haliop
User Banned
Posted: 5th Jun 2010 02:07
wow. im speechless.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 10th Jun 2010 21:13 Edited at: 10th Jun 2010 21:19
Forgot i had this different version,shows how to add a detail map with set blend mapping on and it smoothes the normals of all the terrain objects so it gets rid of the faceted look.This is the version i use in the spline based race track editor from the wip forums,not even sure if i updated that post with this newer code yet.Hope it helps.

link to the track editor WIP if you missed it
http://forum.thegamecreators.com/?m=forum_view&t=158864&b=8

Login to post a reply

Server time is: 2026-07-25 16:20:17
Your offset time is: 2026-07-25 16:20:17