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 / How would I go about dragging a plane on a terrain

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Jan 2013 22:39
So here's what I'm trying to do. I have a terrain, various heights yada yada. When I click and drag the mouse, I am trying to place what kind of looks like a zone from simcity 3, 4 and so forth. My question is, how do I map/position the plane/zone object so that it conforms to the surface of the terrain? I'm just looking for hypotheticals and methods here, I want to write the code myself.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jan 2013 23:53 Edited at: 5th Jan 2013 23:53
There are a number of ways to achieve it.

1) Subdivided plain which wraps over the terrain as you drag
2) Edit diffuse values of the terrain vertices (works well if your terrain has a consistently high poly count)
3) Use a decal shader to draw another texture the area you're dragging
4) Just use a simple plain but disable z-depth (flat terrains would work the best with this method)

You probably already know to use pick object to get the mouse coordinates on the terrain.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 6th Jan 2013 00:32 Edited at: 6th Jan 2013 00:40
Here's a more in-depth follow-up.

(Oh and yes, I use the pick commands with Sparky's for better terraforming of the terrain)

What I was thinking about doing is use objects to simulate the vertices of the zone plane. I would draw the poly's to these locations. So say I have a huge zone I'm drawing over a mountain top. If there are numerous locations that are the same height, then the poly over that area would match the size. Think of it like a line of objects at varying heights to the north, south, east and west edges of the zone plane. Then within this "box" of vertices, when a height is less than or greater than the draw area, another vertex object is placed. The result would be a plane object that is just slightly higher than the terrain (a hard-forced z bias would make this look nice) This plane would only be viewable while it's drawn and then would be hidden. It would be re-shown if the user wishes to just see the zones.

EDIT - the trouble with this method is, if the terrain is terraformed, the old zone would need to be updated. Terraformed areas in the zone would delete the vertex object locations and keep the remaining ones, deleting the old polys. The result would be a zone with a hole in it - which works.

I've looked into decals, but haven't found one that I adequetley understand. I haven't even figured out how to make different textures on the terrain appear without killing the frame rate. Shaders nearly kill it, and trying to memblock draw on a texture is nice, but I can't scale the textures prior to painting or post, using that method. So for now, I am working on what I can surely do.

What I need to know how to do though, is ideally draw the thing, store the locations of the vertex objects per zone and have it all in a function that allows me to color the zone plane and specify what kind of objects are spawned within it.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 7th Jan 2013 23:30
@TheComet: Is there an inbuilt decal function available in Dark Basic Pro ? How do do they draw the decals in FPSC ?

Login to post a reply

Server time is: 2026-07-07 09:05:17
Your offset time is: 2026-07-07 09:05:17