tabletop-club icon indicating copy to clipboard operation
tabletop-club copied to clipboard

Feature Assets: Easier token creation

Open elmodor opened this issue 3 years ago • 12 comments

Is your feature request related to a problem? Please describe. Tokens require a very complex UV setup (front, back, sides). However, many tokens usually only have a front and back while the sides where just cut out from the cardboard. Adding 1 or 4 other sides with the same color is too complex for most tokens.

Describe the solution you'd like It should be possible to create tokens similar to cards. For square and round tokens: specify the front and back image. All other sides should be set by a color value.

Describe alternatives you've considered Currently it would be easier to just use a card as token. Therefor an option to have a card inside the token category would also work. So the configuration for an image would require something like: "file_type = token" to change the type of a specific asset.

elmodor avatar Nov 27 '22 17:11 elmodor

Yeah I agree there should be an easier way to create tokens - but sometimes people might want to have distinct textures for the sides (see the poker chips in the default asset pack), so I think there should be a way to toggle this "simplified" method.

One thing that comes to mind is a couple of extra configuration values in config.cfg, something like:

[Test Token.png]
simple_uv = true

; Similar to how cards are configured:
back_face = "Test Token Back.png"
side_color = "#000000"

[Test Token Back.png]
ignore = true

Then internally when the token is imported, it could scan for this configuration, then create a new "cached" texture that would become the UV of the token (as it is now).

What do you think?

drwhut avatar Nov 28 '22 11:11 drwhut

Of course I want to keep the current system.

I like your proposal! Sounds good to me. Will the "cached" texture be actually cached? Or do we have to create it every time the game restarts?

elmodor avatar Nov 28 '22 14:11 elmodor

Yeah, as in it will create a new image, hidden away in the user:// directory, but only if the original texture(s) changed.

drwhut avatar Nov 28 '22 15:11 drwhut

Boards, pieces and dice need this as well.

GrimPixel avatar Dec 24 '22 01:12 GrimPixel

The thing is, those types of objects are imported as 3D models, so theoretically the UV mapping can be whatever you want for those objects. Early on in the project each folder in an asset pack had subdirectories like cube, cylinder, custom for importing as images vs 3D models, but I decided that the system was redundant, as 3D models were more generic, and gave more freedom as to how to create the model.

Maybe there could be template 3D models created with convenient UV mappings? For example, a board template model in the shape of a cube which has most of the UV space being the top face.

drwhut avatar Dec 30 '22 10:12 drwhut

Pieces in all games are supposed to be easy to pick up, so their sizes are similar, while boards may have various widths and lengths. I guess there could be a standard solution for creating pieces and boards: set a standard size for pieces; then according to the size a piece takes, set the size of the board; then set the scaling of the pieces and the board.

GrimPixel avatar Dec 31 '22 14:12 GrimPixel

If I understand your solution correctly, I think this may be too "generic" of a solution - having a scale property for each of the pieces is in my opinion intuitive enough for most users, and I could imagine if the board was automatically scaled, it could be wrong more times than it is right.

drwhut avatar Jan 02 '23 14:01 drwhut

Not automatically scaled, but calculated and scaled by the creator.

From creator's perspective, there would need to be a front image, a back image and a side image (which could be set the same as the back); then the length, width and height (which could be 1cm or so by default) of the board; then its mass needs to be calculated; finally locations of “snaps” mentioned in https://github.com/drwhut/tabletop-club/issues/180 would be defined.

GrimPixel avatar Jan 02 '23 19:01 GrimPixel

The size (scale) and mass (mass) of the object can already be set by the creator - this issue is purely for the simplified UV, using single images for each side rather than all sides in one image.

drwhut avatar Jan 06 '23 08:01 drwhut

A friend gave me an idea that I wanted to mention here for future reference: since there will be an in-game asset pack manager in v0.2.0 (see #73), what if instead of using the config.cfg file to set the front, back, and side separately like I proposed above, creators used the in-game pack manager to create 3D objects by just importing images onto pre-bundled meshes? Here's an example of what I mean:

Let's say someone wants to add a new board, and they already have an image for it, but they don't know how to turn it into a 3D model, which is required for boards currently. They could go to the asset pack manager, click on "New Pack", then click "New" > "Board", and from here they have two options: either import a custom 3D model (the current system), or use a template model (e.g. a cube), in which case they just need to provide a texture for the top face of the cube.

The same system could then be used for tokens, but since tokens need specific shapes, the options are now provide a full texture (the current system), or separate textures for the front, back, and sides. In fact, the system could be extended to most objects, e.g. what if you could create a piece using just an image, then it could look like the image is on a cardboard cutout on a stand, like a figurine?

Behind the scenes, providing separate textures would mean the game would create a new texture image in the filesystem with the correct UV mapping based on the mesh that was chosen. Depending on how complicated the meshes are, the game could also write .obj files to the filesystem so they can be modified by the creator after the fact?

Would like to hear people's thoughts on this before I start making such a system! In my mind not only would this be eaiser than using the config.cfg to point the game towards different textures, but this combined with the asset pack manager would make adding assets to the game in general much easier, ideally to the point that creators don't need to refer to the documentation.

drwhut avatar Apr 24 '23 19:04 drwhut

When creating shōgi pieces, would I just need to import the images with transparency and the piece would be tablet-shaped automatically? Each of the piece has two sides and need to be defined with two images.

GrimPixel avatar Apr 25 '23 12:04 GrimPixel

Hmm... transparency in textures is a whole other thing entirely. The thing is, if a cube mesh is used, and I added the ability for the surfaces to be transparent, the mesh would still be a cube - there would basically be holes where the transparency is. There could potentially be a way to automatically change the mesh depending on where the transparency is, but that's out of my scope. For the pieces you mentioned, I would recommend a custom 3D model for them for the best-looking appearance.

drwhut avatar Apr 25 '23 17:04 drwhut