I now sort of understand why Cadius uses Saftey Nets.

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
killerog
Posts: 2581
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Tue, 8. Mar 11, 01:42

Yep I have been looking at this thread constantly with my Beady little eyes :D
Image

User avatar
Litcube
Posts: 4244
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Tue, 8. Mar 11, 02:51

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.

User avatar
Observe
Posts: 2760
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Tue, 8. Mar 11, 03:25

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.

User avatar
Observe
Posts: 2760
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Tue, 8. Mar 11, 04:44

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:

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
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:

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:

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, 14:55, edited 1 time in total.

User avatar
Litcube
Posts: 4244
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Tue, 8. Mar 11, 08:21

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

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
To know you're in the right place, the lines above 546 and below 546 are:

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

User avatar
Zeron-mk7
Posts: 522
Joined: Sat, 23. Feb 08, 13:38
x3

Post by Zeron-mk7 » Tue, 8. Mar 11, 08:36

Sorry to ask, but in the X3 Reunion are the same collision avoidance with new custom ship models or not ?
Image

User avatar
Observe
Posts: 2760
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Tue, 8. Mar 11, 14:12

Zeron-mk7 wrote:Sorry to ask, but in the X3 Reunion are the same collision avoidance with new custom ship models or not ?
Yes, X3-R has the same problem. All custom models produced by DBOX for X3 are missing the collision avoidance bounding box.

@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.

doubleshadow
Posts: 671
Joined: Fri, 12. Mar 04, 09:14
x3

Post by doubleshadow » Tue, 8. Mar 11, 17:42

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 :P

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 :)

User avatar
Litcube
Posts: 4244
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Tue, 8. Mar 11, 18:31

doubleshadow wrote:
I made my little revenge for his Excel TShips by not using the patch :P

Hah! Hey, when I wrote that X Editor 2 was a tool we all loved, it wasn't sarcasm! :) We all love it.

doubleshadow wrote:Yeah and HI EVERYONE, long time no see :)

Hi!

User avatar
TrixX
Posts: 2022
Joined: Wed, 18. Aug 10, 14:28
x3tc

Post by TrixX » Tue, 8. Mar 11, 18:33

Good to see you about Doubleshadow :)
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson

killerog
Posts: 2581
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Tue, 8. Mar 11, 18:40

Hellos Doubleshadow !

Really not looking forward to re exporting all my X2/KOG and transcend ships. Going to be a long couple of nights I think.
Image

User avatar
Litcube
Posts: 4244
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Tue, 8. Mar 11, 18:55

Not that he needs it, but it should be recognized that without Killjaeden's awesome pioneer work, it would have been very difficult to come to any conclusions.

User avatar
Observe
Posts: 2760
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Tue, 8. Mar 11, 19:21

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.
Think of it as an opportunity to make all those improvements you've wanted to do but never had time. :wink:

killerog
Posts: 2581
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Wed, 9. Mar 11, 01:58

Observe wrote:
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.
Think of it as an opportunity to make all those improvements you've wanted to do but never had time. :wink:
Indeed. Just the worst possible time for me being the last few weeks of uni :(
Image

User avatar
Observe
Posts: 2760
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Wed, 9. Mar 11, 02:56

killerog wrote:Indeed. Just the worst possible time for me being the last few weeks of uni :(
Don't worry about it. There's no hurry really. We've all been operating with broken collision avoidance since X3 came out, so another few weeks or whatever makes no difference. :)

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”