Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Resources and Tools => Topic started by: Eluo on August 22, 2011, 03:02:08 am

Title: [TOOL] [M2 edit] Collision Adder
Post by: Eluo on August 22, 2011, 03:02:08 am
[center:3it2u7ty]Collision Adder by Tigurius[/center:3it2u7ty][/b][/u]

About this tool:.
Copys the full verts of the m2 model as collision into the model.

Additional Info:
Used in 3.x
Source Included

Download:
[attachment=0:3it2u7ty]CollisionAdder.rar[/attachment:3it2u7ty]


External:

File-upload.net (http://www.file-upload.net/download-3679570/CollisionAdder.rar.html)
Mediafire.com (http://www.mediafire.com/?6pqq86ha67chkjt)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 26, 2011, 01:30:49 am
Hello !

Ok, so here's how I added collisions to my model (the road I posted earlier).
When I started to look at collisions, I tried to use Collision Adder, but it didn't seem to work exactly the way I expected.
That's why I decided to have a look at the source (thank you so much for including it) and try to understand how it works.

After some time, I thought it was related to the way normals were handled. As I understand it, the program copies the model vertice and normals, as well as the skin file triangles, to make a custom bounding box.
The wiki (and that's also what I observed on a Blizz model) says there's one surface normal per triangle for the bounding box, and not 3 like the ones that go with the model vertice.
So I slightly edited the program to make it fit : one normal per triangle (so their number was divided by 3), and I added cross product + normalize to calculate the values for each of them using the existing functions.

Of course I include the modified main.cpp as well as the exe.

Be indulgent, C++ (and M2 actually) is like a whole new world to me. It took me time to figure out how to compile the original program, adding my 4 lines at the right place, etc.
Nonetheless, it looks like my changes work here (and I'm the first one surprised they do), so I post them. Hope it'll be useful.

I tested the program on 2 models only, since I don't have many of them. Of course, on both it worked.

Feedback is welcome :)

Direct download: http://d.pr/8PGT+ (http://d.pr/8PGT+" onclick="window.open(this.href);return false;)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Zim4ik on October 26, 2011, 10:04:09 am
Hi,
Could you post a link to download, cause i "dont have a permission to download files".
Thanks
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on October 26, 2011, 10:11:07 am
Quote from: "Zim4ik"
Hi,
Could you post a link to download, cause i "dont have a permission to download files".
Thanks
Added to first post.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: TheBuG on October 26, 2011, 02:07:07 pm
Quote from: "Mjollna"
Hello !

Ok, so here's how I added collisions to my model (the road I posted earlier).
When I started to look at collisions, I tried to use Collision Adder, but it didn't seem to work exactly the way I expected.
That's why I decided to have a look at the source (thank you so much for including it) and try to understand how it works.

After some time, I thought it was related to the way normals were handled. As I understand it, the program copies the model vertice and normals, as well as the skin file triangles, to make a custom bounding box.
The wiki (and that's also what I observed on a Blizz model) says there's one surface normal per triangle for the bounding box, and not 3 like the ones that go with the model vertice.
So I slightly edited the program to make it fit : one normal per triangle (so their number was divided by 3), and I added cross product + normalize to calculate the values for each of them using the existing functions.

Of course I include the modified main.cpp as well as the exe.

Be indulgent, C++ (and M2 actually) is like a whole new world to me. It took me time to figure out how to compile the original program, adding my 4 lines at the right place, etc.
Nonetheless, it looks like my changes work here (and I'm the first one surprised they do), so I post them. Hope it'll be useful.

I tested the program on 2 models only, since I don't have many of them. Of course, on both it worked.

Feedback is welcome :)

Direct download: http://d.pr/8PGT+ (http://d.pr/8PGT+" onclick="window.open(this.href);return false;)

I'll give it a try when I've got some 3d modelling programs installed again, thanks!
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on October 26, 2011, 06:34:54 pm
wow, checked on my 24 models . 100% fine work
-----
THANK YOU!  :!:
Zim4ik wrote to me on Skype about this tool:

Original:
[21:31:57] Богдан | Zim | Билитюк: Скажи ей/ему спасибо
-
Translate:
[21:31:57] Bogdan | Zim | Bilityuk: Tell her thank you very much
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 26, 2011, 06:47:13 pm
Oooh great ! :)

Thanks for testing, and I'm so happy it also works on other models than mine ^_^
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on October 26, 2011, 07:20:02 pm
On one of the models not added collision

As should be:
C:Documents and SettingsUser>D:tempCollisioncollisionadderCollisionAdder.e
xe D:tempCollisioncollisionadderEnclaveWallfragment01.m2
 Loading Model D:tempCollisioncollisionadderEnclaveWallfragment01.m2
 Loading Skin D:tempCollisioncollisionadderEnclaveWallfragment0100.skin
Saving Changes

As happens with bugged? model:
C:Documents and SettingsUser>D:tempCollisioncollisionadderCollisionAdder.e
xe D:tempCollisioncollisionadderEnclaveWallpost.m2
 Loading Model D:tempCollisioncollisionadderEnclaveWallpost.m2
 Loading Skin D:tempCollisioncollisionadderEnclaveWallpost00.skin

-
Missing line "Saving Changes".
collision in model also not added.
(The model I have added below)

this my 31th model (of 100-120)

I can give you more models that do not work in Collision adder (via Private Message)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 26, 2011, 09:35:09 pm
Mmh, could you send me your mdx for this model ? It would be really easier for me to see if there's something different from the one I use, and why one of them works and not the other.

Are there lots of models that don't work for you ?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on October 26, 2011, 09:42:43 pm
does not work about 20-40% models.
oh mdx... i have only mdl((MDX analog, which can be edited via Notepad) source. now take a search.
up1:  Attach two MDL models in the archive
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 26, 2011, 10:33:44 pm
Thanks, that was really helpful :)

I don't get why for the moment, but I have a simple fix :

If number of vertice < number of faces in mdl/mdx (you have both numbers in mdlvis in the upper right corner of the vertice editing mode), the conversion crashes.

So you can take the model, copy a free vertice (on both models you have one in more or less the center of the grid), and paste it until you have more vertice than triangles. The the converter doesn't complain and it goes ok.

I'll try to see if I can correct that better.

(And btw, I really like the shape of the fence you sent ^^)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on October 26, 2011, 11:45:58 pm
hmm, when converter was crashes. I copied (duplicate) geometry in model, while number of triangles was still several times more (than vertices). But a model successfully converted. (Similar problems were encountered only in models with 2-3k triangles)

or something I do not fully understand.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 05:40:38 pm
I tried to solve the problem yesterday night but I still haven't a clean solution to correct it. I will try again though, when I have a new idea.

Do you still have some models you can't convert at all, even with the "add more vertice" trick ?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on October 27, 2011, 06:00:18 pm
Quote from: "Vel"
As happens with bugged? model:
C:Documents and SettingsUser>D:tempCollisioncollisionadderCollisionAdder.e
xe D:tempCollisioncollisionadderEnclaveWallpost.m2
 Loading Model D:tempCollisioncollisionadderEnclaveWallpost.m2
 Loading Skin D:tempCollisioncollisionadderEnclaveWallpost00.skin

Code: [Select]
$ ./CollissionAdder ../wtfmodel/EnclaveWallpost.m2
 Loading Model ../wtfmodel/EnclaveWallpost.m2
 Loading Skin ../wtfmodel/EnclaveWallpost00.skin
Saving Changes

I see no problem there.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 06:17:58 pm
O_o

That one is weird... On Vel's model I have a converter crash with my modified version (but not with the original one : the collisions are then saved but not correctly created).

There's definitely something I don't get :)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on October 27, 2011, 06:23:07 pm
You may want to look at the stacktrace of the crashed application as well as add debug output to see in which line the problem is.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on October 27, 2011, 06:45:42 pm
I just cleared the code up a bit out of boredom.
http://d.pr/ssJe (http://d.pr/ssJe" onclick="window.open(this.href);return false;)
Clean code, guys!
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 07:18:37 pm
Wow, thank you :)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 08:54:12 pm
lol, I feel bad, I should have seen my error (looks like I forgot to change nInd to nTri a few lines up) -_-
Thanks again.

I have a noob question... g++ complained with the include using < > (it couldn't find the files) and I had to change to " " to compile... I tried to read about the difference (quick googling), but I'm not really sure if it changes something in the end or not... Is it really bad to use one instead of the other ?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on October 27, 2011, 09:08:21 pm
" is relative to the current directory. < is relative to the search path specified to the compiler, usually with -I.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 09:38:28 pm
Ok, thank you :)

I upload a compiled version (no changes).

Direct link : http://www.file-upload.net/download-383 ... 7.zip.html (http://www.file-upload.net/download-3836918/collisionadder_2011-10-27.zip.html" onclick="window.open(this.href);return false;)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on October 27, 2011, 09:48:48 pm
Quote from: "Mjollna"
Ok, thank you :)

I upload a compiled version (no changes).

Direct link : http://www.file-upload.net/download-383 ... 7.zip.html (http://www.file-upload.net/download-3836918/collisionadder_2011-10-27.zip.html" onclick="window.open(this.href);return false;)
Code: [Select]
C:Documents and SettingsUser>D:TempCollisioncollisionadderCollisionAdder.e
xe D:TempCollisioncollisionadderEnclaveWallpost.m2
 Loading Model D:TempCollisioncollisionadderEnclaveWallpost.m2
 Loading Skin D:TempCollisioncollisionadderEnclaveWallpost00.skin
Saving Changes

Thank Mjollna, you're the best!

During the day, I'll look at all of its remaining models.
\\
up1: checked for 12 models (which had not previously worked) - on a new version works
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on October 27, 2011, 10:09:33 pm
You'll have to thank Schlumpf on this one, not me :)
I just uploaded a compiled version.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Steff on October 27, 2011, 11:00:37 pm
We all should thank schlump... Thanks Schlumpf ;)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: thesixth on December 02, 2011, 12:58:35 pm
Sorry if this is just a stupid question, but by adding collision to a model.. like a character model, makes it so, that one cannot simply just walk thrugh him anymore?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Vel on December 02, 2011, 01:34:38 pm
no, collision on character needs to interact with the world.
(Gnome can get into the fireplace (http://www.flickr.com/photos/azyxa/4141714596/sizes/l/in/photostream/)(link) in the tavern in Goldshire, but a human can not.)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on December 02, 2011, 01:39:33 pm
Characters / units are not checked for collision against each other. They do have collision, else they could not collide with the world around them.

Also, collision cannot be animated which would be really odd for more than a basic box used for collision.

To enable collision between units one would have to modify the client in depth, thus being pretty much impossible.

You can do pseudo collision for unit movement server side though. This would be odd for players though as not known by the client. For DotaWoW, they did collision for NPCs being regarded in path finding.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Alastor on May 20, 2014, 10:04:31 pm
One Stupid Question ...
What About Collision Remover ? or do you know any way how to *fak* up with collisons ?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on May 20, 2014, 10:49:13 pm
Quote from: "dahaga"
One Stupid Question ...
What About Collision Remover ? or do you know any way how to *fak* up with collisons ?

http://pxr.dk/wowdev/wiki/index.php?tit ... tLK#Header (http://pxr.dk/wowdev/wiki/index.php?title=M2/WotLK#Header" onclick="window.open(this.href);return false;)
let
Code: [Select]
0x0BC Vec3F[2] BoundingBox
0x0D4 float BoundingRadius
0x0D8 uint32 nBoundingTriangles
0x0DC uint32 ofsBoundingTriangles Our bounding volumes. Similar structure like in the old ofsViews.
0x0E0 uint32 nBoundingVertices
0x0E4 uint32 ofsBoundingVertices
0x0E8 uint32 nBoundingNormals
0x0EC uint32 ofsBoundingNormals
all be zero.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Alastor on May 21, 2014, 01:13:52 am
Oh i was wondering its something around bounding box
Thanks for this
i tried my model (quicksand) and all worked well
idc
(http://i.imgur.com/qePS8ow.png)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Kiun on June 04, 2014, 01:54:32 pm
May someone reupload latest compiled version please? (Links are down)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: MR. Farrare on June 07, 2014, 06:40:35 pm
yes plz these models http://www26.zippyshare.com/v/21759497/file.html (http://www26.zippyshare.com/v/21759497/file.html" onclick="window.open(this.href);return false;) don't work with Collision Adder I have
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: monoman on September 11, 2014, 01:53:17 am
Does anybody still have the latest compiled version of this app?
It would be very usefull to have one the one that can handle the Camera collision as well the normal collision.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Valkryst on January 13, 2015, 02:35:37 pm
Sorry about the necro, but I don't know much of anything about modeling or that for WoW.

If I were to use this on the player models, would that prevent players, mobs, etc... from walking through each other or are collision boxes set to only work for objects?
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: schlumpf on January 13, 2015, 02:51:16 pm
They already have a collision bounding box. Figure from that.

(It does not. Not everything collides with everything.)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Valkryst on January 13, 2015, 04:32:03 pm
Quote from: "schlumpf"
They already have a collision bounding box. Figure from that.

(It does not. Not everything collides with everything.)

Ah, alright.

Thanks for the info, Schlumpf!
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on February 10, 2016, 12:29:53 am
Necro-update :3

Re-up of the collision adder at a more stable URL (the exact same file) :
http://gaming.mjollna.org/static/docs/collisionadder_2011-10-27.zip (http://gaming.mjollna.org/static/docs/collisionadder_2011-10-27.zip)

It should be ok for LK files, but probably not for newer versions.

If you want to compile, you'll need Tigurius' now antique M2 files.
Miraculously, the mediafire link still works : viewtopic.php?f=59&t=829 (http://modcraft.io/viewtopic.php?f=59&t=829" onclick="window.open(this.href);return false;)

Why have Eluo's internal links to resources disappeared ? It's such a loss, even though there are more recent programs for lots of stuff now, some are still interesting, and show some code to people who want to start.

Edit 2017-04-21 : attached the script to this post and updated link again.
Edit 2019-02-20 : updated the link again (url changed on my website)
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Steff on February 10, 2016, 01:34:30 pm
Problem with the root. Thats why we prepare a move in the moment.
Title: Re: [TOOL] [M2 edit] Collision Adder
Post by: Mjollna on February 10, 2016, 02:50:00 pm
Oh ok, so files are still there, but not available for the moment ?
... "moving" ? You plan to migrate the forum elsewhere ?