tree.klz think tank

This is for general discussion about Hidden & Dangerous 2, talk about what you liked or what you didn't like about the sequel. Talk about multiplayer games, setup matches etc.
User avatar
Ikaros
Sergeant
Posts: 79
Joined: Wed Mar 23, 2011 11:30 am
Location: Italy
Contact:

Re: tree.klz think tank

Unread post by Ikaros » Thu Aug 11, 2011 11:54 am

Neplatny = "not valid"
Masivn = "solid wood"
http://malgolan.altervista.org/
Italian politicians - Not in my name!

User avatar
Ikaros
Sergeant
Posts: 79
Joined: Wed Mar 23, 2011 11:30 am
Location: Italy
Contact:

Re: tree.klz think tank

Unread post by Ikaros » Thu Aug 11, 2011 12:03 pm

Regarding 4x4 matrices...

What about fogetting OBB and XTOBB collisions?
We could create tree.klz which does not use those structures,
and instead uses only faces collision, cylinders, spheres, and ABB.

Faces collisions could be calculated automatically by a max script and
a list of meshes from a scene4ds.

Moreover, we can add UN-ROTATED spheres, cylinders and bounding box
which will be add by user using max.
http://malgolan.altervista.org/
Italian politicians - Not in my name!

hdmaster
Sergeant
Posts: 84
Joined: Thu Jan 27, 2011 9:31 pm
Location: Germany

Re: tree.klz think tank

Unread post by hdmaster » Thu Aug 11, 2011 12:25 pm

Thanks for the translations, I'll add it to the list.

Sorry I made a mistake, the last column of the matrices in tree.klz IS [0,0,0,1]. I got confused with all that float variables there. Problem solved ;)

// Update

The collision grid of HD2 is again very similar to the one lexov posted:

Code: Select all


// GridWidth*GridLength*GridHeight

[long]		numObjects
[long]		Reserved
[float]		Height
[long]		Reserved
[long]		References[numObjects]
Last edited by hdmaster on Thu Aug 11, 2011 3:21 pm, edited 1 time in total.

lexov
Private
Posts: 6
Joined: Sun Aug 07, 2011 11:21 pm

Re: tree.klz think tank

Unread post by lexov » Thu Aug 11, 2011 4:47 pm

Ikaros wrote: PS: a question..
How were tree.klz generated, for Mafia?
Completely manually?
Or maybe exported from a 3d-editor?
Or even automatically calculated?
Thank you very much! :)
Face col data can be created straight from the mesh data. For primitives col data we use the following approaches (or a mixture of them respectively):
  • Compute the bounding volume that corresponds to the primitive you want to create and convert it. This does of course only work well for those meshes whose shape roughly matches the one of the primitive.
  • Create and transform the primitives by hand + copy'n'paste
  • In Mafia, some model files contain dummy objects that can be used to create collision primitives. They have a parameter string that encodes the primitive type to create from that dummy as well as the material to use. In conjunction with the dummy object's transformation and AABB you can then create proper collision primitives for the entire model this way. The train station model is one of those models. It's rather complex  (has stairs, platforms, walls, etc...) but with the help of the dummies you can quickly create detailed collision data for instances of it.
The devs probably used these techniques aswell, but I could imagine that they maybe stripped collision dummies from the release version of some models, but that's just speculation.
hdmaster wrote: Collision faces have exactly the same strucure as in Mafia I. But what meaning/purpose has the value distance for each face?
The tree.klz stores the plane for each triangle. A plane is a set of points x that meet the criteria x*n + d = 0 (with n being the plane's normal and d being the distance of the plane from the coordinate system's origin).
hdmaster wrote: What's the purpose of the 'vector3 Extends[2]' values?
The extends vector is the standard encoding scheme for oriented bounding boxes. It stores the distance from the box' center to one of the box' vertices. Normally, a single extends vector is sufficient, but the tree.klz also stores the inverse of the extends vector in Extends[1].
hdmaster wrote: The bounding boxes are built just from one lower and one upper vertex, right?
Yes, if you mean minimum for 'lower' and maximum for 'upper' vertex. :) At least for AABBs.
From what I've read building tight fitting OBBs for arbitrary meshes is not easy. What we generally do is we compute the AABB of the untransformed mesh  and then transform the box according to the instance's and parental transformation.
hdmaster wrote: What effects do the different flags have?
The primitives flags define additional behaviour or properties of the primitive. The only two flags I know are 2 which makes cache.bin objects destroyable (only works for certain models like roadsigns) and 64 which lets bullets penetrate the primitive.
Ikaros wrote: What about fogetting OBB and XTOBB collisions?
We could create tree.klz which does not use those structures,
and instead uses only faces collision, cylinders, spheres, and ABB.

Faces collisions could be calculated automatically by a max script and
a list of meshes from a scene4ds.

Moreover, we can add UN-ROTATED spheres, cylinders and bounding box
which will be add by user using max.
I don't think banning (XT)OBBs is a good idea as that would mean to either approximate OBBs using spheres, cylinders and AABBs or to resort to triangle collision data. Imagine you wanted to create collision data for a stairway. (XT)OBBs are perfectly suitable for that. Spheres, cylinders, AABBs... not so much. Triangle col data may work but chances are that it's too detailed which may negatively affect player movement on the stairway (like getting stuck at times, unsmooth movement, etc..). Remember that you can't create arbitrary (low res) collision meshes but that you can only convert the visible mesh into face col data.
Last edited by lexov on Thu Aug 11, 2011 5:00 pm, edited 1 time in total.

User avatar
Ikaros
Sergeant
Posts: 79
Joined: Wed Mar 23, 2011 11:30 am
Location: Italy
Contact:

Re: tree.klz think tank

Unread post by Ikaros » Fri Aug 12, 2011 7:29 am

lexov wrote: Remember that you can't create arbitrary (low res) collision meshes but that you can only convert the visible mesh into face col data.
What about making arbitrary low-res meshes, handling face collisions with these meshes, and giving the meshes a completely transparent texture?
http://malgolan.altervista.org/
Italian politicians - Not in my name!

lexov
Private
Posts: 6
Joined: Sun Aug 07, 2011 11:21 pm

Re: tree.klz think tank

Unread post by lexov » Sat Aug 13, 2011 4:24 am

Hm ok, or simply don't assign any material to it. That could work, indeed...

hdmaster
Sergeant
Posts: 84
Joined: Thu Jan 27, 2011 9:31 pm
Location: Germany

Re: tree.klz think tank

Unread post by hdmaster » Mon Sep 05, 2011 8:36 pm

Unfortunately i had no time to finish a tool for the .klz files yet, but it seems that there's also another way to create collisions.
It looks like H&D2 uses some .4ds files for collisions e.g. for vehicles. These collision 4ds files have exactly the same name like the normal 4ds object but also the prefix 's'. So the collision file for 'la_tiger.4ds' would be 'sla_tiger.4ds'.

User avatar
Ikaros
Sergeant
Posts: 79
Joined: Wed Mar 23, 2011 11:30 am
Location: Italy
Contact:

Re: tree.klz think tank

Unread post by Ikaros » Tue Sep 06, 2011 7:55 am

Do not worry, hdmaster! You've done so much until now and you have all the time you want, before turning again your efforts toward Hidden  :grin:

I'm currently working on RevEngEd2 and it's almost done. Afterwards, I'll can start studying max script and try to write down a "tree.klz" exporter based upon my previous idea (all faces collision and transparent textures).
http://malgolan.altervista.org/
Italian politicians - Not in my name!

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests