It looks like you're new here. If you want to get involved, click one of these buttons!
suppose i wanted to use a craft.model cube as a die (six-sided, half a pair of dice, ...). seems either i need six images, and somehow map each one to a face, or a single image that wraps the die properly. i can produce either kind of image, but so far all i've found (material.map) puts the whole image on all faces.
related: is there anything written up on creating asset packs, or any editable examples?
thanks ...
r
Comments
@John has a skybox built into Craft - you could start with that.
@RonJeffries Heres something I just put together.
sweet, and very clear.
questions: how did you find member table
uvs
, and how did you figure out the cube uv mapping was in that order?thanks!!
hmm, also nice that it didn't have to be done in triangles
@Bri_G hm, never thought to search for anything that specific, was searching for more general terms. guess i better up my search game. thanks!
@dave1707 - neat and fast response, is this another project to you library?
p.s. Am I right and you don’t need to add Craft as a dependency now - totally forgot since haven’t used Craft for ages - hence my interest now.
@RonJeffries If you look at the reference under Craft, Craft.model, you’ll see the different tables and what they’re for. As for the mapping order, it was mostly by trial and error when Craft first came out. I spent a lot of time trying to figure out how to put a texture on a Craft.sphere before I was able to do it.
@Bri_G It’s in my library now. I copied code from a different project and then created the dice strip to wrap the cube.
The above code could be modified to use a sky box, an image in the shape of a cross to wrap a cube.
@dave1707 - that was the thoughts going through my head when I saw your code and ran it. I spent quite a long time building up sky texture boxes on graphic design programs to produce skyboxes - that’s where I found out about orientation of each face on the texture.
@Bri_G Heres code that will use a sky box. I didn’t pull one in, but they can be found if you search for sky box. I created my own skybox shape.
neat, dave, thanks again. i think i need to think more about how UVs map, the vertex focus doesn't fit my mental model from blender, which is probably wrong.
now i gotta look for the sphere mapping.
thanks again.
@RonJeffries Look at the link below. My code for a textured sphere is near the bottom. You can zoom inside the sphere and view it there also.
thanks!
@dave1707 really nice example and great entry point. Trying to make the cube(s) semi transparent by setting
Which doesn’t seem to do anything. Probably a lot more complicated but wondered if you had pointers. Ideally want to have the surfaces facing the camera rendered semi transparent with the rear inside surfaces fully transparent. Imagine having a 3 x 3 x 3 rubics cube and beIng able to see through the front facing layer
Found the solution
https://codea.io/talk/discussion/8858/transparency-in-craft
@dave1707 - just added some simple texturing to your code:
Just replace the setup() function.
@West Heres a link to a Craft example where I use opacity. The blendmode is important, glad you found it. It’s the code at the beginning of the discussion.
@Bri_G That makes it different. You can change each side with whatever you want.
Here's my die code, for the record.
It uses my extension of the
quat
userdata which adds some extra functions such as choosing a quat at random. You can get that from github at https://github.com/loopspace/Codea-Library-Mathsthanks, @LoopSpace! @dave1707 i noticed your coloring dice thing is doing the uvs counter clockwise, so the texture is flipped. can't tell well with dice, pretty clear with text. reordering the calls will fix readily.
@LoopSpace Getting multiple errors on your above code.
@RonJeffries Heres the dice uvs reversed. This should do text correctly.
@dave1707 yes, I did similarly and posted my thingie over in the UV question I guess. I think for @LoopSpace 's thing to run you may need to fetch his quat extensions.
Yes, for my code then you need to get the
VecExt
file from the github link and include it as a tab/dependency. It adds a huge amount of extra functionality to the native vector/matrix/quat userdata. This project only uses a few bits of it, but I find it useful to put stuff like that in a separate project since I use it in just about every project that I write.