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.

Code Snippets / Shrinkwrap Collision (DBPro 5.8)

Author
Message
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 28th Oct 2005 03:00
Here's a possible solution to those polygon collision woes. Shrinkwrap Collision! Simply take your high polygon model and use this function to create a low polygon "ghost" object. Then simply use the the low polygon ghost object for all your Set Object Collision To Polygon needs.

How it works:
Start with a sphere that surrounds the target model. Then cast Intersect Object rays from each of the sphere's verticies to the center of the target model. Then move each of the sphere's vertecies to the collision points on the target object. The end result is the sphere is "shrinkwrapped" down around the target model. Simply hide the ghost shrinkwrap clone and move/rotate along with the original object.

Features:
1) You can set the number of Rows and Colums the sphere will have to start with, which can help adjust the LOD of the collision and the resources used (processing speed).
2) The function retains the taret object locaition and rotation, so the shrinkwrap function can be used anytime in the code.
3) Can also be used for making LOD clones of your models.


Open MMORPG: It's your game!

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Oct 2005 11:13
Now why didn't anyone think of that before!! It's a principle that's been around for a long time, but done in a very effective way.

Newton does a similar thing with static meshes, and saves loads of polys.

I haven't tried it, but I'm impressed just be reading.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th Oct 2005 14:33 Edited at: 28th Oct 2005 14:34
It sounds excellent for a substantial amount of lag reduction with a very minimal loss of detection, great job.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th Oct 2005 20:39
I don't think this would be practical for caved in map files, because the shrink wrap would form around the outside of the map file not the inside. So if you had a house inside a box, the shrink wrap would look like this (in red):



So if you were inside the box, you would't be detecting collision with the house, just the outside cave walls.

I think to overcome it you'll need to add another sphere morphing function that creates a sphere inside the object and stretches outwards aswell.

Just an idea, I might be missing something, either way great idea even if it only works with "unclosed" objects.

- RUCCUS

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2005 20:45
i think its possible that some objects might stick out of the "bubble" using that method to shrinkwrap. but its a cool idea


Deadly Night Assassins
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 29th Oct 2005 06:53
@Ruccus. Good point. It would be a fairly easy thing to flip it around and make a very small sphere that expanded to fill an interior. Maybe a second function is in order. Then the programmer can choose which one to use as needed.

@Phaelax: If you tried it on the included cows, you will see that you are absolutely correct. It is a heck of a lot closer fit than a sphere. In some cases, like cows and people, a little overlap is okay. Push your hands together. They don't stop at the point of impact, but squish together a bit. Anyway, it's intended to be a sort of fill-the-gap between sphere collision and polygon collision, which I think it does well; and with whole-hearted agreement, not perfectly.

@Everyone: Thanks for the feedback. I'll work on that inverted Balloon Fill code.


Open MMORPG: It's your game!
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 14th Nov 2005 03:07
To prevent what Ruccus is saying (If I am understanding him) simply start the sphere within the player to shoot out its verticies from incide the player.
Prime_8
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location: Canada
Posted: 15th Nov 2005 05:30
wicked slick..

You have made i possible for me to speed up soo much of my work .

great thing is i can export the object as a dbo .. to speed loading for end product

thanks RiiDii

2 + 2 = 5 (for extreamly large values of 2)
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 29th Nov 2005 17:06
Glad it was usefull!


Open MMORPG: It's your game!
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 30th Nov 2005 13:23
Wow, what a tremendously clever idea. To prevent all problems, I think it's best done outside of a program and saved for use in a game.

It will essentially provide perfect collision for characters. Not pixel perfect, but close enough that the difference would never be noticable. Why didn't I think about that? I'm the king of efficient code.

Maybe a Shrinkwrap utility would be in order. Load your model, scale the collision sphere, ZAP, and save. So simple, so useful.

Good work, Riidii.

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 1st Dec 2005 16:01
Quote: "Maybe a Shrinkwrap utility would be in order. Load your model, scale the collision sphere, ZAP, and save. So simple, so useful."

that's funny, i was thinking the exact same thing when i was a third of the way through your post...

Great idea RiiDii! I'll be sure to use this if i ever need fast and remotely accurate collision detection.

"We make the worst games in the universe..."
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 2nd Dec 2005 03:34
Cool. I'll have a look at this as soon as I can. I have been loading low poly models made from action 3D Reducer up till now.

Kohaku
20
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 2nd Dec 2005 13:02
Ooh, very clever! Like you said, this would be incredibly handy for an accurate LOD routine.


You are not alone.
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 5th Dec 2005 06:20
What would be even better is a utility that shrinkwraps an animated model. Then, you could sync the two animations and have perfect polygon collision, suitable for something like hand to hand combat.

I've been thinking about the best way to do it. The number of verticees would remain the same, but the locations would change, since it is so low poly. Append animation was my first thought, but I think that would work poorly. Character shop could probably do it, but once again poorly.

If the utility wrapped limbs, then the Append animation command would probably work for it. I'm very interested in this application of your idea, Riidii. I'll just have to give it some thought and run some tests.

FXTC
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location: CzechRepublic
Posted: 17th Dec 2005 17:22
thats super for LOD system,only need place same texture to low poly cow

AMD 2,4 512MB RAM,2x200GB hdd,GforceFX5700GT128MB
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 7th Jan 2006 09:39
Thanks for the comments everyone. Sorry for the delay in replying. Posts in this forum usually take a while for folks to check up on (myself included).

As far as working for an animated model, I'm afraid I can't be of much help there since I've never animated a model (if I did, I've forgotten it). The only thing I could suggest is maybe taking a model apart, limb by limb, make a shrinkwrap of each limb, then glue the shrinkwrap model together in the same format as the original model.

To make copies of limbs, DBPro has the Make Object From Limb command.


Open MMORPG: It's your game!
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 7th Jan 2006 21:10
I'm working on the animated model right now... hopefully done soon.

Login to post a reply

Server time is: 2024-11-27 01:02:07
Your offset time is: 2024-11-27 01:02:07