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 / 3D object import with texture

Author
Message
xcode77
2
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 6th Jun 2020 22:27 Edited at: 9th Jun 2020 11:00
Hi all,

Managed to get my 3D objects in to AppGameKit studio with no problem, all working well.
Was reading an interesting post about .obj files not performing well in studio, so exported a .3ds from Hexagon (instead of .obj).
As .3ds doesn't create a .png file for loading the texture as .obj does, I was wondering how to import the colors (the .3ds cube displayed no problem just with no color or texture loaded).
I know the .3ds file has color embedded in the file because I used the Autodesk FBX review app to view and my test cube is red as I set it.

Question is two-fold really, do I care about .obj not performing well in studio and continue to use it?
and if I did want to use .3ds files, how about loading the textures/colors?

One small edit:
Could someone help me work out how to add 2 texture files (.png files) to one .obj please? do I need to supply AppGameKit the .mtl file with the multiple .png file info?
I don't understand the documentation without an example using the SetObjectMeshImage( )

Thanks in advance as always
Bored of the Rings
15
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Jun 2020 11:25 Edited at: 9th Jun 2020 11:26
I've worked on a lot of object format conversion tools and had started .3DS converter. Some of the tools I have written make use of memblocks. Have you thought about putting the model data into AppGameKit memblocks? You can read / write colour info to the memblocks very easily. I wasn't aware that .OBJ format didn't work too well in AGKS, maybe I will do some tests when I get time.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
xcode77
2
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 9th Jun 2020 13:03 Edited at: 9th Jun 2020 13:10
Thanks for your reply BOTR,

The post I read had said .obj was slower in studio than classic. I'm really liking studio (the ease of use, whole layout etc) so classic isn't an option for me.
I don't need a .3DS specifically, I just was going through all the possible formats AppGameKit can handle. Some of the info is quite outdated and .blend didn't work etc
Some of the more suitable 3D software for me included .3ds export, so that's why I was curious how to import the textures into AGK.
I've tested about 20 3D apps over the last couple of weeks, all having their pros and cons.

Until now I've been using magica voxel to make quick assets. The export includes a .png and .obj automatically, so all works beautifully in AGK.
Bought "asset forge" (nice easy 3D asset making and easy texturing and my daughter loves it), but any more than one texture and I can't seem to make it display in AppGameKit properly.
I was just hoping I wouldn't have to end up UV mapping & baking in blender just to make a single .png texture (I find blender overly complicated and I'd rather stay away from it).

As for color memblocks, I am truly clueless about that, but totally open to it if you could show a simple example of how to do it.
smerf
15
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 13th Jun 2020 01:48
agk will not import textures. you must open your model file and write ur own import script. models need to have a material assigned, texture assighned, unwrapped, exported with options: selected objects only, with bones, with animations, and defaults if using blender. agk will not recognise children objects with more then one texture if animations is not selected. i wrote a script that works for.x files using this method it works good.

xcode77
2
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 14th Jun 2020 02:48
Thanks for your reply smerf. After you wrote I tried my .DAE file with loadObjectWithChildren( ) and it worked with the colors showing (albeit not perfect coloring. but at least now my .DAE object is showing up)
Not sure why the colors are off, but at least some progress as I didn't use the loadImage( ) function.

Just to clarify, you're saying is AppGameKit can't import multiple textures from the loadImage( ) function? (I mean it will import one texture).
Ok, so can I modify lets say .obj file and the .mtl / .png files manually with text edit and have them show up correctly in agk?
what would be the syntax to call that?

Sorry for so many questions, this is my first delve into the 3D world, I've done all my apps/utilities in 2D up until now
smerf
15
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 14th Jun 2020 05:24 Edited at: 14th Jun 2020 05:30
"agk will not import any textures from your model." I wrote a script in agk that opens my model files and searches is for object and texture references is then load the referenced image via the script and applies it the the object or child and builds an array so it keeps all the images names and models together there is an example attached its far from finished but you can see the potential. If you plan to use a different file type youll have to rewrite a new script for each file type because there set up differently

Attachments

Login to view attachments
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Jun 2020 10:28 Edited at: 14th Jun 2020 10:42
Quote: ""agk will not import any textures from your model." I wrote a script in agk that opens my model files and searches is for object and texture references is then load the referenced image "



You do know that AppGameKit has GetObjectNumTextures() and GetObjectTextureName()??

These allow you to get the texture filenames inside the model files

When I create a 3d model for use in AppGameKit, I just ensure each mesh has a unique material and then load each texture (using its name given in the function above) inside a loop in AGK. The textures are applied to meshes and it works ok.

There's only the obj file format that doesnt support this....ALL the other formats fbx, dae, ms3d, 3ds, .x ..... allow you to get the texture names inside AppGameKit and load the image then apply it to your model. No scripts needed for just textures . If you wanted a pure colour applied then you will have to do that manually.

AGK's obj imported wont split meshes based on material or give you texture names so dont bother with the format if your serious about 3d in agk.
.3ds can sometimes limit your texture name lengths to 9.3, so it is also not a great choice depending on what you are using to model or export with. Others ,no problem as long as you keep num meshes equal to num materials.
xcode77
2
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 14th Jun 2020 18:04
@smerf
Thanks a lot for your example smerf, I'll work my way through it slowly to understand.

@bengismo
Thanks, I haven't used GetObjectTextureName( ) etc before
I wish there was some example code on AppGameKit help. Could you provide a very small and simple code of how to load an FBX mesh into AGKS with textures displaying if/when you have time please?

Just as a side note: vertex colors are imported perfectly well as a texture .png file when the .obj is referenced with SetObjectImage( )
(It must be an enhanced definition as opposed to a standard definition as I've heard multiple sources say .obj vertex colors are not supported )

it does seems .obj is not the way to go in AppGameKit studio with its slow performance (by comparison to other formats). I'll give it a try for .dae and .fbx see if I can get it working and report back.
I did note that .fbx file sizes were bigger than .obj, but .obj loaded slower... hmmm.
I was just following Rick's great tut on youtube with .obj and .png and figured that's what we should be using for static models.




Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Jun 2020 19:36 Edited at: 14th Jun 2020 19:41
Quote: "Just as a side note: vertex colors are imported perfectly well as a texture .png file when the .obj is referenced with SetObjectImage( )
(It must be an enhanced definition as opposed to a standard definition as I've heard multiple sources say .obj vertex colors are not supported )"

I not sure you understand what vertex colours are. If you use vertex colours ...you wouldnt need a texture at all to see the vertex colours. Vertex colours are colours which are stored per vertex in the model file and so there is no texture needed. If your model has vertex colours then each vertex gets an RGB value stored with it.

If you are applying a texture to see the colour then you are not actually using vertex colours at all. You are simply UV texturing a model - like any other textured model. If you convert your model to a memblock and check the attributes of the mesh for a vertex colour, you will most likely find out that there are none there at all.
https://forum.thegamecreators.com/thread/224517

The obj file format is ok if you only have one texture for your entire model but generally not a great idea if you want, complex multi mesh scenes, small file sizes, fast load speeds or support in AppGameKit for texture file names etc....
smerf
15
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 15th Jun 2020 02:43
vertex colors definitely are supported but they offer a poor substitute for a texture, u need perfect models and double the verts to get decent vertex coloring results. Obj files are widley supported but are the useful files for games. If youll look at my model in my example ull see that i just used a few colors that could be reused over and over or a texture. baking large object textures is rarely the way to go.

Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 15th Jun 2020 06:08 Edited at: 15th Jun 2020 06:09
Vertex colours are indeed a poor substitute for a texture. Textures look way better.

Your example code smerf doesnt seem right at all?
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 15th Jun 2020 06:44 Edited at: 15th Jun 2020 19:03
If you just load up your tank.x model with LoadObject(), then loop through the textures that were found in it (GetObjectNumTextures() &GetObjectTextureName()) and load the image names and apply the images to the meshes with setobjectmeshImage() then you get a textured model.

You may need to reorder the textures against the meshes if they weren't saved in order from whatever 3d app was used to create the file but that is fairly easy, and you will have to use the texture names as they are defined in the model file (the panel name is different). Ive printed out the texture names AppGameKit found in the file

That takes about 4 lines to load the textures and apply them rather them manually try to find names in the model file.



Id still much prefer a fully textured object rather than just matte colours but each to their own.

Why use those 27x24 pixel images?? Since they are just plain uniform colours, a 1x1 pixel file would do the same job and be smaller? I assume some app generated them.

EDIT:
Just to add....this is what i do all in one load function:
-find the texture name for the mesh using the GetObjectTextureName() function.
-Then check for similarly named image files but with additional text like _n - for normal map and _ao for ambient occlusion, _lm for lightmap,_r for roughness, _em for environment map etc...
-I check if they exist in the same directory and if they do, I automatically load them and apply them to the appropriate texture slot.
-If a set of textures is loaded then I apply the correct shader (depending on what images were with the model) or stick with AGK's shader for items with just a diffuse (or diffuse plus normal).

This way you can load complex scenes with multiple textures per mesh and set the appropriate shaders without any complexity or scripting at all. The results are a simple LoadObjectEx() function (as I named it) which does everything for me.

xcode77
2
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 25th Jun 2020 19:01
Sorry for the late reply and thank you both for the information about 3D.
In the end it hasnt helped me that much and seems a very convoluted way to achieve a simple load up.
For the time being I think Ill use some alternative software for 3D development, the time wasted has been too much.
Im hoping to get some improvement speed for .obj and would really appreciate some info why AppGameKit studio is performing not at well as classic
App game kit studio will definitely be my go to app for 2D though

Login to post a reply

Server time is: 2020-08-04 04:01:08
Your offset time is: 2020-08-04 04:01:08