I'm coding a simple FPS, but have started adding more complicated features. I'm pretty confused on this current situation, and was wondering if you could lend me a hand with a theory of how to fix my issue-
I'm trying to create it so that when a bullet impacts a certain material (like cement or metal) the decal effect and particles thrown are different between the different materials. (So when i shoot a metal post it sparks or when i shoot wood splinters fly)
I've already coded my own decal system, and it can apply the decals and such correctly, but i can't figure out how to make it different between the materials.
I've tried manually applying materials to everything in the scene, but this takes way too much work and is innefficient. For example i design my map in 3ds then i tried making every different materialed object separately and placed it manually in the scene with a manually applied material (with my own material system).
I'm just asking for some opinions on how i could do this differently.
Material system example
I made a struct to cover materials and in this struct it has
"MaterialType;" as a variable. I then apply the material to the object and make the MaterialType= "cement" or "wood", etc. This kind of works, but if the level gets big the performance hit is bad since every hit the system checks for MaterialType and then applies a different particle effect/decal for each impact.
Also the material system covers sounds, lighting, etc so you understand my issue...
I'm not asking for code or anything just helpful suggestions.
Thanks in advance.
Material Question (applies to decals/particle effects)
-
- Posts: 28
- Joined: Sun Sep 17, 2006 3:59 pm
- Location: iraq
I think the most sensible way to go about doing this would be to copy the oct-tree triangle selector and make it select triangles made of vertices rather than just floats, then you can get the texture coordinates of the 3 verts and interpolate to get the position on your texture.
once you have the position, you can either make your models so that all the wood texture is within one square, metal in another etc. or have a mask image which says how each part of the texture sounds and compare it to that.
for example, you could use each of the 32-bits of your mask texture to be a different sound effect and decal style. or you could just have 4 sounds as red/green/blue/alpha layers and loudness being brightness
once you have the position, you can either make your models so that all the wood texture is within one square, metal in another etc. or have a mask image which says how each part of the texture sounds and compare it to that.
for example, you could use each of the 32-bits of your mask texture to be a different sound effect and decal style. or you could just have 4 sounds as red/green/blue/alpha layers and loudness being brightness
-
- Posts: 28
- Joined: Sun Sep 17, 2006 3:59 pm
- Location: iraq