
I now sort of understand why Cadius uses Saftey Nets.
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 3464
- Joined: Fri, 28. Oct 05, 16:31
-
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02
Observe and I have been working on this all day off forum.
We can confirm the existence of a shape around the ship with the tests we'd done today defined by Width, Height, Length, and an X, Y, Z center. We're sure this represents the collision data people are looking for with regards to collision avoidance behaving oddly with custom ships.
We're also somewhat confident, of the existence of a sphere in the same line defined by a diameter and an X, Y, Z center. Through several tests, we cannot see any result of ship behaviour changing with relation to changing the sphere values. We don't know what the sphere is used for, but we know it's a sphere, and reproducing vanilla values can be done using our methods.
Here's what we think:
http://members.shaw.ca/litcube/X3/Scree ... Values.JPG
The RAW row represents what the bod and bob will ultimately contain in terms of collision data (This is what should be in your file). It will look like this in your bod:
/! PART_VALUES_RAW: 30; -3289; -13779; 65439; 0; 4278; -6929; 7471; 16896; 58606; !/
-99; 00000000000000000001; // end of part
-99; 0000000000000000; // end of body
POINT and FLOAT data are just translations by DoubleShadow, in case anyone wanted to pick up the torch in figuring this stuff out. They're all equal to each other. For example a float value of 1 is equal to 65536.
There's two shapes. A sphere in the first 4 columns. The last 6 columns represent another shape. For all intents and purposes, this shape can be assumed to be a box.
All of the values in the last row are derived from the float values, and multiplying them by either the Y of the main bod (on the right), or the "BodSize" (on the right).
Y of the Main Bod: When you open 3DS max, and select the main model, and open object properties, you'll see the dimentions of the object. It refers to the Y you see there.
BodSize: Before first body in the bod file, is a value that represents the size of the object. For the cerberus, do a search for 401434 to see what I mean.
For our tests, we got all X, Y, Z for each shape by multiplying the float by the "BodSize", and the dimensions of the shapes (Sphere Diameter, Box Width, Height, Length) by multiplying the float by the Y value of the ship itself. It could still be that only one of either BodSize or Y is used to arrive at all 10 values, but the way we did it represented a visually more appropriate collision box when drawn in 3ds Max using those exact values.
As a simple example, if you know that your ship is as wide as 20% of length, and as tall as as 45% the length, and your ship is symmetrical from a, x and y standpoint, your line will look thus:
/! PART_VALUES_RAW: 0; 0; 0; 65536; 0; 0; 0; 13107; 29491; 65536; !/
65536 represents 100%, or 1. Most Spherical diameter values we see are also larger than the Y length by about 5% to 10%. Offsets are used to cover areas that stick out past the pivot of the main model, like the Cerberus, Panther, etc.
Folks, if your custom ship doesn't have this information, it's broken. It will act weirdly with collisions. There is some default collision avoidance by some unknown method if you do not have this info, but it doesn't pass muster. It is broken.
We can confirm the existence of a shape around the ship with the tests we'd done today defined by Width, Height, Length, and an X, Y, Z center. We're sure this represents the collision data people are looking for with regards to collision avoidance behaving oddly with custom ships.
We're also somewhat confident, of the existence of a sphere in the same line defined by a diameter and an X, Y, Z center. Through several tests, we cannot see any result of ship behaviour changing with relation to changing the sphere values. We don't know what the sphere is used for, but we know it's a sphere, and reproducing vanilla values can be done using our methods.
Here's what we think:
http://members.shaw.ca/litcube/X3/Scree ... Values.JPG
The RAW row represents what the bod and bob will ultimately contain in terms of collision data (This is what should be in your file). It will look like this in your bod:
/! PART_VALUES_RAW: 30; -3289; -13779; 65439; 0; 4278; -6929; 7471; 16896; 58606; !/
-99; 00000000000000000001; // end of part
-99; 0000000000000000; // end of body
POINT and FLOAT data are just translations by DoubleShadow, in case anyone wanted to pick up the torch in figuring this stuff out. They're all equal to each other. For example a float value of 1 is equal to 65536.
There's two shapes. A sphere in the first 4 columns. The last 6 columns represent another shape. For all intents and purposes, this shape can be assumed to be a box.
All of the values in the last row are derived from the float values, and multiplying them by either the Y of the main bod (on the right), or the "BodSize" (on the right).
Y of the Main Bod: When you open 3DS max, and select the main model, and open object properties, you'll see the dimentions of the object. It refers to the Y you see there.
BodSize: Before first body in the bod file, is a value that represents the size of the object. For the cerberus, do a search for 401434 to see what I mean.
For our tests, we got all X, Y, Z for each shape by multiplying the float by the "BodSize", and the dimensions of the shapes (Sphere Diameter, Box Width, Height, Length) by multiplying the float by the Y value of the ship itself. It could still be that only one of either BodSize or Y is used to arrive at all 10 values, but the way we did it represented a visually more appropriate collision box when drawn in 3ds Max using those exact values.
As a simple example, if you know that your ship is as wide as 20% of length, and as tall as as 45% the length, and your ship is symmetrical from a, x and y standpoint, your line will look thus:
/! PART_VALUES_RAW: 0; 0; 0; 65536; 0; 0; 0; 13107; 29491; 65536; !/
65536 represents 100%, or 1. Most Spherical diameter values we see are also larger than the Y length by about 5% to 10%. Offsets are used to cover areas that stick out past the pivot of the main model, like the Cerberus, Panther, etc.
Folks, if your custom ship doesn't have this information, it's broken. It will act weirdly with collisions. There is some default collision avoidance by some unknown method if you do not have this info, but it doesn't pass muster. It is broken.
-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
Just to emphasis for clarity:
All custom models exported via DBOX are currently missing the bounding-box collision avoidance object reference in the exported .bod file.
This means custom models will suffer from other ships crashing into them at a much higher rate than Egosoft ships.
Therefore, best add that PART_VALUES_RAW line for each of your LOD meshes. At minimum, all 10 values can be zero except the last 3 which define the bounding-box.
All custom models exported via DBOX are currently missing the bounding-box collision avoidance object reference in the exported .bod file.
This means custom models will suffer from other ships crashing into them at a much higher rate than Egosoft ships.
Therefore, best add that PART_VALUES_RAW line for each of your LOD meshes. At minimum, all 10 values can be zero except the last 3 which define the bounding-box.
-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
Here is basic information so you can understand how to create the collision avoidance bounding box using Argon M1 as example:
- Import Argon M1 into 3DS
- Open Argon M1 bod file in text editor
- Find first occurance of text: PART_VALUES_RAW
- Copy that line, and replace in the following:
The above is a simple box mesh in .bod format.
- Change the values in the 3 columns in the vertices section to match the last 3 values in the PART_VALUES_RAW line as shown.
- Save that as collision_box.bod (or some such)
- Now import collision_box.bod into 3DS.
- You should see a box surrounding the Argon M1 mesh:
[ external image ]
That is the bounding box used for collision avoidance.
Obviously you can reverse the process. For example:
- Select your custom ship in 3DS, and right-click Properties. You will see a section indicating the mesh box size:
[ external image ]
- Make a box having the x,y,z dimensions indicated. You will see a box outlining your ship.
- Convert your box to poly (or mesh), Reset Pivot Points, Set x,y,z to zero (World Center), Reset Xform, Collapse Modifier Stack, and export to collision_box.bod
- Open collision_box.bod in text editor.
- Create the PART_VALUES_RAW line in reverse of described above. All values can be zerio except those last three defining the bounding box.
- Paste that line into the end of each LOD in your ship/model in the location shown by the box example.
- Convert your ship to binary (.bob)
Your ship will now possess superior collision avoidance.
[EDIT] It is also possible to do this without opening 3DS, but the method described should suffice in the meantime. Ultimately DBOX should be updated so the proces can be automatic.
- Import Argon M1 into 3DS
- Open Argon M1 bod file in text editor
- Find first occurance of text: PART_VALUES_RAW
- Copy that line, and replace in the following:
Code: Select all
/# Exported with dbox2 1.11 at 3/7/2011 5:47:52 PM
540844; // body size
// vertices (8)
-10496; -21334; -65536; // 0
10496; -21334; -65536; // 1
-10496; -21334; 65536; // 2
10496; -21334; 65536; // 3
-10496; 21334; -65536; // 4
10496; 21334; -65536; // 5
-10496; 21334; 65536; // 6
10496; 21334; 65536; // 7
-1; -1; -1; // end of verts
// ----- part Box01 (12 faces) -----
0; 3; 2; 0; -25; 2; 0.000000; 0.000000; 1.000000; 0.000000; 1.000000; 1.000000; /! N: 0.000000; -1.000000; 0.000000; !/ // 0
0; 0; 1; 3; -25; 2; 1.000000; 1.000000; 0.000000; 1.000000; 0.000000; 0.000000; /! N: 0.000000; -1.000000; 0.000000; !/ // 1
0; 7; 5; 4; -25; 4; 1.000000; 0.000000; 1.000000; 1.000000; 0.000000; 1.000000; /! N: 0.000000; 1.000000; 0.000000; !/ // 2
0; 4; 6; 7; -25; 4; 0.000000; 1.000000; 0.000000; 0.000000; 1.000000; 0.000000; /! N: 0.000000; 1.000000; 0.000000; !/ // 3
0; 5; 1; 0; -25; 8; 1.000000; 0.000000; 1.000000; 1.000000; 0.000000; 1.000000; /! N: 0.000000; 0.000000; -1.000000; !/ // 4
0; 0; 4; 5; -25; 8; 0.000000; 1.000000; 0.000000; 0.000000; 1.000000; 0.000000; /! N: 0.000000; 0.000000; -1.000000; !/ // 5
0; 7; 3; 1; -25; 16; 1.000000; 0.000000; 1.000000; 1.000000; 0.000000; 1.000000; /! N: 1.000000; 0.000000; 0.000000; !/ // 6
0; 1; 5; 7; -25; 16; 0.000000; 1.000000; 0.000000; 0.000000; 1.000000; 0.000000; /! N: 1.000000; 0.000000; 0.000000; !/ // 7
0; 6; 2; 3; -25; 32; 1.000000; 0.000000; 1.000000; 1.000000; 0.000000; 1.000000; /! N: 0.000000; 0.000000; 1.000000; !/ // 8
0; 3; 7; 6; -25; 32; 0.000000; 1.000000; 0.000000; 0.000000; 1.000000; 0.000000; /! N: 0.000000; 0.000000; 1.000000; !/ // 9
0; 4; 0; 2; -25; 64; 1.000000; 0.000000; 1.000000; 1.000000; 0.000000; 1.000000; /! N: -1.000000; 0.000000; 0.000000; !/ // 10
0; 2; 6; 4; -25; 64; 0.000000; 1.000000; 0.000000; 0.000000; 1.000000; 0.000000; /! N: -1.000000; 0.000000; 0.000000; !/ // 11
/! PART_VALUES_RAW: 1; -6018; -5963; 71499; 0; 0; 0; 10496; 21334; 65536; !/
-99; 00000000000000000001; // end of part
-99; 0000000000000000; // end of body
- Change the values in the 3 columns in the vertices section to match the last 3 values in the PART_VALUES_RAW line as shown.
- Save that as collision_box.bod (or some such)
- Now import collision_box.bod into 3DS.
- You should see a box surrounding the Argon M1 mesh:
[ external image ]
That is the bounding box used for collision avoidance.
Obviously you can reverse the process. For example:
- Select your custom ship in 3DS, and right-click Properties. You will see a section indicating the mesh box size:
[ external image ]
- Make a box having the x,y,z dimensions indicated. You will see a box outlining your ship.
- Convert your box to poly (or mesh), Reset Pivot Points, Set x,y,z to zero (World Center), Reset Xform, Collapse Modifier Stack, and export to collision_box.bod
- Open collision_box.bod in text editor.
- Create the PART_VALUES_RAW line in reverse of described above. All values can be zerio except those last three defining the bounding box.
- Paste that line into the end of each LOD in your ship/model in the location shown by the box example.
- Convert your ship to binary (.bob)
Your ship will now possess superior collision avoidance.
[EDIT] It is also possible to do this without opening 3DS, but the method described should suffice in the meantime. Ultimately DBOX should be updated so the proces can be automatic.
Last edited by Observe on Tue, 8. Mar 11, 13:55, edited 1 time in total.
-
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02
I've finished the DBOX patch, but as we don't have permission to mung doubleshadow's code, I'm going to post only my code and show you how to modify your install yourself. There's three snippets.
Before we get to those, what the code does, is fill the PART_VALUE_RAW line that's missing from DBOX1.11 written bods. The line represents exactly the findings that Observe and I have come up with in this post, including offsets, sphere, and box dimensions. It does this line for all LODs, using the largest x or y or z value of of the main body as the ratio benchmark.
On to the snippets.
The first goes in bod_body_writer.ms at line 546:
Snippet 1
To know you're in the right place, the lines above 546 and below 546 are:
Snippet 2
This goes at nearly the very end of bod_body_writer.ms. Go to the very end. From the bottom up, you'll see:
post this right ABOVE return true;
Snippet 3
Open globals.ms
Paste this as line 2:
Before we get to those, what the code does, is fill the PART_VALUE_RAW line that's missing from DBOX1.11 written bods. The line represents exactly the findings that Observe and I have come up with in this post, including offsets, sphere, and box dimensions. It does this line for all LODs, using the largest x or y or z value of of the main body as the ratio benchmark.
On to the snippets.
The first goes in bod_body_writer.ms at line 546:
Snippet 1
Code: Select all
local xs, zs, ys, d, xb, zb, yb, w, h, l
boxnode = (node.max - node.min)
w = boxnode[1]
l = boxnode[2]
h = boxnode[3]
if largest == -99 then
(
if (l > largest) then largest = l
if (w > largest) then largest = w
if (h > largest) then largest = h
)
l = (l / largest) * 65536
w = (w / largest) * 65536
h = (h / largest) * 65536
xb = (node.center[1] / largest) * 65536
yb = (node.center[2] / largest) * 65536
zb = (node.center[3] / largest) * 65536
xs = xb
ys = yb
zs = zb
d = (largest / largest) * 65536
d = d * 1.1
format "/! PART_VALUES_RAW: %; %; %; %; %; %; %; %; %; %; !/%" (xs) (zs) (ys) (d) (xb) (zb) (yb) (w) (h) (l) os.newline to:os.stream
Code: Select all
)
format "-99; %; // end of part%" (bitArrayToString flags) os.newline to:os.stream
Snippet 2
This goes at nearly the very end of bod_body_writer.ms. Go to the very end. From the bottom up, you'll see:
Code: Select all
return true;
)
)
post this right ABOVE return true;
Code: Select all
largest = -99
Snippet 3
Open globals.ms
Paste this as line 2:
Code: Select all
global largest = -99
-
- Posts: 583
- Joined: Sat, 23. Feb 08, 12:38
-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
Yes, X3-R has the same problem. All custom models produced by DBOX for X3 are missing the collision avoidance bounding box.Zeron-mk7 wrote:Sorry to ask, but in the X3 Reunion are the same collision avoidance with new custom ship models or not ?
@Litcube: Good work on the Maxscript code!

Now we know the purpose of these values we need to inform Doubleshadow.
[EDIT] Posted reference in DBOX thread for Doubleshadow attention.
-
- Posts: 671
- Joined: Fri, 12. Mar 04, 08:14
Observe wrote: [EDIT] Posted reference in DBOX thread for Doubleshadow attention.
No need to. You have my undying attention from the very morning of this fine day - Litcube send me PM once he wrote the patch.
I made my little revenge for his Excel TShips by not using the patch

To everyone:
I've made all the necessary changes and once proven working, it will be released.
Yeah and HI EVERYONE, long time no see

-
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02
-
- Posts: 2035
- Joined: Wed, 18. Aug 10, 14:28
-
- Posts: 3464
- Joined: Fri, 28. Oct 05, 16:31
-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
-
- Posts: 3464
- Joined: Fri, 28. Oct 05, 16:31
Indeed. Just the worst possible time for me being the last few weeks of uniObserve wrote:Think of it as an opportunity to make all those improvements you've wanted to do but never had time.killerog wrote:Really not looking forward to re exporting all my X2/KOG and transcend ships. Going to be a long couple of nights I think.


-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
@Observe, heh fair call 
Thou I am still some what disappointed at x using spheres and rotated boxes
(I didn't think it was ellipsoids... fighters always turned too soon on the sides of capies and too late at the front/back)
Capsules capsules capsules!!! no trig functions required!
(The better question is... am I sufficiently disappointed enough to re-attempt int->float float -> capsule collision? 60/40?)

Thou I am still some what disappointed at x using spheres and rotated boxes

(I didn't think it was ellipsoids... fighters always turned too soon on the sides of capies and too late at the front/back)
Capsules capsules capsules!!! no trig functions required!
(The better question is... am I sufficiently disappointed enough to re-attempt int->float float -> capsule collision? 60/40?)
-
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02
-
- Posts: 5333
- Joined: Fri, 30. Dec 05, 17:47
The last thing I am is a math expert, so yes s9silent, please pursue this further if you have any other ideas whatsoever.Litcube wrote:I'm hazarding a beating here, because I do consider you the resident Math expert, s9ilent, but how would one transport axis on a capsule shape without using trig? Could we start another thread? I promise I'll post in it!s9ilent wrote: Capsules capsules capsules!!! no trig functions required!
