deforming meshes (destroy building)
Blitz3D Forums/Blitz3D Beginners Area/deforming meshes (destroy building)
| ||
I want to do something Rampage-ish where you have a giant robot or something, and as he walks over buildings (rectangles w/texture) the rectangles smash/break apart still textured. Is there a way to randomly break/smash up a mesh, then delete the extra parts when you want? I know it's kind of a dumb question. Sorry. |
| ||
Probably 1000 ways to do it. One suggestion, create several building piece entities and put them together into a whole building, then just move the pieces around as the building gets destroyed. |
| ||
every game ive seen makes the buildings simply move below the terrain (with smoke effect to hide the transition) and leave behind pre-made rubble |
| ||
both good simple ways, tanks. |
| ||
Another way is to write a routine which: 1. Using TYPES and a little math, create a mesh made up of about 20 surfaces comprising of one poly each (which we'll call chunks), which is the same size as the building in total. 2. Calculate UV coordiantes for the textures on the triangles so that when they're "assembled" they match the building. 3. Remove the building mesh and put this one in its place. 4. In with the chunk TYPE, have current information on its velocity and rotation. (so far, this would take about 0.01 seconds CPU time, so don't worry about overhead) 5. Add an instance to the mainloop to check all "chunk" TYPEs which are above ground level. 6. For each chunk, calculate it's rotation and downward velocity (increasing each iteration to account for gravity) and set it in its new vertex positions. 7. When any chunk goes below ground level, just free the surface, then delete that chunk TYPE. (about another 0.001 seconds per interation - your CPU can handle hundres of these calculations easily.) :) This way, you can handle multiple buildings being crushed simulatenously, etc, and it looks very visually impressive. However, this isn't a "simple" way. It'd take a whole evening to write that routine. +BlackD [edit] This is actually pretty much what Toad suggested, but explaining what doing that involves. :) Yes - you can create meshes as types.. eg, new\chunk = createmesh(). I did this recently in a program like this: Type Map Field mesh End Type Type tex Field surface End Type tex1=LoadBrush("ter1.png") world.map = New map world\mesh = CreateMesh() For i = -3 To 0 For m = -3 To 0 chunk.tex = New tex chunk\surface = CreateSurface(world\mesh) AddVertex chunk\surface,i,m,0,0,1 AddVertex chunk\surface,i+1,m,0,1,1 AddVertex chunk\surface,i+1,m+1,0,1,0 AddVertex chunk\surface,i,m+1,0,0,0 AddTriangle chunk\surface,3,2,1 AddTriangle chunk\surface,0,3,1 PaintSurface chunk\surface,tex1 Next NextBut of course the maths for the polygons and UV coordinates in your case would be more complicated than that. :) That was part of the WAR3 Terrain Demo (http://www.geocities.com/kinneargames/war3.zip) - 256 meshes, 4096 surfaces, 8192 polygons, 16384 vertices ;).. all defined in TYPEs. [/edit] |
| ||
thanks!! |