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 / Advanced problem: Animated UV coord from world coordinate

Author
Message
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 5th Jun 2012 16:03
Fairly advanced problem this. I am going to attempt a decal blood/injury system in Carnage, using a gore layer. Essentially, when the player is shot, at the exact point of impact, I am going to add gore damage.

I originally was going to just have preset locations and graphics. So for example, I'd have the forearm health, and then a damaged version in the same texture. I'd then simply scroll the UV data of the forearm when it got injured to the damaged portion of the texture. But I've decided I want to go further.

So I am going to have another texture layer for the blood/gore which starts off blank and uses the same UV coords as the base texture. When a bullet hits the player, I calculate where on the texture the bullet hits and modify it with some gore decals. I can also then do animating blood running down the players skin, like Undergrowth.

The challenge is identifying where on the model the bullet hit. Once I detect a collision, I can cast a ray and get the world XYZ of the collision. Then I will need to:
1. Cycle though every poly in the model and identify which polygon the XYZ is in, or the ray intersects.
2. Use the vertices to calculate a UV coordinate
3. Easy from then on ...

The real challenge is translating a ray intersection to a set of 3 vertices which describe the poly. Somehow I would have to extract all the poly data from the chracter, taking into account its orientation and animation frame, resulting in a load of triangles which have their vertices in real world coodinates. I'd then probably need to check all of them for collision with the ray, and once I found one, then I could figure it out.

Has anyone done anything like this or have any ideas? I think it's a tricky one ...

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Jun 2012 17:01
There is a command in Sparky's I'm sure, to return the polygon number that has been hit. So, if you could get that working, you could then take the 3 vertices from that polygon, work out an area in 3D based on the average location, giving the centre of the polygon (likely hit point), then the average 2D location from the UV coords, added together and averaged out. Then with this UV coord, you multiply the X and Y by the width and height of the texture, and you have your bullet hit point on the texture... or roughly that location. If your polygons are quite small, then it would work pretty nicely - wouldnt work so well on big polygons, but for your needs, just working out which polygon got hit should do the trick.

If you can't find that command in Sparkys, maybe it's in newton, or something like that - I will have a look tonight and see if I can offer more advice.

Also, there is that awesome art package texturing program Dark Paint, that must use 3D poly to texture conversion somewhere, maybe Russia would help you out...

http://forum.thegamecreators.com/?m=forum_view&t=184410&b=8

Along with that, there is a built in decal system but I'm a bit foggy on that. I will see if I have the old example of that as well, but I'm not sure if that'd be any good for animated models, I'm thinking it's just for statics.

Health, Ammo, and bacon and eggs!
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 5th Jun 2012 17:33
That's a good find Van. I just looked in the Sparky's help file and it does have a getFaceHit command, with the help "returns the id of the polygon hit in the last collision (as listed in the object's memblock)", which I assume means if I was to convert the object to a mesh and then use the MAKE MEMBLOCK FROM MESH command, I would be able to zero in the polygon described.

The problem though is the animation data, especially since my animation translations are done in a shader. I'd first need to be able to create an object which is in it's animated pose as it's "permanent state", if that make sense, then create a collision object from it, then fire the ray with sparky, get the face, traverse a memblock, grab the polygon, find the middle (that'd be accurate enough), and go from there.

Doable! All the steps would be:
- Extract current limb rotations from Enhanced Animations
- Lock vertex data for each limb, and manually apply all the transformation matrices to permanently move the vertices and effectively create a new posed model.
- Configure as a sparky's polygon collision object
- Fire the ray and get the polygon
- Convert the model to a memblock (probably could have another one already converted, as the mesh data wont change)
- Find the index data, find the polygon, get the 3 verts, extract the UV coords, average them together, Bob is both our uncles (apparently we're related!)

Argghhh. Tough, but doable. The realtime performance hit is scary though ... especially if a minigun could hit a play 20 times per second. But having said all that, if I want limb perfect bullet collision, for things like applying forces to rag dolls, I have to figure out a solution for detecting a limb hit by a ray at least. So it's got to be done.

Thanks Van. At the least, that face hit command may come in handy. It's the only method I know that will return the poly for me, without calculating the poly myself. So it's a good start!

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Jun 2012 19:54 Edited at: 5th Jun 2012 19:54
Would it not be easier to glue a small zbiased plane textured with the bullet hole to the limb at the point where the bullet hits? Sparky's gives you the normal and position which is everything you need. If you go messing with the texture it means you have to have a different set of textures for every player, plus there will be places where the texture maps to the model in such a way that the bullet hole is distorted or only half visible.

[b]
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jun 2012 20:07
Quote: "Undergrowth"


Overgrowth

I wonder how you'll calculate the direction the blood has to flow on the texture?

Just to give you my 2 cents, in order to get the vertices of a face when using sparky's you just have to multiply SC_GetFaceHit() by 3. I've attached an example.



TheComet

Attachments

Login to view attachments
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jun 2012 20:12
Oh and this code might interest you. All credit goes to Neuro Fuzzy for this one. The demo is 2D, but the functions are actually meant for 3D triangles. It could help you calculate the offset in the texture when you calculate the UV data.



TheComet

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 5th Jun 2012 20:12
Quote: "I wonder how you'll calculate the direction the blood has to flow on the texture?

Just to give you my 2 cents, in order to get the vertices of a face when using sparky's you just have to multiply SC_GetFaceHit() by 3. I've attached an example. "


Thanks for that Comet. That'll save me a few hours faffing about experimenting! Is that with a memblock created from a mesh of the object?

As for the blood flow direction, I think you'd just need a normal for the face (taking into account the object rotation etc). From that you could calculate a down direction for the face, and with the UV coordinates of the vertices, you could calculate how that orientation maps to the texture .... several hours more faffing about with maths though, no doubt.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jun 2012 20:15
Quote: "Is that with a memblock created from a mesh of the object?"


Yes. It'd actually be better if you extracted the vertex data into an array when loading the object and use that rather than accessing memblocks during your game.

TheComet

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2012 13:42
Quote: "From that you could calculate a down direction for the face,"


The problem with that is the "down" direction changes when a limb is animated. You wouldn't want the blood to magically not rotate as the limb rotates - but you would want the blood to flow down of course. Sounds like a tricky problem to get an animated effect right. A static decal effect such as blood spattered bullet holes should be much simpler to implement - and you could use the original down direction and assume the blood spreads and dries instantly. It depends on how much realism you need I suppose.

I'll be watching this thread with interest.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 13:44 Edited at: 6th Jun 2012 13:49
You could rotate the blood with point object, and put something on the ground, then smooth the rotation to get an arc. The object on the ground would rotate with the player. That gets blood always flowing down in the right direction.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2012 13:48
Quote: "You could rotate the blood with point object, and put something on the ground."


You can't rotate the blood with point object, because the blood isn't an object.

@ Fallout

I have a few ideas on how to make flowing blood, so it's possible I'll be able to update you with some more code. What interests me though is why you're asking this on the DBP board with DBP code, but you're programming it in Dark GDK?

TheComet

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 13:54 Edited at: 6th Jun 2012 13:59
OK, but the drawing collision is an object, so you can still use point object as a drawing tool with a Sparky collision check. So each bullet is stuck to the skin, and behaves like a slug affected by gravity, drawing blood where it moves to.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Jun 2012 13:55
Quote: "The problem with that is the "down" direction changes when a limb is animated. "


Yes, that's a challenge. You'd have to calculate the down direction from a collision normal, and rotate that collision normal by the limbs hierarchy. Starting to sound like more trouble than it's worth, isn't it?

Quote: "You could rotate the blood with point object, "


As Comet said, the blood would be a texture layer so you couldn't point or rotate it.

Quote: "What interests me though is why you're asking this on the DBP board with DBP code, but you're programming it in Dark GDK?"


Purely because the theory is the same, and this board is more active! If I'm writing test programs, I still use DBP because it's much quicker to prototype an idea, so trying out ideas in DBP will most likely be the way I solve it .... if I solve it.

I'm still not sure if it's worth the effort though. Undergrowth is a 3rd person close up game, but Carnage is viewed from quite far away. I may be doing more work than I really need to, but when the camera zooms in in death cam mode, it'd be awesome to have full on flowing blood.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 14:01 Edited at: 6th Jun 2012 14:06
Quote: "As Comet said, the blood would be a texture layer so you couldn't point or rotate it."


You use Sparky's to initialise the collision check. So stick something down to draw the texture, and then keep that object attached to the skin, but affected by gravity, and as it moves you repeat the sparks check, and keep drawing the texture in the position of the hidden object. It would be like a 3D pen if you like.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Jun 2012 14:04
I think you're missing the difficulty Pincho. The problem is converting a 3D world position to a draw position on the texture. Sticking objects and moving them with gravity is all well and good, but when you get your object position and try and turn it into a drawing on a 2D texture, that's when the head scratching begins.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 14:07 Edited at: 6th Jun 2012 14:07
Quote: "I think you're missing the difficulty Pincho. The problem is converting a 3D world position to a draw position on the texture. Sticking objects and moving them with gravity is all well and good, but when you get your object position and try and turn it into a drawing on a 2D texture, that's when the head scratching begins."


I think I am making it easier though. Try it on a plain object. A 3D pen.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2012 15:10
Quote: "Sticking objects and moving them with gravity is all well and good, but when you get your object position and try and turn it into a drawing on a 2D texture, that's when the head scratching begins."


I thought that step was solved? You know the vertex index, you know the UV coordinates of each vertex, and you know the 3D collision point which enables you to calculate the UV coordinates of the collision point using that triangle function I provided by Neuro Fuzzy.

TheComet

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 15:16 Edited at: 6th Jun 2012 15:18
Sorry, I was making it so that the blood runs, and that wasn't originally required. Would be neat though.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2012 15:19
Quote: "Sorry, I was making it so that the blood runs, and that wasn't originally required."


That's his aim. But using dummy objects and stuff like that probably isn't the best method.

You can calculate the orientation of the face by using the 3 positions of the vertices, but my head probably can't support that kind of math. Neuro Fuzzy, we need you!

TheComet

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jun 2012 15:24
I think that Chafari has drawn on UV's before. He gets the location somehow.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2012 15:45
@Diggsey

Quote: "Sparky's gives you the normal and position which is everything you need."


I can't seem to get Sparky's collision to allow for the animation. The only relevant functions seemed to be the static ones, e.g. sc_getStaticCollisionX() and these don't seem to change when the object animates.

How do you get the exact XYZ point of the raycast position for an animated object? I'm probably missing something simple because I haven't used it before - and I might have an old version.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2012 15:52
Quote: "I can't seem to get Sparky's collision to allow for the animation."


Sparky's uses the first frame of the object for all collision checks, regardless of what frame it's in. It helps boost speed. What you might be able to get away with is setting up the object every frame... Would it be hard to write a DLL which just handles raycasts on animated objects?

TheComet

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Jun 2012 15:58 Edited at: 6th Jun 2012 15:59
I don't think you can Green. You can't setup Sparky to work with an animated object, to my knowledge.

Quote: "I thought that step was solved? You know the vertex index, you know the UV coordinates of each vertex, and you know the 3D collision point which enables you to calculate the UV coordinates of the collision point using that triangle function I provided by Neuro Fuzzy."


That's cool for a static mesh, but mine is an animated character, and what's worse, is it's GPU animated. Sparky doesn't support animated meshes natively. There is no easy way I can use Sparky to return the triangle.

The only way I can think of is to calculate the vertex positions myself by translating them by all the limb rotation matrices, then create a static mesh Sparky can collide with. But I can tell by just typing it that'd be too slow.

I personally think the only real option is to work manually with the raw data. Arrive at a bunch of triangles, and do some funky maths to find out if the collision line is intersecting them. The triangles would all have to come from animated/rotated vertices, and those would have to come from something internal, as with all the bone weighting and things going on, I would really struggle to calculate them myself.

I'm going to poke about later and see if the get object command (GDK) can yield up a link to the vertex data in it's animated and posed form.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2012 16:19
Sounds awfully complicated... Is there no way to have raycasts done on the GPU somehow? Or at least at some lower level, because after all, those vertices are just a few floats in memory right? I think attacking the problem from above is not he way to go.

I played around with my demo a bit and made it possible to draw to the object using the mouse. For some reason though it doesn't work with all of the faces... The sphere works best to draw to. Check it out (attached).

TheComet

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2012 16:30
Quote: "You can't setup Sparky to work with an animated object, to my knowledge."


Yes, that's the conclusion I was coming to.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Jun 2012 16:31
I think that I read somewhere that you have to allow object scaling in Sparky's, to support animated models.

I don't think there's an easy solution to this, it all involves some tricky maths. Personally, I'd love to have trickling blood and stuff, so I'd substitute accuracy to get that. I'd work out a general location based on the object limb positions, and go from there.... maybe exagerating the blood to help cover the innacuracy, and then just have the blood trickle down on the texture.

Health, Ammo, and bacon and eggs!
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Jun 2012 16:49
Quote: "Sounds awfully complicated... Is there no way to have raycasts done on the GPU somehow? Or at least at some lower level, because after all, those vertices are just a few floats in memory right? I think attacking the problem from above is not he way to go.

I played around with my demo a bit and made it possible to draw to the object using the mouse. For some reason though it doesn't work with all of the faces... The sphere works best to draw to. Check it out (attached)."


Cool demo mate. Even if I can't solve this problem, that sort of thing could come in handy for something else. I found the same issue btw; a few of the sphere's top faces weren't detected.

As for doing it all on the GPU, I'm sure that is possible, but the problem is, AFAIK you can't modify a texture on the GPU. You can sample from it, but not change it (perhaps I'm wrong). Also, with the amount going on in my shaders, I couldn't cram anything complex like that into it without dropping something else.

Quote: "I don't think there's an easy solution to this, it all involves some tricky maths. Personally, I'd love to have trickling blood and stuff, so I'd substitute accuracy to get that. I'd work out a general location based on the object limb positions, and go from there.... maybe exagerating the blood to help cover the innacuracy, and then just have the blood trickle down on the texture."


You could be right. I could put a huge amount of effort into this, just for it to be almost impossible to see due to the perspective of my game. You'd be able to see it during the deathcam views, but perhaps a cheat would be good enough. If I just detect a hit from a number of locations, I can then draw the blood from a known position.

For example, attach some dummy objects to the models limbs (boxes). Set them up in Dark Dynamix as capsules ... I'll have to do this anyway for rag dolls. Cast a ray and detect collision on a per limb basis and then simply modify a blood texture from a preset location on, for example, the upper arm portion of the texture. I will already have the direction normal, as this will be returned by Dark Dynamix ray casts as it hits the dummy capsule/box. From that, and the angle of orientation of the capsule, I could calculate which was to draw the blood.

I've just finished some arterial particle effects and uploaded a vid to my thread, so I am at the stage where gore-ifying the model is the next step ...

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Jun 2012 18:02
Sounds good, will have to remember to keep an eye on that, I always like gore, even just coding gore effects is fun. Like my little brothers Game Maker project, I added a gib to that, like basically a bleeding porkchop, spitting out blood particles and bouncing around. I had a great laugh adding that, turned a harmless little game with a man and a little dog, into a total bloodbath.

I wonder, if it would help to be able to check if the collision is in front, or behind the whole model - I think that you could get a good effect based on just the front/back, and the nearest 2 limbs.... as long as your models are UV mapped uniquely, so no overlapping.
Okay, time to get long-winded...

Imagine you calculate a point in front of your character, and a point behind your character, maybe 1 metre in front and 1 metre behind. Then, you have a 3D position of a collision, you can work out if this collision is to the front, or the back of the character. Obviously you can also figure out the closest limb as well. I'd work out if the collision is in front or behind, and also the 2 closest, linked limbs. So, if someone get's shot in the butt, the collision is behind the character, and maybe on the pelvis bone, between the hip and base of the spine bones.

Now, if you flag both the front and back bones as locations on the texture, you could translate roughly where the collision happend. Once you know which side, and which pair of joints are affected, you should be able to work out a rough 2D texture location, from the locations on the texture map. It would be possible to work out the balance between the 2 bones.... like check the distances, total them, then you work out the percentage of each bone that is hit - apply that to the 2D texture bone locations. Would give a decent indication of the collision, but mostly along a bone, rather than anywhere on the model. Might be more worthwhile for calculating severed limbs - like a sword chopping right through a leg, and having the gib and remaining limb resize to suit where the blade actually hit... damn that would be cool, proper slicing and dicing, well worth the work invovled I think.

Anyway, just thinking out loud again. I'd love to see some Overgrowth style effects in Carnage, especially the bleeding.

Health, Ammo, and bacon and eggs!
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Jun 2012 18:41
I get your basic meaning, I think. Map skeleton joints to rough locations on the texture map. Work out where a 3D hit is in relation to the skeleton and then derive a 2D coordinate in the UV map. Messy, ugly, but probably accurate enough and very fast. Could be worth thinking about.

I've just completed a memblock based texture changer and it's fast. I can store wound decals as memblocks, and the characters blood texture as a memblock all the time. Then when injured, I just copy the decal into the blood memblock and recreate the image. It seems quick and looks good. Now to get the accuracy, perhaps using the method you described.

As for gore mate, check the 2nd post in my WIP to see the plans for total dismemberment.
http://forum.thegamecreators.com/?m=forum_view&t=195417&b=8&msg=2330220#m2330220

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Jun 2012 18:44 Edited at: 6th Jun 2012 18:46
You could glue hidden objects which have the same geometry and UV coordinates as the animated mesh to each limb of the character and then use sparky's on those objects.

[b]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2012 19:33
Quote: "You could glue hidden objects which have the same geometry and UV coordinates as the animated mesh to each limb of the character and then use sparky's on those objects."


How would that help? Wouldn't you just have the same problem?

Quote: "I think that I read somewhere that you have to allow object scaling in Sparky's, to support animated models."


That improves matters but the collision point doesn't seem to move correctly with the object. Here's the code I used (it uses the "tiny.x" model from the MS DX SDK). The long thin box represents the raycast.



@TheComet

Neat demo.
Chenak
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 6th Jun 2012 22:28
I'm not entirely sure how to do this as I haven't got this far into development of my project but I've noted down ways it could be done.

There was a command in dark physics which returned UV coordinates from a raycast to an object (Although it didn't work), maybe Matty H could implement this if we ask nicely as it might be in the phyx library as I think using the methods currently suggested would be quite slow especially for more than one model.

Once you can get the UV coordinates in theory all you need to do is create a wrapped UV layer (using a shader would be the best option) and use Image kits paste image function to draw the decal onto the uv layer image.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Jun 2012 22:43
Quote: "How would that help? Wouldn't you just have the same problem?"

No, because sparky's works on moving objects just not animating ones. If you glue the objects to the limbs sparkys should be able to give you collision information.

[b]
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 7th Jun 2012 00:21 Edited at: 7th Jun 2012 00:22
Gluing objects may be a solution to the animation issue. There would be inaccuracies where the attached object's verts didn't blend with the bone weights, but it'd be pretty close.

Quote: "There was a command in dark physics which returned UV coordinates from a raycast to an object (Although it didn't work), maybe Matty H could implement this if we ask nicely as it might be in the phyx library as I think using the methods currently suggested would be quite slow especially for more than one model. "


If that works that'd be useful. Might be worth suggesting to Matty for v1.2 after he's released v1.1. That in conjuction with glued objects would get around the animation issue. Could work!

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Jun 2012 02:20
Quote: "You could glue hidden objects which have the same geometry and UV coordinates as the animated mesh to each limb of the character "


I took that to mean exactly the same, but if you mean simple limbs without blending weights then as Fallout suggests there would be some, hopefully minor, inaccuracies around joints. It could work with that proviso.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Jun 2012 00:14 Edited at: 9th Jun 2012 00:16
I have added the command 'dynRaycastHitGetFaceID' to Dark Dynamix. Also you may be able to add these two functions to the header right now:
float dynRaycastHitGetU()
float dynRaycastHitGetV()

So that may help a little but there are problems. Firstly, I will need to add commands to cook and make a triangle mesh from the bones of an object, this should not be a problem although it will push back the update a little.

Then, I don't think the barycentric coordinates PhysX returns are the actual UV data of the model, I say this because it does not seem to allow you to set the UV data when you cook the mesh, so how would it know? I will look at this again.

So, supposing all goes well, you should be able to sync all triangle mesh(bones) to the model(even with animation) since this is how ragdolls work anyway. You will have the face(poly) along with a set of UV coordinates which you may need to do a little extra work on to convert to the actual UV coordinates.

You may be able to try some of this on a limb based model already as I think the commands are in place to position all limb actors to limb positions just before any raycasts. Although the faceID command is not in there yet.

Sorry I can't help more but I don't yet understand the UV barycentric coordinates much, It seems to work now on a static cube but I think if the texture is scaled you would have to account for that yourself.

I will post back if I obtain any more information.

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 11th Jun 2012 12:46
Matty, thanks for taking an interest in this! I would say don't worry about it just yet. I'd much rather see the update with all the cool rag doll stuff and other fixes. I am progressing down a line of limb based collision for my gore effects for the time being.

If we can work out a precise UV solution later on down the line, it'd be well worth having a go though. Having seen Comet's example. I can see lots of scope for how useful it would be. My thoughts are things like having an extra texture layer for the entire world geometry, then adding decals, blood splats, and other texture effects directly to that. So there is definitely value in UV based collision, but don't put time into it just for me now, as it's not holding me back.

Looking forward to that update!

Login to post a reply

Server time is: 2024-03-29 05:00:50
Your offset time is: 2024-03-29 05:00:50