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 Discussion / Destructible environments

Author
Message
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Dec 2008 02:19
Really I just want to know if it is POSSIBLE in DBC. I had an idea for a game, but it would be nice to have some destructible environments in it (blowing holes in walls and such). So far, I haven't even been able to figure out how it is done normally, so I haven't been able to work out a concept for the coding of it.

Has anyone looked into it or experimented with it before?

Thanks in advance.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Dec 2008 09:56
Here's a couple of concepts:

Changing Textures : Have a series of textures for an object at different levels of destruction/damage. Swap the textures as damage increases.

Transparent textures: Have an object like a plain textured with something like a bullet hole. Make the texture transparent except for the bullet hole/cracks. When there is an impact, position the plain at the point of impact. Have multiple plains with different types of damage and place them as damage occurs. Fade them out over time and reuse them.

Multiple objects used to build 1 object: Use a bunch of individual pieces to create a single object. As the object gets blasted, remove pieces or send some flying in different directions.

Change a matrix: As damage occurs, lower the points on the matrix at the position of impact. Also change the matrix tile to display a texture of damage.

Vertex manipulation: Requires memblocks but change the position of the vertices of a mesh as damage occurs.

Enjoy your day.
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Dec 2008 10:56
Quote: "Vertex manipulation: Requires memblocks but change the position of the vertices of a mesh as damage occurs."


Seems more like what I am looking for, but what about object splitting at vertex addition. For instance, if you blow a column in half, you would need to unlink verteces and re-attach them to get the broken look while keeping it looking solid, while if you blow a hole in a wall, you would need to create verteces to form the hole (though a transparent texture could work here, it would lack the solid look).

I have never been really good with memblocks, so maybe this would be easy if I understood how it stores the data. Good ideas though, I will try them out.

Thanks Latch!

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Dec 2008 03:47
Quote: "I have never been really good with memblocks, so maybe this would be easy if I understood how it stores the data. Good ideas though, I will try them out."

A memblock is just like it sounds, a big block of memory. You read and write bits, bytes, words or dwords sort of like you do with files. Finding the place you want in your memblock and how large a chunk of it you need is the hard part. Take a look at some of the MAKE MEMBLOCK FROM ... commands and you'll see how it works. The header of a memblock is like the contents of a book, it tells you where chunks of memory begin and end.

Quote: "Seems more like what I am looking for, but what about object splitting at vertex addition. For instance, if you blow a column in half, you would need to unlink verteces and re-attach them to get the broken look while keeping it looking solid, while if you blow a hole in a wall, you would need to create verteces to form the hole (though a transparent texture could work here, it would lack the solid look)."

I think you could do that, I Seem to recall that making an object uses all the data in a memblock so you'd probably have to find the break and copy one half to a new memblock to get separate objects. but latch knows much more about this than me, ive really only experimented with it.


Goke of the day: I coded an AI replica of Steve Irwin. It crashed because of a string array.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Dec 2008 04:50
Quote: "...re-attach them to get the broken look while keeping it looking solid, while if you blow a hole in a wall, you would need to create verteces to form the hole "


Sounds a bit like you want to use CSG (Constructive Solid Geometry). Basically using two or more objects and combining them or using them to "carve" into each other to form another object. In DBC, you'd probably have to pull that off with a DLL. But for things like Glass, or crates, or wooden tables and such, building the object out of other pieces would probably be a less expensive (computationally) way to go.

For memblocks, you could use simple vertex manipulation that might not be too expensive. There is a 32 byte header and the second DWORD is the location of the start of the vertex data. If a pillar was hit, you might alter the x and z positions of some of the vertices randomly. Punching a hole or breaking the solid mesh and sealing the severed vertices would be pretty tricky. You'd have to go into the face data, find the vertices that each face is made up of, then alter the face data. If a split in the object exposes more surface area, you might even have to add additional vertices and faces - then you'd have to recalculate the UVs and the normals. While it's possible to do all these things, it would take some doing and you'd have to be sure you are affecting the correct faces and vertices from the point of contact...

Here's a basic example of changing the vertices at random as if a pillar was being struck from different angles. This example only changes the x and z vertex positions on a stacked set of cylinders:



Enjoy your day.
Flyin Mushroom
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location: Arkansas
Posted: 27th Dec 2008 05:07
Yes, I seen a good concept off of destructible buildings off the video game "Mercenaries." I've done a 5 story and 15 story building where when it collapses, the smoke is so thick at the ground level and I usually just position the buildings y position and lower it below the matrix terrain with a few additional features on the top floors.

I've also did a effect where when my ground-to-ground or air-to-ground missiles impacts the matrix terrain, it lowers it and textures the impacted area with dirt textures which i need to fix because the dirt doesnt look good. I havent messed with it in almost a year and a have and havent looked for a short clip of the code i did to put on here.

Login to post a reply

Server time is: 2025-06-07 20:07:09
Your offset time is: 2025-06-07 20:07:09