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 / Making Craters in Terrains any ideas

Author
Message
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Jul 2006 15:03
I was thinking if you could access the terrain data at a specific location apply some sort of negative height field to that location and then update the terrain

It probably sounds too hard to do with present dbpro commands but i was whondering what ideas people had for creating a crater after a missile has hit a specific location.

fubar
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jul 2006 15:07
Personally I'd just make the sides, like a circular crater that simply sits on top of the terrain. As long as your sensible you could position this and give the impression of a crater but all it would be doing is raising the sides.

So rather than digging a hole, your sticking a crater model on top that will make it look like a hole without needing to adjust the terrain.

Really though, I think the vertice access commands would be the only way to do it - like find out that terrain limb, lock the verts, adjust them to make a crater (it's real easy once you have those commands, just adjust the Y heights). I'm thinking that locking the limb vertices will let you do this stuff to advanced terrain, but I'm not sure - never tried it.

Aegrescit medendo
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Jul 2006 15:32 Edited at: 28th Jul 2006 15:32
I think that once you have created your AT terrain, you can manipulate it like any other object. For the sake of efficiency, it may be wise to map out the vertices prior to runtime, so you can quickly locate the right vertices for the explosion.



fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Jul 2006 15:39
The terrain is quite large and i didnt want to map out the verticies unless i had too

I have been reading up on the vertices commands as suggested by van B but im not sure how to get the terrain limb of an object at a specific location perhaps that might be a future upgrade or maybe my help file just dont include that command although i have applied the latest update as of 28th july 2006 for future thread reference

fubar
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jul 2006 15:53
Unfortunately the limbs are a bit weird with AT, I think you'd really have to stop using that UPDATE TERRAIN command, and show and hide each limb in turn, so you can map out what limbs are where.

I'd make an array to hold the vertice numbers, like a grid system whereby the X and Z component represeent 1 square area on the terrain, a tile if you like. Anyhoo, by simply getting the vertice location, and dividing it by the tile size, you would know the grid location and store that vertice number and limb number there.

Then using this precalculated reference, you could adjust the verts based on your grid - like the crater start point, get the grid location and closest vert, then just work outwards from that because you'll easily know the neighboring vertices each time.

With that reference array, your job will be so much easier - much easier to do this all in realtime once you can work out quickly which vert is closest. Coupled with physics, you could have craters form naturally. Like throw a giant physics enabled boulder at the terrain, and if theres a collision at a certain force, then the terrain could craterise. I think it would be mad to have this planet with low gravity being bombarded with lumbs of rock - just running for it and staying alive would make for an entertaining game I think.

Aegrescit medendo
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Jul 2006 16:02
that sounds great but forgive me if im SILLY but i dont know how to get the vertices data to store in the first place, a code snippet would be greatly appreciated

fubar
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jul 2006 16:05
Will see what I can do, I promised someone a planet terrain example, perhaps I can make an example for you based on that too.

No promises as to when this will be done, but I expect I'll have time over the weekend.

Aegrescit medendo
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Jul 2006 16:23
Can't you just loop through the vertices, and if they're near enough to a point, then set the Y height to the (crater depth)+sqrt(dist)

There are three types of people, those that can count and those that can't.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Jul 2006 16:38
Quote: "Can't you just loop through the vertices, and if they're near enough to a point, then set the Y height to the (crater depth)+sqrt(dist)"


Yes, but it's probably too slow for a huge terrain.

This tutorial on Vertex Manipulation may help you...

http://www.thegamecreators.com/data/newsletter/newsletter_issue_41.html#8



fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jul 2006 02:14
for interest sakes my terrain is 512*512 but is scaled by 2,?,2

fubar
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 29th Jul 2006 07:06
If you are using a regular matrix I can show you a way to do it.
If you are using Advanced Terrain, then I have never tried AT.

Can you give me a piece of code that has your object hit the matrix in a spot, I will see if my code will crater the terrain and post it back to you.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Jul 2006 05:09
nope im using a terrain its easier to load height fields that way

fubar
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 04:43
A note to Van B

Did you have any luck yet on your terrain example, i know you said no promises im just curious.

Thanks for your time

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 7th Aug 2006 04:58
Hey fubarpk do you have to use AT, if you check my post on a terrain without that is in some ways better than AT. Then you can just have two heightmaps, one with a non-crater, and one with the crater, then when you want to apply the crater, just apply that heightmap to the terrain and blamo you have a crater in like 3-4 commands, if you use the include file I put with it. Also you can apply this in real time if you like, so you can actually see your crater sinking down. Just an idea, btw I am working on an updated and faster version but I need feedback on my post to see if my new version is working on more than just my computer. I think my terrain is easier to use then AT and more flexable, and you can set it up in chunks/limbs if you want to, just use more than one piece.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 05:05
That sounds like a great way of getting the effect to work but the problem I am foreseeing with that when a missile isnt quite lined up with crater hole the hole will end up in different place.

Thats why i originally thought a crater object, ie terrain behind placed at that location and some how only modify that part of the terrain.

fubar
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 05:06
But forethat we would have to acces either the matrix or terrain data directly which i dont know how to do

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 7th Aug 2006 05:12
Ok all you would have to do is load the "normal heightmap" into a memblock and when the missle hit the terrain, just add a dark spot (a circle or whatever) to the memblock image, and then apply that to the terrain and your terrain will now be updated with the missle hole in the correct spot.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 05:16
that is exactly what i want do you have any code ideas that can help me do that

fubar
bosskeith
20
Years of Service
User Offline
Joined: 5th Dec 2005
Location:
Posted: 7th Aug 2006 05:19 Edited at: 7th Aug 2006 05:21
why not have an alpha crater that you apply to the height map and get that image and apply ...that way the more hits it recieves the more times you paste the crater image and position it in scale to the x and z of the terrain...depending on how you create your alpha would determine the way the craters react. if the entire crater alpha image was solid in middle and transparent on outside then all holes would be same depth...if transparent all around with a nice gradient then the hole would adjust the depth according to the previous height.
[edit]
of course you would do these steps in another bitmap
[/edit]

Ink all over the screen...and dang it! Signature still does not show.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 05:38
is there a tutorial somewhere that would help me achieve the alpha blending you are suggesting bosskeith

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 7th Aug 2006 05:54
here is an idea, why not make a blank bitmap, the same size as your heightmap, say 512x512, then you have a blank map + heightmap, now all you do is write your crater data into the blank map then when your satisfied that your crater is correct, then combine the new crater map with your heightmap, then apply that heightmap to the terrain.
bosskeith
20
Years of Service
User Offline
Joined: 5th Dec 2005
Location:
Posted: 7th Aug 2006 05:54 Edited at: 7th Aug 2006 06:00
no but most graphics programs have the [.PNG] file format that retains it's alpha when loaded

[edit]
said originaly tga meant .PNG
[/edit]

Ink all over the screen...and dang it! Signature still does not show.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 06:13
is there a command that i dont have in the help for A.T because i only know how to load a terrain with a height map i dont know how to apply a bitmap to the terrain i know the following command for A.T

MAKE TERRAIN : MAKE TERRAIN Terrain Number, Heightmap Filename
DELETE TERRAIN : DELETE TERRAIN Terrain Number
POSITION TERRAIN : POSITION TERRAIN Terrain Number, X, Y, Z
TEXTURE TERRAIN : TEXTURE TERRAIN Terrain Number, Image Number

TERRAIN EXIST : Return Integer=TERRAIN EXIST(Terrain Number)
TERRAIN POSITION X : Return Float=TERRAIN POSITION X(Terrain Number)
TERRAIN POSITION Y : Return Float=TERRAIN POSITION Y(Terrain Number)
TERRAIN POSITION Z : Return Float=TERRAIN POSITION Z(Terrain Number)
GET TERRAIN HEIGHT : Return Float=GET TERRAIN HEIGHT(Terrain Number, X, Z)
GET TOTAL TERRAIN HEIGHT : Return Float=GET TOTAL TERRAIN HEIGHT(Terrain Number)

are there others that i dont know

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 7th Aug 2006 06:33 Edited at: 7th Aug 2006 06:33
Listen what I am talking about does not use AT, I repeat, It is NOT Advanced Terrain. Rather it is an object, that you can update in real time, it is visually as good/if not better than AT. This terrain is easy to use and only requires a detailmap and a heightmap. You can apply a colormap if you wish, or you can just let it color it for you. check my post here

http://forum.thegamecreators.com/?m=forum_view&t=72766&b=1

check the last page and run the lastest version its just an exe and if you think it is for you then I will help you set up your deforming terrain ok.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 06:40
i downloaded early versions of your source but the latest would keep resetting the server i am downloading the exe now, how much do you sell the commands for and will they work with dark gdk

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 7th Aug 2006 06:46
the commands are just dbp commands and the mesh is just a dbo that I made, so its all free. I`ve never use gdk but I am sure that it will work with it.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 10:23
okay i finally managed to download your commands if i want to blend two images together to create the crater effect on the terrain i dont think i can use your your blend_images function because if the crater starts at white in centre and goes to black on edge then it creates a hill and i want the negative of this any ideas

fubar
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 7th Aug 2006 12:34
In case a .x mesh with texture of a crater will help, I thought I'd give you the heads up, I just posed one in this thread...

http://forum.thegamecreators.com/?m=forum_view&t=85258&b=3

Cheers!
aG Annihilator
21
Years of Service
User Offline
Joined: 20th Jun 2004
Location: UK
Posted: 7th Aug 2006 13:47
hehe your crater image is the wrong way round, that might be why the belend_images command made a hill. in most heightmaps,black is the lowest height and white is the highest.

try reversing the gradient in photoshop

------------------------
Annihilator of Annihilated Games
http://ag.liquidannihilation.com
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 15:51
actually annihilator it is supposed to be done that way because if you dont the black area around the circle aint transparent and will effect it worse thats why i thought it would be better to blend a possitive image in a way that uses a subtractive method by changing the blend function to subtract the image is great but not what i want because it doesnt take into account the already present values

fubar
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Aug 2006 16:00
Thats not a bad idea Davis seeing as db allows the attaching of objects great thinking it would also support objects on an angle of a hill. if only it was possible to remove the centre of the crater in the joined object or AT whatever was easiest.

So far we have two great methods above one is glueing the object and the other is modifying the image with a positive image. These work well for a later advancement to the program i may use but not for digging a hole but this is great that people are thinking.

fubar
bosskeith
20
Years of Service
User Offline
Joined: 5th Dec 2005
Location:
Posted: 8th Aug 2006 00:25 Edited at: 8th Aug 2006 01:59
i just thought of a way ...should have thought of this when he said his new terrain was going to be an object and not advanced terrain ...you can carve your terrain with a sphere...One of those ambiguous hidden commands lol...
PERFORM CSG DIFFERENCE TargetObject, BrushObject

obviously target object being your terrain and brush object being your sphere

someone posted this which might be of interest
http://forum.thegamecreators.com/?m=forum_view&t=29734&b=15
if you check out the 5.8 upgrade it has all the csg commands in their


nvm too slow for what you want

Ink all over the screen...and dang it! Signature still does not show.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Aug 2006 06:40
thats exactly what is needed bosskeith thanks for your support

fubar
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Aug 2006 07:47
trying to place a mesh object at a location of the object and removing the area where they collide. I am using an object which is a half sphere object.

I dont know if im on the right track

load object code


createcode function i am trying to write but i dont know if im on the wrong track and what the parameters mean for VertexIndex,VertexStart,VertexEnd,IndexStart,IndexEnd

Another thing i was planning on passing limb 0 so i can get access to the objects root data.

fubar
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Aug 2006 02:38
Ideally what i really want is to dent an object

basically a function something like

void dbDentObjectY(id,objposition,objradius){
........
........
........
}
there could also be
dbDentObjectX and dbDentObjectY functions also

fubar
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 24th Aug 2006 03:24
Here is how you would create a function like this.

You have to use the vertex data commands.

you have 2 objects

object 1
and object 2


you check object 1 vertexdata point positions.

then you check object 2 vertexdata point positions.

then you determine which object you want to "subtract/move" the vertex data from. Say object 1 overlaps object 2 and you want object 2 to be changed to the shape where object 1 "shares the same space". You would then determine the max point at which object 1 is overlaping object 2. And then you have a couple of options.

1. you can just move the vertex data points where its being overlapped. Then remove the overlaping object. (the problem here is when object that is being overlapped has substantialy less polys than object being subtracted. ex. sphere overlapping a cube.)

2. you can merge the two objects together. Determine the max edge of the overlapped object and then add datapoints to destination object and delete all datapoints from overlapped object that is being overlapped. This is more complex but would give the best results. ( this method would make more polygons, but say you had a sphere and a cube, and they overlapped, then you would basicaly combine the objects together where they overlapped, basically making a new object.) I use a method similar to this on grass patches for my game.

3. ????? I dont know anyother way. except using memblocks and thats to complex for me.

good luck.
fubarpk
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st Aug 2006 14:35
This function does create a crater from an existing object the pivot point has to be set at top of the crater if i remember been a while since i used this code.




fubar

Login to post a reply

Server time is: 2026-06-11 11:21:57
Your offset time is: 2026-06-11 11:21:57