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 Studio Chat / TreeIt exporting into AGKStudio

Author
Message
Chrissell
11
Years of Service
User Offline
Joined: 2nd Apr 2013
Location:
Posted: 14th Oct 2019 21:04
Hi Im trying to export a TreeIt tree into AGKStudio.
The main 3D tree object imports fine and the textures do. But one texture covers the whole tree?
I usually make a 3d object and then make 1 texture for the whole object. TreeIt and some other programs have several textures like one for bark and one for leaves for example.
Is there a way of importing an object with these different textures into AGKstudio?
Or is there an easier way or different program?
Thanks
Chris
C.R.Sellen
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Oct 2019 21:52 Edited at: 14th Oct 2019 22:34
If you use the .x file format to export then load into AppGameKit it creates an object with multiple meshes if more than one texture is needed. (typically 2 meshes)

You can then use GetObjectTexturename() to get the names of the texture filenames that you need to apply or set them in your code directly.

You then use SetObjectMeshImage() to set the correct image to each of the meshes in the model




You should also, generate mip maps, and turn on alpha masking and set the cullmode to 0 too to get it to look near correct. Ohhh and also set texture wrapping to on as well. To make it look really really good you will need a decent shader with translucent rear face shading

You could use the texture atlas tool in TreeIt to create a single texture instead and so you wont have to load multiple textures instead.
Chrissell
11
Years of Service
User Offline
Joined: 2nd Apr 2013
Location:
Posted: 14th Oct 2019 23:33
Thanks Bengismo, that's so helpful and looks brilliant. Great Advice.
C.R.Sellen
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 16th Oct 2019 15:59
Don't know if Chrissell had any luck with this one but I am struggling with the same problem.
I have tried to follow your suggestions Bengismo but still only get 1 texture to apply.

Anyone have an example code?

Thanks
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 16th Oct 2019 18:30
if the leaves are children objects you can do it like this


Well maybe without the randomness I use lol but that code works well for trees I have converted
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Oct 2019 15:35
@ fubarpk. Thanks for your coding example but unfortunately all the tree examples that I have do not have the leaves as children. Useful though for other projects.

Hopefully i will find a way.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 17th Oct 2019 16:01 Edited at: 17th Oct 2019 16:01
Hi

My GodRay Demo in the Shader Pack uses a Tree from Evolved's TreeIT too.
I had it setup like so:


Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 18th Oct 2019 13:25
@ Hi janbo and thanks for your posting.
I have your Shader Pack which certainly enhances the model, however the bark and leaf textures shown in your post have been merged in to 1 x png presumably through TreeIt.
With textures merged you are still only applying 1 texture image to an object whereas I really need to know if it is possible to add 2 or more textures, i.e 1 for trunk bark and 1 or more for leaves.
Unfortunately I have been unable to get TreeIt to run on a W10 64bit pc as it was really only intended for the 32bit DBPro days.
Consequently I am unable to merge textures unless you or anyone else know of another app that can do this or APKS already has the capability for this but which isn't very obvious.

Cheers
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 18th Oct 2019 15:05
Quote: "With textures merged you are still only applying 1 texture image to an object whereas I really need to know if it is possible to add 2 or more textures, i.e 1 for trunk bark and 1 or more for leaves."


As per my post above...Use GetObjectNumMeshes() to find out how many meshes there are in your object. Its quite likely to be 2. You then use SetObjectMeshImage() on each mesh to set its image. So one mesh has bark applied and one has leaves.
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 18th Oct 2019 17:07
Hi Bengismo.
I did try your method earlier but the first 4 models only had 1 mesh each so didn't work so I gave up.
I have now found 1 model with 3 meshes, so fingers crossed.
Chrissell
11
Years of Service
User Offline
Joined: 2nd Apr 2013
Location:
Posted: 18th Oct 2019 17:41


rem *** Loads the Object in direct x format ***
obj_Palm_x = LoadObject( "Palm.x" )

rem *** Use this to get the texture name for each image ***
TexImage$=GetObjectTextureName(obj_Palm_x,2) : rem *** Texture index 1 to 2

rem *** Position Object to fill screen ***
SetObjectposition(obj_Palm_x,0,-10,0)

rem *** scale object ***
SetObjectScale(obj_Palm_x,.2,.2,.2)

rem *** load images found from GetObjectTextureName ***
img_palm02 = LoadImage( "palm02.png" )
img_date_palm_leaf = LoadImage( "date palm leaf.png" )

rem *** set images to mesh ***
SetObjectMeshImage(obj_Palm_x,1,img_palm02,0)
SetObjectMeshImage(obj_Palm_x,2,img_date_palm_leaf,1)

rem *** darken scene a bit ***
SetAmbientColor(50,50,50)

rem *** turn on apha masking ***
SetObjectAlphaMask( obj_Palm_x,1 )
rem *** Cullmode to 0 ***
SetObjectCullMode( obj_Palm_x, 0 )

do
Print(TexImage$)
Sync()
loop
C.R.Sellen

Login to post a reply

Server time is: 2024-04-19 19:46:44
Your offset time is: 2024-04-19 19:46:44