SA-MP Forums

Go Back   SA-MP Forums > SA-MP DL Edition > SA-MP 0.3.DL

Reply
 
Thread Tools Display Modes
Old 24/10/2017, 10:40 AM   #1
Kalcor
SA-MP Developer
 
Join Date: Apr 2005
Location: 846
Posts: 850
Reputation: 2617
Post Basics of exporting from blender to SA-MP

The main export tools for GTA:SA are written for 3dsmax. But if you're like me and don't model professionally, the cost of 3dsmax can be a bit much.

Blender is a free modeling program with importers and exporters for many different games, including GTA:SA.

Tools needed:
- blender 2.63+
- gtatools blender scripts by ponz
- TXD Workshop by TurtleL
- kdff.exe command line tool (comes with the SA-MP server package)
- Collision File Editor II 0.4 BETA

Instructions for getting started.
- Download and install blender. Check that it runs.
- Extract the gtatools scripts in to your blender addons folder e.g. C:\blender-2.71-windows64\2.71\scripts\addons. You should then have a "space_view3d_gta_tools" folder in your blender addons folder.
- Enable GTA tools in blender by going to File > User Preferences > Addons > and checking 3D View: GTA Tools.

We'll be exporting blender's default cube as a dff with a collision attached.

Find a texture for the cube. Open a txd material in TXD workshop and export it to something blender can read like bmp or png.



Step 01) Open up blender.



Step 02) Game engines use triangles to render, but modeling programs support different types of edges like quads (squares). We need to triangulate the cube's faces so it can be exported to the game.

02_triangulate_cube.mp4

Step 03) Create a UV map by running UV unwrap and apply the texture we exported earlier.

03_add_cube_texture.mp4

Step 04) Make sure the material name in blender matches the material name in our txd file.

04_change_material_to_txdmatname.mp4

Step 05) Export the cube as a dff and we'll attach a collision. I named my cube as testcube1.dff.

05_export_cube.mp4

Now we need to use the kdff.exe tool in the server package to generate a collision (.col file) then attach the collision to the dff. Copy the kdff.exe tool to the folder where you are exporting your models, then open a command prompt, cd to that folder, then run kdff on your dff file. Example:

Quote:
c:\>cd c:\gtasa\03server\models\modeling
c:\gtasa\03server\models\modeling>kdff.exe -g box -d testcube1.dff -o testcube1.col
In the above command, we used kdff to generate a simple box collision for our testcube. Now we should attach this collision to the dff file.

Quote:
c:\gtasa\03server\models\modeling>kdff.exe -a -d testcube1.dff -c testcube1.col -o testcubeC.dff
At this point, our final model file testcubeC.dff is ready. We just need to make sure our texture is in wallzzz.txd and has the correct material name. We could load this in to the artconfig.txt and spawn it with /crobj.

Quote:
artconfig line: AddSimpleModel(-1,19379, -2001, "testcubeC.dff", "wallzzz.txd");
If we spawn it like this it'll look dull because we did not apply any lighting. Everything in GTA is prelit, that means the lighting information is embedded in the dff. We should apply some vertex lighting now.

Step 06) Bake lighting to vertex colors, export the dff again and reattach the col. Make sure Shadeless is turned off in the material tab so we can see the lights being applied to the model.

06_vertex_lighting.mp4

Step 07) After we've re-exported our dff, reattached the col so we have testcubeC.dff ready, we can go ahead and see our final result.

07_test_cube.mp4



More on kdff.exe
kdff can generate 3 types of collision files: empty, box, mesh. 'empty' is for objects that don't need a physical collision, such as objects attached to players. 'box' mode will generate a single box around the object. A box is suitable for many simple interior objects like fridges, plants etc. 'mesh' mode will use the object's faces to create a proper collision. After exporting in 'mesh' mode, you should take the .col file in to 'Collision Editor II' and generate face groups and also set the material type of the surfaces if needed.
Attached Files
File Type: zip gtatools_for_blender_120812.zip (90.4 KB, 916 views)

Last edited by Kalcor; 24/10/2017 at 01:11 PM.
Kalcor is offline   Reply With Quote
Old 04/11/2017, 11:54 AM   #2
TopShooter2
Big Clucker
 
TopShooter2's Avatar
 
Join Date: Feb 2017
Posts: 128
Reputation: 57
Default Re: Basics of exporting from blender to SA-MP

Great tutorial, thanks.
TopShooter2 is offline   Reply With Quote
Old 04/11/2017, 11:57 AM   #3
DonaldDuck
Banned
 
Join Date: Jun 2017
Location: Phillipines
Posts: 365
Reputation: 91
Default Re: Basics of exporting from blender to SA-MP

Thats nice.
DonaldDuck is offline   Reply With Quote
Old 04/11/2017, 11:57 AM   #4
Ponga
Big Clucker
 
Ponga's Avatar
 
Join Date: Oct 2017
Posts: 86
Reputation: 9
Default Re: Basics of exporting from blender to SA-MP

Thats great.
__________________
Ponga is offline   Reply With Quote
Old 04/11/2017, 12:00 PM   #5
cuber
Gangsta
 
cuber's Avatar
 
Join Date: Oct 2016
Location: KS.
Posts: 776
Reputation: 134
Default Re: Basics of exporting from blender to SA-MP

Well done, Kye.
cuber is offline   Reply With Quote
Old 04/11/2017, 12:07 PM   #6
Freshncool
High-roller
 
Freshncool's Avatar
 
Join Date: Aug 2014
Location: Pakistan
Posts: 1,187
Reputation: 332
Default Re: Basics of exporting from blender to SA-MP

Could you give us more insight on the parameters of AddCharModel and AddSimpleModel?

For example, what is the 1st param of AddCharModel? I used a valid skin ID then used the skin ID from the 2nd one in SetPlayerSkin and it worked.
__________________
haha
Freshncool is offline   Reply With Quote
Old 04/11/2017, 12:24 PM   #7
Kalcor
SA-MP Developer
 
Join Date: Apr 2005
Location: 846
Posts: 850
Reputation: 2617
Default Re: Basics of exporting from blender to SA-MP

Quote:
AddCharModel(base skin (used for voice, animations), new skin ID, dff file in the models folder, txd file in the models folder);
from pawn: SetPlayerSkin(playerid, new skin ID);

AddSimpleModel(virtual world (-1 is all virtual worlds), base model (used for IDE flags), new model ID (-1000 to -30000), dff file in models folder, txd file in models folder);
from pawn: CreateObject(new model ID, position, rotation etc..);
Also, 'kdff', needed to make the collision has a gui version, which is easier to use, since this tutorial was written.
Kalcor is offline   Reply With Quote
Old 04/11/2017, 01:37 PM   #8
Freshncool
High-roller
 
Freshncool's Avatar
 
Join Date: Aug 2014
Location: Pakistan
Posts: 1,187
Reputation: 332
Default Re: Basics of exporting from blender to SA-MP

Quote:
Originally Posted by Kalcor View Post
Also, 'kdff', needed to make the collision has a gui version, which is easier to use, since this tutorial was written.
Thanks!

Here's a little thing that's annoying with the GUI program, it attempts to open up the ballontest dff file, what I removed so every time I open it, it gives me an error about not finding it.


Also I'm getting this when I try and open a specific .txd file from a model I got from a gta website to test it.
(in game the txd is also invisible.)
__________________
haha
Freshncool is offline   Reply With Quote
Old 04/11/2017, 02:22 PM   #9
Riwerry
Huge Clucker
 
Join Date: Oct 2013
Posts: 414
Reputation: 3
Default Re: Basics of exporting from blender to SA-MP

Is there possibility to access my own object's texture via native SA:MP functions (SetObjectMaterial)?
Riwerry is offline   Reply With Quote
Old 04/11/2017, 02:40 PM   #10
Freshncool
High-roller
 
Freshncool's Avatar
 
Join Date: Aug 2014
Location: Pakistan
Posts: 1,187
Reputation: 332
Default Re: Basics of exporting from blender to SA-MP

It seems the gui always access violates with ANY txd file.
__________________
haha
Freshncool is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Model Editing with Blender SkittlesAreFalling Everything and Nothing 2 26/02/2014 09:10 AM
Exporting Saurik Everything and Nothing 1 25/11/2011 05:36 PM
3ds max or blender SourceCode Everything and Nothing 6 15/11/2011 05:08 PM
Weather blender niCe Help Archive 13 12/10/2009 09:47 PM
[FilterScript] [FS]Car exporting stanLeys Filterscripts 8 03/08/2009 02:45 PM


All times are GMT. The time now is 02:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.