123do: Creation of a cube with and without collision box

From Grand Prix Legends Wiki
Revision as of 20:01, 22 April 2009 by Bernd Nowak (Talk | contribs) (Text replace - 'gplmz.bcsims.com' to 'srmz.net')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

One-Two-3DO (also known as 123do)

One-Two-3DO or in short 123do let's you create 3DO objects for GPL. You can get it here: [Link to One-Two-3DO].

It runs fine here for me with Windows Vista 64 bit with an Nvidia 8800GTS. Only thing which had to be changed is to "Disable desktop composition for the OneTwo3DO.exe like you can see in this screenshot

Vista Compability Settings

When you start 123do you will see a window like this:


Now you must understand that you need points (vertices) to attach polygons and lines on them.

The unit measurement 123DO used is in metres. Thanks to Ginetto here's a translation formula:

1 metre = 3.28083 feet = 39.36996 inches

Let's create a simple 3DO cube

Background vertices

First, here's a generic picture of the 3D room and how the vertices are positioned for a cube. This picture shall tell you a bit about the positioning of vertices in GPL.

3DO Room

I have numbered the vertics we need for a cube from 0 to 7. Like a real cube the cube in 3DO has 8 corners. You may ask yourself why I start counting the vertices at 0. 123do and GPL use a different approach for counting. The first element is 0 instead of 1 we're using outside in the real world.

If I want to create a 3DO cube with a dimension of 1 metre for every side of the cube I need to create those 8 vertics:

vertics index	x	y	z

0		1	0	0
1		1	1	0
2		0	1	0
3		0	0	0
4		1	0	1
5		1	1	1
6		0	1	1
7		0	0	1

You need those vertics as points for polygons or lines. Without those vertics you can not assign a polygon or a line to it.

Here's a picture to display an idea how it works for a simple polygon:

Attaching a polygon to vertices

The edges of the polygon are attached to the vertices.

Adding vertices

Now this should be enough for the basics of vertices and polygons. Let's get back to the open 123do program and transfer what you have read above to the real cube.

To add the vertics to 123do open the Create/Add vertices manually from here:

Create/Add vertices

You should then see this window, showing you defined vertices on the left side and the possibilities to add/edit/remove vertices on the right. I have filled in the values of vertic 0. Remember from the background section Background about vertices the matrix about the 8 needed vertices.

Create/Add vertices window

Now in the next image you see I have filled in all needed vertices for our test cube.

8 vertices added

Close the dialog and choose File/Save project. Make it easy and give it the name of the 3DO you wish to have. Please use 8.3 syntax naming the project. In my example I use cube like you can see from the attached picture:

Save project

Adding Textures


Now it's time to think about the cube, vertices, polygones and what we will see in GPL. To the cube in GPL it needs to have some bitmaps painted on the sides. You recall that the sides are build out of polygons. If I only create the polygons in 123do and attach no texture to it you would have an object like this in GPL:

Untextured cube in 3D

A 3D object without any meaning. Not even as an object nice to stop shortcutting.

Here're the textures I made for our cube. Due to display limitation I have uploaded the file 123docubetextures.zip which contains the follwoing bmp files:


Remember I mentioned that 123do only uses bmp files and a 3DO object in GPL uses mip files. Where's the logic behind this ?

For creating the 3DO object in 123do it's much simpler to use only bmp files because you can reload the textures without the need to edit the picture first and then create/update the mip file every time. When the 3DO will be created only the first part of the 8.3 filename will be stored in the 3DO file.


Use bmp filenames with the 8.3 name schema.

Good filename => "cubebo.bmp" Bad filename => "cubebottom.bmp"

So use only 8.3 name schema and don't use blanks in the filename.

Another limitation is the size of the texture.

Read this quote carefully: Using mips with size, in pixels, which are 512x256 or bigger will not work on 3Dfx graphic cards because they simply don't support textures bigger than 256x256. So keep this in mind.

The size always has to be the power of 2 for a mip to work, here are the most common sizes: 256x256, 256x128, 256x64, 256x32, 256x16,128x256, 128x128, 128x64, 128x32, 128x16, 64x256, 64x128, 64x64...and so on. Any deviation from these sizes, and the mip tools won't work, or if you should manage it anyway, you'll get the dreaded 'Could Not Load Track' error in GPL.

There is a catch - the bigger textures you use, the more energy they suck out of your gfx card, and frame rate drops. For instance, if you're making a wall, try not to use one huge mip, but rater small, repeating ones, using bump-mapped textures. More on this later. But using a small texture will look bad when close-up because it gets pixellated, there is too little detail. This is something we just have to live with in these days. Not quite real-life just yet!

So create your own BMP files and remember naming schema and filesize or use the ones from here 123docubetextures.zip, download them and unzip them to the directory where you stored your cube.3dp project. There's also a lot to say about color depth as well as transparency as well as a lot of other interesting things. We will cover MIP files here: GPL Mip Files.

Adding them in 123do

To get the textures into 123do use the Load & Save Textures button like you can see here:

Press the Load & Save Texture(s) button

Now you can load the textures (bmp files) like you see in this window:

Load & Save Texture(s) window

You should have used 'speaking' names or have made some notices which texture is for what side of the cube.


Adding Polygons


You have a bunch of vertices which will be used to tie the polygons to it. A vertix can be used more than one time otherwise you need a lot more vertices. But if you imagine a polygon filled with a texture the texture has a view directon. Guru refers to this view directon as PLANE. Here's a picture to show you both cases with a polygon and a texture attached to it. The white arrow is given you the PLANE direction when you create polygons clockwise:

Clockwise definition of a polygon

We want to add a collision box later so all polygons should be clockwise. If you have problems assigning the vertices to polygons and then even to now if it's clockwise or not take a bit of paper and pencil. It's important to lay out the X and y direction right. Otherwise you will guess whats left, right, front or back.


Creating the polygons in 123do

Now we come to the hardest part of it. We need to add the polygons. When adding the polygons, the sequenz how you add the vertics will be critical from where your polygon will display an attached texture (bmp in 123do and as a mip in GPL). Remember the PLANE section.

I made some additional picture to maybe help you a bit more. Please take your time.

Vertices to polygons

If we add the vertices 0,3,2,1 in that sequenz you can see from the picture above that this is the bottom of the cube. 0,3,2,1 would be clockwise. This would result in a plane pointing in your direction which would mean that you can see the image. 0,1,2,3 would be anti-clockwise. This would result in a plane pointing away from you which would mean that you can't see the image. Ok, it's the bottom and there's nothing to see but I'm a german :)

Please select the Create Polygons button:

Create Polygons button

Next image is the Create polygon(s) window. Please select the Flat Shading button from the Add Polygon group.

Create/modify Polygons

Please select No when the programs offer you to pick the vertices by mouse. If you do more 3DOs it might be handy but for this tutorial we will add them from a dropdown menu.

Now you should see the Manual Vertex selection. Most of the time it's crippled the first time I open it. Just resize it.

Create/modify Polygons

Now select the vertice for one polygon and choose Add vertex for 4 vertices. After you have added 4 vertices select Close polygon. With this list:

3,7,4,0 = front
6,7,3,2 = left
0,4,5,1 = right
1,5,6,2 = back
4,7,6,5 = top
0,1,2,3 = bottom

It should look like this:

Polygons added

If you have done a mistake you can remove the selected polygon or edit it.

IMPORTANT: Save your project now !


Assigning polygons to textures

After we have created the polygons we can assign the textures to them. To do so choose the Assign texture(s) button.

Assign Texture(s) button

In the Assign Texture(s) window it's easy to be confused. For our cube project the handling is easy. You see the created polygons as well as some other stuff.

From the list above which I will repeat here:

3,7,4,0 = front
6,7,3,2 = left
0,4,5,1 = right
1,5,6,2 = back
4,7,6,5 = top
0,1,2,3 = bottom

the polygons to sides relation should be:

Polygon No. 0 =>front
Polygon No. 1 =>left
Polygon No. 2 =>right
Polygon No. 3 =>back
Polygon No. 4 =>top
Polygon No. 5 =>bottom

Now select a polygon in the Available Polygon's list and choose the texture for it. Do this for every polygon. But be aware to choose a polygon and then assign the texture. Saves you some work.

Assign polygon to texture

When you have assigned all textures to polygons select Close and save your project.

Rotating assigned textures

Now you should see something like this in 123do:

Textured cube

We should now check if the textures have to be rotated. Mine had to. Let's point your mouse in the draw aera and use the right mouse buttom (context menu). Select Front. After the refresh again use the right mouse buttom and select now Zoom All. Do this for every important side, in this case of this cube I would test Front, Left, Right and Back as Top and Bottom are not so important.

In my cube the Left texture must be rotated:

Left rotated

This is very quick to resolve. Select the Assign texture(s) function and select polygon no. 1. Use the rotate button. You can see the result on the fly. Do this for all interesting sides until you're happy.

Rotate the texture

IMPORTANT: Save your project now !

Create the 3DO file

Now after you're happy with your cube you need to export it to be able to use it for your track. This is very simple. Select File/Write ASE file/Write ASE and convert to 3DO. You have created your 3DO cube.

Create 3DO

Now you want to see it in action

Creating the need MIP files

At this point you still have the 3DP file as well as the exported 3DO file called cube.3DO if you have choosen to follow the tutorial. The exported 3DO has the textures stored without file extension because it assumes it must be MIP (need to ask for this. I think it can be a srb too ???).

I use the program WINMIP from Klaus Hörbrand for this tutorial. You can get your copy of it here: [http://www.horbra.de/winmip/Winmip2.htm].

Download the program and unzip it to a folder of your choice. Start it. Make sure that GPL is selected. See this image here:

Select GPL in WINMIP

Next select File/Open and switch from mip to bmp and load your first BMP file (the texture you loaded in 123do and assigned to a polygon.

Change mip to bmp

Now that the bmp has opened you can easily change it to a mip file by selecting this dropdown:

Change bmp to mip type

Next select the typ and mapping. We use no transparent effects and we want the texture be filled/stretched accross the whole polygon so we choose typ 3 and mapping 3.

Here's a short list of types and mappings:

0 - Has Palette, Opaque, R8, G8, B8, A8 . NB the 8 alpha bits are unused.
1 - Has Palette, Transparent, R8, G8, B8, A8. NB the only values used in alpha should by 255 (opaque) and 0 (transparent)
2 - Has Palette, Semi-Transparent, R8, G8, B8, A8
3 - No Palette, Opaque, R5, G6, B5, A0
4 - No Palette, Transparent, R5, G5, B5, A1
5 - No Palette, Semi-Transparent, R4, G4, B4, A4
7 - No Palette, Semi-Transparent, R8, G8, B8, A8
(Type 7 is only supported with Nigel's new rasterisers, the original rasterizers had only partial support for it.
Type 6 does exist, but again the support in the original rasterizers was incomplete, and the code for it in Nigel's new rasterizers is wrong.
Taken from here: [[http://srmz.net/index.php?s=&showtopic=4047&view=findpost&p=29324 Nigel's answer]]

0 - repeat vertical and horizontal
1 - repeat vertical , strech horizontal
2 - repeat horizontal, strech vertical 
3 - strech vertical and horizontal

As for an example it would have been enough if the BMPs would be in 4bit color depth. Then you should use typ 0 with mapping 3. Unfortunatly Paint.NET saves BMP files with the lowest as 8 bit.

Here's a picture of the settings for cubeba.bmp or better cubeba.mip:

Change bmp to mip and mip settings

Only step left for cubeba.bmp is to save the mip file in WINMIP. When you select the Save button a dialog will pop-up and ask you if you want to save the file as cubeba.mip. Do so because in your cube.3DO the string is named cubeba.

Confirm MIP name

Do so for all 5 remaining bitmaps. You now have a 3DO file called cube.3DO as well as 6 mip files called cubeXX.mip

When you're finished it's time to open your track.TSO file and added the cube object. Here's my mytrack.TSO:

# additional track objects
obj 3 20.0 -6.0 0 0 0 0 1 cube
obj 3 1.6 -6.0 0 0 0 0 1 bm150m
obj 3 51.6 -6.0 0 0 0 0 1 bm100m
obj 3 566.3 -6.0 0 0 0 0 1 bm150m
obj 3 616.3 -6.0 0 0 0 0 1 bm100m
obj 3 145.8 7.0 0 0 0 0 1 flagger
obj 3 661.3 7.0 0 0 0 0 1 flagger

It tells trk23doz (See:Editors Compile Section) to add this object 20 metres behind SF line 6 metres on the right with no rotation and with z=0. The 3DO name is cube(.3DO). Like in the cube.3DO file the textures aren't stored with the complete filename in the track.3DO file the external 3DO files are also only stored with the name and not the extension.

Compile the track and test it. See if your textures are the way you wanted them and text if you can drive through.

Adding the collison box

You have tried it ? Every texture is where it should be ?

Have you tried driving against it ?

You can drive through. It's a cube without any collision box attached to it. If you had made everything like I did and have followed the guidelines about clockwise vertices creating the polygons this is easy.

Start 123do and load your project called cube.3dp. Select Misc/Set Collison Type:

Add collsion to your cube

You will see a window where you can see defined collision boxes as well as the type of the collision. Currently we have none.

Collisions Volumes

Since we want to add one simply select the Add Volume button. Select all polygons and set the type, in my case I think Armco is nice and then select the Add button.

Add Collisions Volume and typ

You should now this window.

Collision Volume assigned

Select Close.

A good time to SAVE YOUR PROJECT!!!

Now you must only export the 3DO Create the 3DO file and start GPL and test if the cube is now a solid cube. If it is, well done. If not ask at the [SMRZ] for help.

Remeber you don't need to recompile the track.3DO. If you change the mip files and work on your textures you don't need to compile/export with 123do or to recompile the track.