Latest screenshot:
First off, the purpose of this thread is to bounce ideas off a wall, and hopefully figure some things out. I currently have decent knowledge of C++ and am teaching myself Direct3D.
This program is meant to simulate collisions between two objects, deforming both based on the physics involved in the collision. This is done through several independant code modules, each of which have the ability to be reused in similar programs,
possibly extending the simulation ability to include non-moving objects through the application of outside forces. Lol, that's not gonna happen.
So, here are the primary modules:
1. The Collision Detection Module
will consist of fairly standard collision detection algorithms. These will also determine whether or not the objects are moving towards one another at a speed exceeding minimum deformation velocity (preset; possibly modified based on material data). If Materials are on collision course and above minimum speed, proceed to module 2.
2. The Collision Path Generation Module
will consist of two main parts. The first will use the minimum/maximum x/y/z values to find the center of both objects. This point will then be taken to part 2. In part 2, this point will be turned into a line by application of velocities of both objects (to create lines relative to each object). Forces acting on objects will be assumed the same [may change at later date].
3. The Node Generation Module
will be responsible for creating the grid of nodes used in the collisions. In this step, points will be seeded within both objects, with the desity of nodes increasing as the distance from the expected line of impact decreases. This will allow for more accurate collision in areas which matter while reducing CPU draw; see Finite Element Method wiki page. Uses "slice method" for calculating whether nodes are within object boundaries. The generation of the nodes themselves will consist of generating multiple grids of nodes with distances between nodes being double the next higher density. These grids will then be put into expanding spheres [although due to there being more than one point from which distance is measured, the end result will be more cylindrical than spherical in an ideal case] outwards from the center point, with the innermost grid being the radius distances given for the object, in order to have the minimum distance grid cover the entire (or almost entire) area of direct impact. The difference in radii distances will be equal to 4 times the length of the bonds in the areas bounded by them.
4. The Bond Generation Module
involves connecting neighboring nodes with elastic bonds in preparation for collision. This involves creating a list of bonds which will be put into a vector; each bond will also have two pointers to it stored in the nodes which contain it. Each node will have up to 6 pointers to bonds. Bond length and strength will vary based on distance between connected nodes. The bond characteristics will also be able to be altered based on direction in which the bonds face at generation. This will allow for splintering/peeling in strips, giving the simulation a much better ability to simulate more complex materials such as wood or stone. The most likely method for accomplishing this module will be to start with a single node at a collision point from module 2 and work outward from there. This method would involve combining node and bond modules into one while leaving slice method code separate [for portability] and yet as a neccessary header file. [note: if this method used, will need to ensure code is in place to prevent node overlap and other similar issues]
5. The Physics Based Collision Module
will be responsible for the heavy calculating which needs to be done as the collision takes place. Looping force/velocity/position code will be here as well as code for bond deformation and bond failure. Forces calculated will include: external forces, bond forces, repulsive forces. External forces will be an input into this module; likely will have little effect on simulation unless very large. Bond forces will be calculated based on bond length. Repulsive forces will be calculated based on node distances. Bond deformation will enable bonds to stretch/contract in length. Bond failure will sever bond when it becomes overly stretched or when force from bond exceeds a large force determined based on material information.
6. The Cleanup Module
will be responsible for re-assembling the output from the collision module into something capable of being rendered and appearing reasonable. For now, only focusing on non-textured meshes. Will involve turning severed debris into new objects or particle effects. Will involve removing most interior nodes, editing/adding/deleting triangles of object. Will refit triangles to include external nodes[slice method should be useful here as well for determining whether a node is an external or internal node]. [note: this module still needs a large amount of conceptual work before module coding can begin, ideas still relatively sketchy]
7. Slice Method Module
consists of the basic functions required to use the slice method to find whether a point is in, out of, or on the edge of, a 3d object. "Slice Method" [there is probably a more technical name for it; look up later] involves cutting a 2 dimensional slice from 3d object followed by checking another axis. If the other axis collides with an even number of lines, the point is outside the object; if odd number, inside. This holds true in nearly all cases of closed objects, the case of edge lines being the exception; may need to add 'if' statements in slice stage to ensure proper behavior. Will use Y axis for slicing, followed by an x axis line. Due to complex exception handling required, slice method code is rather bulky.
The most interesting thing about this is how it could be used to simulate such a large number of materials. By altering parameters for the bonds, one could create a material which acts like rock (easy to break, but won't really bend), material which acts like metal (easy to bend, hard to break), or even wood by altering the x and y bond strength and adding in a bit of random factor while leaving z strong resulting in splintering.
Edit: this post has been VERY heavily edited to reflect changes made during design and implementation process. I am currently changing based on my typed up design docs which serve as both general docs reminding me of what to do as well as notes.
This section I will be updating occassionally to reflect generally how the parts of the project are doing
1. Planning: 100%
Coding: 100%
2. Planning: 100%
Coding: 100%
3. Planning: 100%
Coding: 100%
4. Planning: 100%
Coding: 100%
5. Planning: 100%
Coding: 100%
6. Planning: 90%
Coding: 50%
7. Planning 100%
Coding 100%
Front end(D3D, DirectX 9) Planning: 100%
Front end Coding: 90%
Note: these figures were extracted from excretory system, may not accurately represent actual progress