It looks like you're new here. If you want to get involved, click one of these buttons!
I belive followings are minimum code to create 3D cube via Craft.
How can I draw the six surfaces with indivisual six colors like a rubic cube ?
Thank you for your advice.
function setup()
-- Dependencies Craft, Camera
scene = craft.scene()
scene.camera.position = vec3(0, -10, 0)
entity = scene:entity()
entity.model = craft.model.cube(vec3(1,1,1))
scene.camera:add(OrbitViewer, vec3(), 100, 0, 0)
end
function update(dt)
scene:update(dt)
end
function draw()
update(DeltaTime)
scene:draw()
end
Comments
@cuvota Are you trying to draw a rubics cube or do you just want a cube with six different colored sides. I guess if you create one cube, you can create a lot more cubes to form a rubics cube. If no one posts anything, I’ll have an example a little later when I have time.
@cuvota Here’s an example of drawing 3x3x3 cubes.
@dave1707 That's not going to work for a rubik's cube because you have each cube as a separate colour, but for a rubik's cube then each side of each cube will be a different colour.
Looking back at old Codea videos, I found a couple of rubik's cubes:
@LoopSpace I don’t know if he really wants to create a Rubiks cube or not, so I just gave him different colored cubes in 3x3x3 cube.
Here’s an example to color each side of a cube that can be used if he wants to create a Rubiks cube. I saw those videos when I did a forum search, but there wasn’t any code examples.
Those videos are pre-craft so may not be relevant.
Here’s a change to the above code for a rubiks cube.
Thank you very much. I build basic structure of a 3 x 3 x 3 Rubic Cube shown the following picture. This is the first trial of using Craft, and found i’ts very powerful for 3D model creation. Next step is rotate each slice of the cube.
Greetings friends Impressive design, the use of textures and colors go excellent with the proposal. I think it's great that they share this type of implementations in forums, all of us who go to this meeting place are in 3d design, scale model printers, prototypes and more. The future is here to stay! I would like to know if with this type of codes you could create other symmetry and of course take them to 3d scale
@3dmodels Using Craft, it’s a lot easier to create 3D objects.
l write following code to add cube rotation function as my study. but the method getting complex and hard to debug. This code have big problem . Is there more smart approach for this subject.?
It's been a while since I wrote my Rubik's cube (in the pre-Craft days), but I think that I had a table for each face and so when rotating a face, I could apply a single quaternion to each cube in that table. Then I'd update the tables since the cubes will have moved round. To be clear, a cube would typically belong to more than one face-table.
If you think that the code would be useful, I can upload it to github.
Yes please. I’ts would be helpful.
And I also wanna find the method using Craft. I suppose making 9 cubes as a group and rotate the whole of the group around the center of it.
Is there a notion of a Craft group? I know that entities can have parents, but that wouldn't work for a rubik's cube because you'd have to be continually shifting parents and tracking which face was being rotated at a time.
@cuvota Making 9 cubes as a group and rotating it won’t work because the corner cubes can be rotated in different groups.
@dave1707 i just said "OMG, it's coloring the vertices!"
Not sure about this post, but I’ll use the dice example from the other discussion to show a cube with different colors on each side.
@RonJeffries - yup, if you build up a mesh for the texture, using triangles, different colours at the vertices will produce colour gradients so you can produce quite complex images.