Thursday, 10. April 2008 18:36
Heya,
just want to write some words about my current project.
To learn torque, Frank Geppert from Dexsoft-Games and i are creating a virtual museum. You will be able to run around in different themes and place your own images on your virtual picture frames, add a text to the frame and adjust the size of it.
When i first was thinking about methods to create this project (code based), it sounded quite easy to manage. To my surprise, it was easier than i thought.
Until now i can say that 60% of the base code are done. I can move around, place frames, open a GUI with a list of available pictures and draw them on my frames. The list for the pictures is generated automatically by searching the folders for the necessary files.
The skin system for the frames is also quite easy. You just have to give the different skins a special name. Just let me give you an example.
Imagine you have your frame model called “frame.dts”. Then you have to assign a texture to the model which is called “base.frame.png”. The other skins you want to apply to your frame can have any name you want plus the “frame.png” at the end. So you can create images like “skin0.frame.png”, “skin1.frame.png”, “anotherpic.frame.png” and so on. The engine will recognize the “frame.png” and assign it to the “frame.dts” file.
To actually change the skin now, you use the function “%obj.setSkinName(’skinname_without_frame.png’);” and that’s it! If you want to apply skin1 to the model, you would write “%obj.setSkinName(skin1);” and the skin will be changed.
So to make the engine recognize the textures, you need to create a “materials.cs” file in the same folder. Just define the texture inside and you are done!
materials.cs
new Material(base_frame)
{
baseTex[0] = "base.frame";
};
new Material(skin0_frame)
{
baseTex[0] = "skin0.frame;
};
new Material(skin1_frame)
{
baseTex[0] = "skin1.frame";
};
Easy, isn’t it?
So to display all available skin for the frame, i search for “./*.frame.png”. It will list all images that ends with “.frame.png” in the GUI i created.
If i have something visually to show, i will post some shots of course.
See ya next time!