Author Topic: format for custom bricks?  (Read 3875 times)

How exactly do custom complex bricks work?  I tried looking at some files but I couldn't figure out how all the numbers result in a brick.

Welcome to my world, all I want to do is make a higher version of certain bricks but I've got no clue where to start.

The numbers represent coordinates which in turn represent the corners of a shape.

A brick will have 2 sets of coordinates for each face, one for collision and one for texture application.

So, take the fence brick for example....

Code: [Select]
4 1 6
SPECIAL

The numbers represent the space that the brick occupies. "Special" is the catergory name for the brick.

Code: [Select]
XXXX
XXXX
XXXX
XXXX
XXXX
dddd

X's indicate areas where bricks cannot be attached. d's indicate where the brick can be attached to from the bottom. U's indicate where bricks can be placed on top.

Code: [Select]
0 0 0
4 1 6
COVERAGE: //TBNESW
0 : 4
1 : 4
0 : 99
0 : 6
0 : 99
0 : 6

I have no loving clue what is going on in the above section. Looks like it deals with collision though.

Code: [Select]
----------------top quads:
1

TEX:SIDE
POSITION:
-2 -0.1 3
-2  0.1 3
 2  0.1 3
 2 -0.1 3
UV COORDS:
0.2 0.8
0.2 0.2
0.8 0.2
0.8 0.8
NORMALS:
0 0 1
0 0 1
0 0 1
0 0 1

Above is where you specify where vertices (or their equivalent) go. Notice that "TEX:side" is where you would indicate which texture to place on that polygon.


Admittedly what I know about bricks is sparse and I can't be stuffed to go about calculating where all the coordinates should go. We need some kind of exporter...

Ah, now that I see the divisions of things, I get a better understanding a bit.  I looked at the tree for an example of a brick with more complex illustration of were bricks can be placed, and I came up with this:
Quote
------
------
------
------
------
------
------
------
------
------
------
------
------
--XX--
-XXXX-
-XXXX-
------
------
------
------
------
------

------
------
------
------
------
------
------
--XX--
--XX--
--XX--
-XXXX-
-XXXX-
-XXXX-
-XXXX-
XXXXXX
XXXXXX
------
------
------
------
------
------

--XX--
--XX--
--XX--
--XX--
--XX--
--XX--
--XX--
-XXXX-
-XXXX-
-XXXX-
-XXXX-
-XXXX-
-XXXX-
XXXXXX
XXXXXX
XXXXXX
--XX--
--XX--
--XX--
--XX--
--XX--
--dd--

--XX--
--XX--
--XX--
--XX--
--XX--
--XX--
--XX--
-XXXX-
-XXXX-
-XXXX-
-XXXX-
-XXXX-
-XXXX-
XXXXXX
XXXXXX
XXXXXX
--XX--
--XX--
--XX--
--XX--
--XX--
--dd--

------
------
------
------
------
------
------
--XX--
--XX--
--XX--
-XXXX-
-XXXX-
-XXXX-
-XXXX-
XXXXXX
XXXXXX
------
------
------
------
------
------

------
------
------
------
------
------
------
------
------
------
------
------
------
--XX--
-XXXX-
-XXXX-
------
------
------
------
------
------
Looks as if you have to do each layer from either right to left, left to right, front to back, or back to front, and that "-" allows bricks to be in the area.

Yeah, the tree is actually a special case because few bricks use that method to that extent, most like the fence just have one "layer".

Ok, looking at the files more, I think I figured a little more out.

Quote
0
COVERAGE: //TBNESW
1 : 1
1 : 2
0 : 3
0 : 6
1 : 3
0 : 6
I think the first 0 means that it uses a .dts shape for collision.  Otherwise it defines the collision box using two sets of coordinates to define two opposite corners.  Then I think it defines the the scale of the texture scale.  Going in order of Top Bottom North East South West.

Quote
----------------top quads:
1

TEX:TOP
POSITION:
-0.5 -1 1.5
-0.5 0 1.5
0.5 0 1.5
0.5 -1 1.5
UV COORDS:
0 0
0 1
-1 1
-1 0
NORMALS:
0 0 1
0 0 1
0 0 1
0 0 1
Then going onto the next section I think it goes in this order:

First it defines a group, not sure what they're used for, but the number after that defines how many faces are in that group.  Next is the coordinates of the face according to the very center of the brick.  I'm still at a lose for what UV cords and normals are about.

Edit: Reading up on stuff, I've got that UV mapping is used for textures, and that normals are used for lighting, though I'm still now sure how either quite come into play as of yet, back to reading.

Edit: Ok, I think I got normals down, the main help has been the 1x2 ramp:
Quote
0 0.707107 0.707107
0 0.707107 0.707107
0 0.707107 0.707107
0 0.707107 0.707107
This is the normals for the ramp part, and really helped me.  I saw this number and instantly pulled out my calculator because I recognized it from trig to double check the numbers.  Since this is a 45 degree ramp, it has two different parts that effect its lighting, both of which are the same as sin45 degrees.  Looking at additional sides I have come up with this:

The first number in the series is the East (1) West (-1) control on how lighting effects.  The second is North (1) South (-1).  Lastly the third is up (1) and down (-1).  If it is a sloped section, then you use trig sin(the angle that lighting hits it from this direction) in order to determine how much lighting effects it.  The four lines are then the four verticals, possibly lighting can be gradient on round parts.

And yes, I know these are rays, but I'm using solid numbers for my figuring out.  If I make a tutorial, I'll be having images that shows rays coming of vertexes.

Edit: I think I now get how most of the numbers work, but a still need help on how UV mapping works.  Other then that I think I've got it down, perhaps with a little word from an experienced brick modeler on how UV mapping works, I think I could throw together a decent tutorial.
« Last Edit: August 05, 2008, 10:43:43 PM by laremere »

The normals define which angle and direction that face should be rendered at from the brick to the camera - it won't render a face you can't see if you're looking from behind it. This is why you can see through bricks if you use the F8 camera to go inside them.

From wiki:
Quote
Uses

    * Surface normals are essential in defining surface integrals of vector fields.
    * Surface normals are commonly used in 3D computer graphics for lighting calculations; see Lambert's cosine law.
    * Render layers containing surface normal information may be used in Digital compositing to change the apparent lighting of rendered elements.

It is used for the second one.  I did make a mistake in my post, and that was saying it was sin(, and it's really cos(.

The UV coords MIGHT be the texture offset.

I know they're for something with textures, just not how exactly they work.

Thats what they were for in GMax.

To map a texture onto a quad, every vertex is associated with a 2D point on the texture: the UV coordinaters. (0, 0) is the upper left corner, (1, 1) is the lower bottom corner. If you use values higher than 1 or lower than 0, the texture will repeat.


Now 'complicated' bricks seem to use SPECIALBRICK rather than SPECIAL.

Also, Shape FX 0 is none, 1 is Undulo and 2 seems to be Water, according to the Large Cubes file. More to come, maybe? (%brick.setShapeFX(%num);)