Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 3d - blender to agk tutorial

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 25th Feb 2018 10:00 Edited at: 1st Apr 2023 11:30
Hi guys.

Here is a tutorial to export a 3D object or animation from blender to agk.
Note : other screenshots will be added soon

(My orginal post (from my blog) can be translated in lots of langage ) :
https://arkeoschronicle.wordpress.com/2018/02/25/blender-to-agk/


1) create or import 3D object in the blender ( version 2.7x).

- Do not have too many faces (for a character between 500 and 3000 approximately), if necessary, reduce the number of faces.

Edit mode :
- to edit your object3D, reduce the number of faces...
- clic on your object 3D, and use the Tab key to enter in editmode or use this menu :


- Achieving proper uvmapping. Unfold uv: in edit mode, panel tool / uv tools, use unwrapp. If necessary, edit the uv mapping, to avoid having faces that overlap.

Uv window (from editor type) :
Choose the UV/Image editor


Unwrap (uvmapping of the 3D object) :


Result of the uvmapping (here, some face are overlapped)


Uvmapping ok :


- Create texture : you can paint on the model, including pictures, or use the tool 'bake' in the render panel at the bottom.
texture paint mode :


baking :



- If your object is not animated, go directly to 3) export the model


2) Animation in Blender

This is a delicate stage. Agk can import various formats: .dae, .x are two formats that seem the best. However, agk does not support scales.

So be especially careful never to use them in blender. Otherwise, you may need to convert the model with a 3D conversion tool like Ultimate unwrapp 3d (about 60 €) or open3dmodel (free and open source).



Warning :

- before creating the skeleton/armature, check out the size of your model, if necessary, export in .obj and test its size in agk. Scale the model in edit mode and not in object mode. If not, then you should apply the scale with ctrl + a / apply scale.


- Put your model in the center of the view, ditto for the skeleton. Because when exporting, this will be the pivot of the object.




For the animation in Blender:

- Create the skeleton, creating the bones by hand. It is unfortunately not possible to use rigify because of scales on it.


- To enlarge a bone, do not use the scale, but pull the head of the bone, for example.


- It seems we can not use inverse kinematics (IK solver) or other modifiers of bones, otherwise it fits the scale of the frame.

- Once in place, before to parent the 3d model with skeleton, apply scale for the armature (and even rotation if necessary).


- To parent the 3d model with skeleton, select the 3D model and the skeleton then press ctrl + p, choose automatic weight if possible, or use envelope.



- If necessary, change the weight painting to make everything okay. Select the 3d model, and enter weight paint mode and select each vertex group, and then change the weight in the left panel (t key).


- When it's ok, we can animate. Open dopesheet screen, to access the animation keys if necessary. Warning: use only one action for all your animations as blender exports only the first action (export in .dae)


- Then animate your model by moving the bones or doing rotations, never scale! Moving a bone and press the i button to insert a key, choose LocRot.



- It is possible to activate the autokey. You can choose to insert for LocRot channels only.



- in user preferences,
pay attention to check the "only channel available", never insert scale.


- When your animation is complete, you will be able to export. You can clean some channels in the dopesheet screen. Select all the keys and press x, select "clean channels".


3) export to agk

Your 3D object and animation are ready. You can export:

- Check that the 3d model and skeleton are at the center of the view.


- Select the 3d model and the skeleton, if an animated object.


- Menu file / export: animation, choose Collada (dae) or .x. For a normal object, the .obj, .x or another should work.


- Export .obj : Apply Modifiers, Include Edges, Include Normals, Include UV, Objects objects as OBJ


- Export .dae : Apply modifiers, selection only, triangulate.


- Export .x : export meshes, normals, uv coordinnates, export skin weights, amatures bones, rest position, animation, animation as animations.



4) import the 3d model in agk

- For an animated Object (or multi object): Use LoadObjectwithchildren ().

- Use the "frames" for your animation, but must be converted to time (seconds...).
Important : in AppGameKit, if you have several animations in your object animated, you should use the time for each animation

For example, in blender, you should have:
10 for Animations of 20 frames : walk, run, die, etc...
- frame 0 to 20: Walk
- frame 21 to 40: run
- frame 41 to 60: die
and so ...
Total frames : 200 frames

Remember :
- the start frame for the 1rst animation : 0
- the end frame of the 1rst animation : 20
- The total of frame in your model : 200


In AppGameKit, you should use :
PlayObjectAnimation( objID, animName, starttime, endtime, loop, tweentime )

exemple with the 1rst animation (walk)
- starttime : it's the start time for your 1rst animation
- endtime : it's the end of your animation

How to calcul the starttime and endtime of animation ?
- StartTime = StartFrame / TotalFrame
- Endtime = EndFrame/ TotalFrame

So for the walk animation :
- start frame = 0 -> Starttime = 0/200 (= 0)
- Endframe = 20 -> Endtime = 20/200 (= 0.1)

So in aGK, you should use (to see the first animation (walk)) :
PlayObjectAnimation (objid, "", 0, 0.1, 1, 0)
or
PlayObjectAnimation (objid, "", 0, 20/200, 1, 0)


For the others animations :
- walk : startTime = 0/200, endtime = 20/200 (or 0.1) : PlayObjectAnimation (objid, ' ", 0, 20/200, 1, 0)
- Run : startTime = 21/200, endtime = 40/200 (or 0.2) : PlayObjectAnimation (objid, "" , 21/200, 40/200, 1, 0)
- die : startTime = 41/200, endtime = 60/200 (or 0.3) : PlayObjectAnimation (objid, "" , 41 / 200, 60/200, 1, 0)
and so.

NOTE:
- in blender, you can see the animation in frame or in time if you prefer

Et voilà !


Other usefull threads (blender to agk, or animation 3d for agk):

Blender to agk :
https://forum.thegamecreators.com/thread/215998
https://forum.thegamecreators.com/thread/220581
https://forum.thegamecreators.com/thread/219381
https://forum.thegamecreators.com/thread/204256
https://forum.thegamecreators.com/thread/219381

Misc :
https://forum.thegamecreators.com/thread/217019
https://forum.thegamecreators.com/thread/221082
https://forum.thegamecreators.com/thread/219376

Dae error :
https://forum.thegamecreators.com/thread/215791

Cheers !

Edit 03.2023 :
- Changes the images links with github links (https)
- Add More informations to export animation for AGK.
AGK2 tier1 - http://www.dracaena-studio.com
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 25th Feb 2018 17:24
Nice write up

That's disappointing about scaling, I tend to scale the chest bone to animate breathing. It's also handy for exaggerating a more toon style. disconnecting some bones and moving them may work a similar effect I suppose...

Have you tried baking the animations? This should let you use IK and curves and the like, as the transforms will all get baked down to just basic location/rotation per frame.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 26th Feb 2018 05:54
One thing ive learn lately...always apply scale and rotation of blender armature before animating. Otherwise, it look ok in blender, for me it look ok in Ultimate Unwrap but tear the limbs once in AGK.
Green7
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 27th Feb 2018 08:30 Edited at: 27th Feb 2018 08:31
Quote: "- use the frame for your animation. For example, in blender, you should have:
Total frames (10 for Animation of 20 frames) : 200 frames
- frame 0 to 20: Walk
- frame 21 to 40: run
- frame 41 to 60: die
and so ...

In AppGameKit, you can use:
walk -> framend = 20/200 or 0.1 -> PlayObjectAnimation (objid, ' "0,0.1,1,0)
Run -> framend = 40/200 or 0.2 -> PlayObjectAnimation (objid, "" 21 / 200,0.2,1,0)
die -> framend = 60/200 or 0.3 -> PlayObjectAnimation (objid, "" 41 / 200,0.3,1,0)
and so."


now this is a interesting information! thanks! As AppGameKit seems not to use the obvious frame count like i was used to, was a try and error until now.
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 27th Feb 2018 10:32
@Blendman would you mind if I make this into a PDF and add it to user's downloads?
Development Director
TGC Team
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 27th Feb 2018 15:33
@Rick : of course, you can use it for anything you want .
I have made this tutorial to help agk users to export from blender to agk
So a pdf is a great idea for the users
AGK2 tier1 - http://www.dracaena-studio.com
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 28th Feb 2018 00:16
This is a very nice tutorial. Thanks alot !!


PSY LABS Games
Coders don't die, they just gosub without return
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 28th Feb 2018 08:25 Edited at: 28th Feb 2018 08:26
Very useful, Blendman. Thank you.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 28th Feb 2018 09:46
Hi

Thanks
I have updated the tutorial with all the images needed .

AGK2 tier1 - http://www.dracaena-studio.com
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 28th Feb 2018 12:46
Fun fact trivia: blender's .x exporter was originally written by one of our own members, the thread is somewhere on the old 3d chat board
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Mar 2018 17:45
Great tutorial! Many, many thanks for this.

One thing to note: You can export .x, but you CANNOT import .x back into the latest version of blender, so make sure you also save your objects in native blender format if you want to make changes. (If anyone knows a way to import .x into Blender, please share! ).

Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 1st Mar 2018 19:09
Hi thanks.

It seems its possible to import .x :
https://forum.game-guru.com/thread/212840

AGK2 tier1 - http://www.dracaena-studio.com
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 1st Mar 2018 19:13
There is a plugin to import .x files into blender 2.6, I am not sure if its compatible with the latest version.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 16th May 2018 19:38
I've had a lot of trouble (and I mean A LOT) getting an animated and textured model from blender into AGK. I've had to flip normals in blender to make the object look like it is not inside out in AppGameKit, but then raycasts don't detect a collision as (I'm guessing here) the triangles that make up the mesh are clockwise instead of anti-clockwise (or is it vise-versa?). I haven't found a solution to this issue yet.

If animating, you need to make sure every vertex has some level of influence from a bone. Any vertices left without any influence simply disappear when loaded into AppGameKit (that's my experience at least).

Does anyone know how to flip the faces (i.e. the order of the vertices so the front-faces are on the outside of the mesh), but without flipping the normals (to prevent my object looking strange and inside-out)?

Has anyone else had issues like this?

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 16th May 2018 20:56
@CJB that may be one of the problems I had with collisions but what I did was used
an invisible block object at the same location which fixed the collision issues
fubar
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th May 2018 18:19
Hi

I guess you use .x for export ?
Have you tried to export in dae.

I use the blender 2.76, the other versions doesnt work with agk (2.78..).
In dae i have no matter, the file works fine for me in agk, no need to inverse the culing or normal.
AGK2 tier1 - http://www.dracaena-studio.com
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th May 2018 18:41
Quote: "I use the blender 2.76, the other versions doesnt work with agk (2.78..)."


How exactly does it not work with AppGameKit? I ask because I've been using 2.79.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th May 2018 19:38
When I try to export the same file with blender 2.78, the dae doesnt work properly.
but i have to make others tests, i havent used the 2.78 since march 2018.
AGK2 tier1 - http://www.dracaena-studio.com
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 18th May 2018 14:16 Edited at: 18th May 2018 14:18
I am using 2.79. I am now having success with the .fbx exporter. For animations to work properly, you need to make sure you select the object and armature (both in object mode), and ensure the scale option is enabled and set to 0.01. Here are the settings I am using (I don't know if they are all required, but it's been a bit of a trial and error approach):



Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-18 12:14:50
Your offset time is: 2024-11-18 12:14:50