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.

Newcomers AppGameKit Corner / (3D beginner) How to apply different textures to different sides (meshes?) of an object. Also, a bug with SetObjectMeshImage?

Author
Message
Coilwinder
11
Years of Service
User Offline
Joined: 28th Feb 2013
Location: Norway
Posted: 29th Jul 2017 14:53
Just testing the waters here For starters, I'm trying to make a simple cube with different textures on different sides.

I'm not sure I got all the 3D terminology right btw. I think a mesh consist of one or more polygons (sides), and one or more meshes again is an object (I'm not even thinking about animation at this point )

The built-in command "CreateObjectBox( x,y,z )" only makes one mesh for a cube, so it seems I can't use that for my purpose? I tried making a cube in Wings3D and Blender. Wings3D also just made one mesh (even if I colored the sides differently, I'm guessing I should made more "materials" but atm I couldn't get it to assign them to only a side. I did manage to make a cube with 6 meshes in Blender though.

I tried:
Exported the blender object as .3ds and .dae,
Also imported the .3ds into Wings3D and exported as .x, 3ds, .dae and .lwo

But none of the objects I import into AppGameKit shows up as anything else than a boring white cube (guessing it's something to do with lighting settings?).


Also, it seems I'm unable to remove any images from a texture stage by setting the image ID to 0 (zero), as described for the command SetObjectMeshImage (whether made with CreateObjectBox and textured, or loaded with LoadObject). I get an error message stating that "image 0 does not exist". A bug?

Here's my super basic test code so far. Media files included in zip if needed.


Apologies for any typos and strange grammar.

Attachments

Login to view attachments
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 31st Jul 2017 06:11
That is correct. You'll get 1 mesh. You need to unwrap the model. I've mainly used Ultimate Unwrap 3D for that but pretty sure I've done it easily right inside Blender as well. What you'll end up with a texture (single image) that has the 6 faces of the cube. Then in each face area you can draw whatever you want.

I don't know how the default cube is uvmapped. Could possibly experiment to try to find out. But it is quite possible all 6 faces of it are mapped as one by default.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Coilwinder
11
Years of Service
User Offline
Joined: 28th Feb 2013
Location: Norway
Posted: 31st Jul 2017 08:12
Ok, thanks for the pointer. I need to check out unwrapping then.

If an CreateObjectBox() object is textured, the texture is repeated on all sides. I'm not sure how that works (with one mesh). All sides get the same scale and repeat / clamp (not sure of name) settings etc.

Btw I remember playing with LightWave many years ago (just for fun, didn't really make anything out of it), but I have to say that Blender's GUI looks much more daunting! So I haven't used Blender almost at at all so far.
Apologies for any typos and strange grammar.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 31st Jul 2017 17:46
Don't be scared of Blender its a great tool and not as tricky as you would think, there are many decent videos out there even TGC have a couple in there tutorial videos, you can import a textured model with more than 1 image and unwrap it and add ambient occlusion, the steps for that are to a bit winded but its worth getting to know the process and starting with a basic cube is perfect.
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 31st Jul 2017 18:23
I found this video on how to unwrap in Blender. It works, despite the annoying noise. I still don't know what to do once I have the thing unwrapped, though.
https://www.youtube.com/watch?v=x8Dxh4QOuqE

Here's my notes:

1) Split the screen into two windows:
Set the lower window to UV/Image Editor.
Set the top window to Edit Mode.

2) The model is now selected. Press A to Deselect.

3) In the top window: Click on the edge select icon (placed in the lower part of that window)

4) You will now have to select the edges where you're going to cut open your object
Use shift-rightclick to select several edges
Shift-Alt-rightclick to select all the way around

5) Bar to the left -- click the Shading/UVs tab
Select:
UV Mapping: Mark Seam

6) When you deselect (with A) You will see that the seam is highlighted red. This is the lines that are going to be cut open.

7) Select A to highlight the whole object

8) Still in the bar to the left:
UV Mapping: Unwrap (select Unwrap again in the sub menu)
Coilwinder
11
Years of Service
User Offline
Joined: 28th Feb 2013
Location: Norway
Posted: 1st Aug 2017 12:16 Edited at: 1st Aug 2017 12:17
Thanks guys!

basicFanatic:

Great notes! That and the linked youtube got me started (at least a bit. And I didn't mind the noise, it was a very informative video). Only thing missing was the export UV layout. After I found it I got it textured easily in AGK.
But I could absolutely not get the loop selection (Shift-Alt-Right click) to work in Blender (Windows 7), but for now that's no biggie.


Apologies for any typos and strange grammar.

Attachments

Login to view attachments
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 1st Aug 2017 16:00
I just tried creating a little die in Blender and export it as .fbx
However, the .fbx didn't seem to load into my AGK2 game. Then, after much tinkering, I noticed that sky-scraper sized monolith hovering above my head! (I first thought it was the sky)
I got my stupid die after setting the size to SetObjectScale(obj,0.0001,0.0001,0.0001)
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 3rd Aug 2017 18:45
Here's the die! I found out that Blender had a simple bevel effect that I could use the smoothen the edges.

Another thing I learned: The transparency on the exported texture map is very important since it symbolizes the unused area of the .png file. So if you fill these areas with color, the texture will get distorted in the game! That is why I have that transparent area on the upper-right of my texture.

Attachments

Login to view attachments
Coilwinder
11
Years of Service
User Offline
Joined: 28th Feb 2013
Location: Norway
Posted: 3rd Aug 2017 19:58 Edited at: 3rd Aug 2017 19:58
basicFanatic:

That's nice to know, thanks!

About that bevel effect, how did you do that? I also looked into it (or rather "inset face"), then I found out it wouldn't work with any of the snap-to- features, which makes it kind of useless. Found one way around it (googling..), first Extrude then Scale the face, which seems to work. I'm not sure how to get it smoother though (except by repeating the procedure).
Apologies for any typos and strange grammar.
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 3rd Aug 2017 20:31
Very pretty bevel effects in Blender:
1) Press TAB to go to Edit mode (toggles Object/Edit mode)
2) Press A to select all of your model (toggles select all/None)
3) Press Ctrl-B and then move the mouse to "change offset" and use the mouse wheel to adjust segments (smoothing). Left-click to confirm.
Coilwinder
11
Years of Service
User Offline
Joined: 28th Feb 2013
Location: Norway
Posted: 3rd Aug 2017 21:06 Edited at: 4th Aug 2017 13:52
Thanks (again) !

Nice die (dice?) too, I borrowed it a bit Into Castle Advanced demo for fun.
(Not the best screenshot)

EDIT: In attachment instead - couldn't get image tag to work.
Apologies for any typos and strange grammar.

Attachments

Login to view attachments
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 6th Aug 2017 09:43
Speaking of Blender, I just found a truckload of game-related tutorials:
https://www.katsbits.com/tutorials/#blender_tutorials

Login to post a reply

Server time is: 2024-03-28 12:38:30
Your offset time is: 2024-03-28 12:38:30