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.

3 Dimensional Chat / How can I create an object with several meshes using Blender?

Author
Message
=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 7th Mar 2018 20:43 Edited at: 7th Mar 2018 20:45
Hey Guys,

I wasn't sure if I should post this here, or in the AppGameKit Chat forum. Since I hardly ever post in this forum, I thought I'd try here first.

So, I'm actually trying to create a largish low poly object to use as the background in a game. I've already tried creating a single texture map for it, but even with what I would consider to be a huge texture (2048 x 2048), some of the smaller parts of the model were really blurry. My next plan is to use AGK's SetObjectMeshImage() command, but no matter what I try I cannot get my object to register more than 1 mesh

I even made a simple model of a plane as a floor with two cubes, each with a different texture but again, despite all efforts, no joy.

I've been unable to find anything helpful on these forums or any Blender related ones (Although I'm not really sure what I'm looking for in the Blender resources)

If anyone has any idea what I need to do to make this model work properly in AppGameKit, then I'd be very grateful

Thanks in advance

=PRoF=
Ortu
DBPro Master
10
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 8th Mar 2018 02:26
Is there a reason it needs to be all one object?

Have you tried parenting instead of joining the objects in blender, export them together as one object, then use loadObjectWithChildren in agk?
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.
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 8th Mar 2018 15:01
Hi

You could try this :
- create several objects, dont join them
- select them
- export your objects selected as .obj

Open this file in agk with loadobject () and set the texture with setobjectmeshimage ()

It should work.
AGK2 tier1 - http://www.dracaena-studio.com
=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 8th Mar 2018 15:10
@Ortu - No, not really; but it would be easier I guess. I'll try parenting. Thanks for the suggestion.

@Blendman - That's what I have been doing, except the object ends up with only 1 mesh when I check with GetObjectMeshNum()
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 10th Mar 2018 16:05 Edited at: 10th Mar 2018 16:29
Hi

I have tried to get several mesh in one object exported from blender, and I do'nt know why, it doesn't work.

I have tried the format :
- obj, dae, 3ds, b3D -> always 1 mesh

I have tried : parenting, no parenting -> always 1 mesh

=prof= :
if you find a way to export from blender and get several mesh in agk, please tell me how you do that ^^.

I continue to search how to do that ^^.

EDIT :
- ok, in .x, it work without any parenting.
- open it with loadobject() in agk

The export options :
Export meshs/export normal/export uv/export material/right hand/ Y

The matter is that :
1) the file is bigger in.x than in .obj
2) if you use : LoadObjectwithchildren (animated object) : The objects are rotated by 90 in X, so you have to rotate them in blender (-90 in X) or in agk (-90 in x)
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Mar 2018 20:35 Edited at: 10th Mar 2018 20:36
Blendman, thats not really true...

As long as you have different materials/textures applied to 3d items in blender and you export .dae, .fbx .3ds or .x then you get multiple meshes when you load the file into AGK.

The exporters only consider breaking it into multiple meshes if there is a reason to do so....different materials causes that.
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 10th Mar 2018 21:48
Oh thanks for the informations !
I dont know that all objects should have a unique material or texture.
Is it work with . Obj too ?

I will try tomorrow, thank very much .
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Mar 2018 22:39
Making the unique material forces the file to be saved in such a way that AppGameKit loads it up as 2 or more meshes which is what we want. This means we can apply multiple textures and shaders etc...

Ive not managed to get .obj's to load as multiple meshes and I havent tried it as I dont use .obj much. I tend to use other formats.
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 11th Mar 2018 20:56
Hi

I have tried a dae, with multi mesh, multi uv, multi textures, normalmap, lightmap, diffuse, all works fine.
Its great !
Agk just miss some internal features like specular for example .
But all works fine.
Thanks again Bengismo
AGK2 tier1 - http://www.dracaena-studio.com
=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 13th Mar 2018 22:21 Edited at: 13th Mar 2018 22:22
I am having absolutely no luck with this what so ever



Using my demo scene (above, a simple plane with two cubes, each with it's own material/uv map/texture image), the best I managed was a .x file which claimed to have 2 meshes when GetObjectNumMeshes() is called, but when I apply an image to the meshes, only mesh 1 textures something (in this case, the floor plane), applying a texture to mesh 2 did nothing at all. Exporting the same model as a .obj only showed 1 mesh.

Here are the export settings I used when exporting the .x model.



Can someone who has made a model in blender which will work with the SetObjectMeshImage(), post the .blend file here please so I can see what I'm doing wrong?
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 14th Mar 2018 16:37
You should try to export in dae, I use this format to export ndit works fine.
Create 3 objects separatelyi blender, add them a unique material for each object, then dd aunique texture. Then export all in dae.

Tomorrow, i will post ablend file which works.
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Mar 2018 19:47 Edited at: 14th Mar 2018 19:52
This is really quite easy



So.... 20 seconds to create a scene with 2 blocks and a ground plane. Assign materials to each object and assign textures to the materials. Add UV's to your object data.

Then Export ANY of these and you will get multiple meshes (3 in the case of this model):
.dae (works perfect)
.fbx (works perfect - but ensure your scaling is right as the units can be a magnitude out x10)
.3ds (works perfect - but you must enable texture wrapping in AppGameKit if your texture is wrapped multiple times in blender )
.x (works fine - just make sure you uncheck export selected objects only)

.obj does not work in my experience. Its only ever one mesh. If someone knows how to import .obj into agk as multiple meshes please let us know

Exactly which mesh is which object depnds on the order you have created them in blender and the filetype you used but they are all there and all work with the exception of .obj


For advanced users....you can add normalmaps and even generate a lightmap so it looks just like the blender render

Attachments

Login to view attachments
=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 14th Mar 2018 20:21
@Bengismo:
That is exactly what I have been doing, but I have not been getting the same results as you. The only difference I can see is that you are using Blender Render, where as I am using the Cycles one. I'll try exporting your model and seeing what happens, (If this doesn't work, it's a problem with my install of blender/agk) and then assuming it's successful, try a Blender Render scene of my own.
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Mar 2018 20:36
Quote: "That is exactly what I have been doing, but I have not been getting the same results as you. The only difference I can see is that you are using Blender Render, where as I am using the Cycles one. "

Its nothing to do with the renderer used. I can create the models without ever rendering them or switch renderers and still get them to load in AppGameKit fine. Its the setting up materials and uvs that is key to getting multiple meshes.

Quote: "I'll try exporting your model and seeing what happens, (If this doesn't work, it's a problem with my install of blender/agk) and then assuming it's successful, try a Blender Render scene of my own."

Let us know how you get on....I only did a quick render of that scene so you could see its the same scene in blender to the one in agk.

=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 14th Mar 2018 21:59
Ok, so I have it working more or less.

Switching to Blender Render changes a few of the properties relating to textures, as well as how it handles materials/textures. But it certainly makes a difference.

The only thing I have been unable to do is get the models to work with 2 UV maps (for decals etc.)

I shall continue playing with it, and report back

Thanks everyone for the help
Ortu
DBPro Master
10
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Mar 2018 23:50
When texturing in agk, how do you specify which UV to use for which texture?
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.
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 15th Mar 2018 13:15 Edited at: 15th Mar 2018 13:19
I dont know if its possible.
When i use several mesh with an object, i should write a shader for it, to have lightmap, normalmap, or other cool features.

It could be great if Paul add a feature to set the texture uv by stage.
By default, i think all texture textureuv0, except the lightmap which use the textureuv1.

Bengismo : the lightmap in agk is very different from the lighting in blender.
So we cant have exactly the same scene, except if we bake in the lightmap the colors and diffuse for exemple.
But agk doesnt have specular, and other diffuse shader like oren nayar or other.
It could be great to have those diffuse and spec shader In agk, at least.
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 15th Mar 2018 14:07 Edited at: 15th Mar 2018 14:21
If you use your own shaders then you can set which texture uses which UV coordinates. No problem. You can have multiple UV coords for other effects (decals, wave effects,lookups) etc but only in shaders.

As Blendman says, with the built in stock diffuse texture uses Stage 0 and UV0 and the Lightmap uses Stage 2 and UV1 if they are included in the model file otherwise it uses UV0 coords (same a s diffuse).

It wouldnt make sense to add a UV selection per stage as AppGameKit wouldnt know what to do with each texture stage. It wouldnt know how to blend the textures as there are MANY possible ways of combining the textures and infinate numbers of possibilities. This is why shaders are used these days instead of the older fixed function rendering pipelines of DX8/9. In the vertex and pixel shaders you are in full control of blending textures together, apply effects, normal maps, bump maps, decals, lightmapping etc....

Blender uses a raytracer to produce its images (Blender Render or cycles typically) so the render in AppGameKit using Open GL will never be EXACTLY the same as AppGameKit uses open GL in real time. At least it wont without using custom shaders to add all of the rendering features used in the blender render (such as cook torrence specular).

The lightmap is an overlay and should only darken the lighting from a set level. You have to remember to turn off the SUN lighting and ambient which is on by default and disable lights if your using lightmapping in AppGameKit or the scene looks too bright as your adding light to light thats already baked into the scene. Careful use of the object diffuse and emmisive colors gets a better result too.

AGK doenst have specular built in as a function we can use but specular can be added into a shader fairly easily, its not hard to add a phong shader to do this as I have done it. Ive not got a cook torrence one that will include the lightmap and diffuse in it but I could work on one if I ever get some time so that the scene in AppGameKit would look very similar to the blender render. Its already not far off looking good and its real time dynamic rendering. Just light mapping and bump mapping together looks great and creates quite realistic scenes.

If we could add some PBR rendering too it will look pretty great and still run fast. Its all about using the shaders these days rather then some stcok off the shelf architecture.

EDITED: as my spelling and grammar is ****
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 15th Mar 2018 15:05
If you have a simple example of a specular shader, im interested, but would it work with normalmap too ?
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 18th Mar 2018 16:58 Edited at: 18th Mar 2018 17:01
Specular and normal maps work well together. I quickly created 9 spheres with 3 different textures.

From the left side
1) Texture only
2) Texture and normal map
3) Texture and normal map and specular pixel shading



What i want to do is... true reflected specular mapping (via cuba maps/dual parabolic texure) and will attempt to work on that when I get a chance.
Blendman
4
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 18th Mar 2018 17:03
Hi
Its great
What is the shader 3) ?
Could you post the code of this shader ?

Thanks a lot.
AGK2 tier1 - http://www.dracaena-studio.com
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Mar 2018 17:19
The code is very similar to this (allthough it needs modification for use in AppGameKit to use AGK's in built variables):
https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model

and then used
SetShaderConstantByName(1,"uSpecular",specular#,0,0,0) /// Which is actually Shininess in the original shader

This sets the specular power


Green7
12
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 21st Mar 2018 12:57
janbo has a true reflected specular mapping via dual parabolic texure in his shader pack.
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 21st Mar 2018 13:28 Edited at: 21st Mar 2018 13:29
Yes...... but I want to know how to do it, how it works and how to program shaders....not just use them without a clue of how they work.

If Blendman wants a Specular shader then he could use Janbos shader pack.
hoyoyo80
2
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 22nd Mar 2018 10:17
Hi all, i seldom visit this subforum and i just follow this thread.

My question: what are we trying to achieve here? Is it something level export? Where all the meshes export as one?

=PRoF=
15
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 23rd Mar 2018 23:34
Ok, so I think I finally managed to get model to texture the way I wanted it to! Thanks everyone for the help with that.

My next job is to try and get a light map to work with the model

@hoyoyo80:
I'm trying to make a low poly background scene for a game I am working on.

Login to post a reply

Server time is: 2018-10-18 06:16:36
Your offset time is: 2018-10-18 06:16:36