Browse Search Popular Register Upload Rules User list Login:
Search:
Solid 3D Cube

Image:
screenshot of the scene

Author: s_noonan

Group: Default

Filesize: 22.79 kB

Date added: 2023-02-26

Rating: 6.5

Downloads: 4003

Views: 626

Comments: 26

Ratings: 4

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

This scene's code is a rework of Xray's code with added code to determine polygon drawing order. This scene has 11 _vars while Xray's scene has 27 Scene.my.vars. This scene has 104 custom lines of code (CLOC) vs. Xray's scene with 118 CLOC. The blue "Thyme Script" box can be used as a Component (phunlet).

Rev A: Added perspective. Code now 123 CLOC.
Rev B: Kill old polygons when new ones are created.
Last edited at 2023/02/28 23:23:16 by s_noonan
Please log in to rate this scene
edit
Similar scenes
Title: Solid Cutter - 500 (Read Description And Comment)
Rating: 5
Filesize: 499.98 kB
Downloads: 1338
Comments: 4
Ratings: 1
Date added: 2013/01/31 01:20:58
Made with: Algodoo v2.0.1 Edu
Rating: rated 5
download
Title: Optical Illusion 1 Solution
Rating: 5
Filesize: 16.96 kB
Downloads: 2067
Comments: 0
Ratings: 1
Date added: 2022/04/20 10:40:38
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: companion cube hates life
Rating: 5
Filesize: 35.29 kB
Downloads: 857
Comments: 0
Ratings: 1
Date added: 2010/09/11 15:35:52
Made with: Algodoo before v1.8.5
Rating: rated 5
download
Title: Cube Dispencer 2
Rating: 5
Filesize: 268.8 kB
Downloads: 796
Comments: 1
Ratings: 1
Date added: 2012/03/26 01:15:13
Made with: Algodoo v2.0.1
Rating: rated 5
download
Title: 3D full rotable half - cube 360 x 360
Rating: 7.1539
Filesize: 10.03 kB
Downloads: 718
Comments: 2
Ratings: 7
Date added: 2010/04/30 15:32:31
Made with: Algodoo before v1.8.5
Rating: rated 7.2
download
Title: Cubes on a Teeter-Totter
Rating: 5
Filesize: 7.51 kB
Downloads: 855
Comments: 0
Ratings: 1
Date added: 2024/06/19 12:59:43
Made with: Algodoo v2.1.0
Rating: rated 5
download
This scene is a response to:
Title Author Rating Downloads Comments Date added
Solid 3D Cube Xray 6.1 (3 votes) 4676 23 2023/02/12 19:32:37
show grid
niceeee.
OMG, this is awesome! :o I have been trying to do exactly what you have done and you beat me to it. I am impressed beyond words. :tup: _o_ :tup:
Oh, by the way, I have been thinking about working on other motions with the cube such as changing the scale and translation, and maybe even displaying it in perspective projection. Those challenges would probably take me many weeks to learn the math, and then to design and debug the code, so would you be interested in tackling those things? You are much more gifted than I am when it comes to those sorts of things.
Thanks guys. Adding perspective wasn't too bad but figuring out the order of polygon creation was a struggle.
Wow, you never cease to amaze me, Mr Noonan! :tup:

Oh, and I'm happy that you placed comments in your code because it helps me (and others) to understand what's going on. I just began learning about affine transformations a few years ago, and now using the math in a real-world application helps me to understand most of it. Thanks again!
Last edited at 2023/02/27 03:31:15 by Xray
Yeah!! this is what i was talking about i don't know how the code works but it is awesome :tup:
s_noonan -- There's a little glitch in my code that always bothered me and I see that it transferred over to your scene. When rotating x, y, or z axes there's a little "hiccup" that occurs when the theta switches from -pi to +pi OR from +pi to -pi. I found that the transition can be made a lot smoother by adding a small +0.1 or -0.1 offset when the transition occurs. Here is the code change that seems to work well. Try it and let me know what you think about it:

keys.isDown("right") ? {
_a = _a < - math.pi + 0.1 ? math.pi : _a - 0.05
} : {};
keys.isDown("left") ? {
_a = _a > math.pi - 0.1 ? - math.pi : _a + 0.05
} : {};
keys.isDown("up") ? {
_b = _b < - math.pi + 0.1 ? math.pi : _b - 0.05
} : {};
keys.isDown("down") ? {
_b = _b > math.pi - 0.1 ? - math.pi : _b + 0.05
} : {};
keys.isDown("[1]") ? {
_c = _c < - math.pi + 0.1 ? math.pi : _c - 0.05
} : {};
keys.isDown("[0]") ? {
_c = _c > math.pi - 0.1 ? - math.pi : _c + 0.05
} : {};
Thanks. I changed the code per your recommendation and see the improvement, but now I'm wondering why the code has the +/- math.pi limitation. _a = _a - 0.05 seems to work OK. _a = _a % (2.0* math.pi) - 0.05 also seems to work OK.
Quote: "...I'm wondering why the code has the +/- math.pi limitation"

Reply: I think it's because rotations are calculated in radians, but not sure. There are 2pi radians in 360 degrees, which might explain the +/- math.pi limits.
I understand that Thyme angle functions work in radians, but I don't believe that the added (pi limiting) code does anything useful. I was hesitant to remove the code since Chesterton's fence quote states "Don't ever take a fence down until you know the reason it was put up.". Since you don't know why pi limiting is in there, then I will probably take it out. The only issue I see with removing the limitation is that if you did enough rotations, the angle could be so large that the angular resolution suffers. That won't happen with this scene. At first I thought the limitation might have something to do with gimbal lock, but I don't believe that to be the case.
Last edited at 2023/02/28 23:17:08 by s_noonan
Quote: "The only issue I see with removing the limitation is that if you did enough rotations, the angle could be so large that the angular resolution suffers."

Reply: I didn't think of that, but you are right. :blush:

More: I like how you changed the code to make a smooth rotation. I won't blame you at all if you decided to not add variable scale and translation because the code has gotten rather complex at this point. Adding more features might muddle the design. You already have done some very impressive work in my view. _o_
Last edited at 2023/03/01 02:15:31 by Xray
Scale and translation should not be too hard to add. I will probably add it within the next week but OK if you beat me to it. Use any of my code that you want since I copied most of yours. While you are at it you could add a texture to one face of the cube.
Okay, I'll see what I can do with it. Thanks.
I had no problem adding textures to the surfaces but I am really struggling to make those textures rotate properly with their respective polygons. :(
I don't know if texture matrix supports projective transformations. I know tm supports scale, offset, and rotation. I haven't seen tm do any keystoning of images.
Quote: "I haven't seen tm do any keystoning of images. "

Yup, I believe that's the problem. :mad:
If we don't use perspective projection on the cube then there should be a way to make the image fit. The information is in Transform Polygon and/or Rotate Polygon.
Quote: "If we don't use perspective projection on the cube then there should be a way to make the image fit."

I agree, but it just isn't working out for me. Your code is a lot different than mine, and because of that I'm having trouble understanding it and getting it to work. I don't have the coding knowledge and experience that you have which makes it much more difficult for me to attempt to modify it. I might be able to get something to sort of work, but it will take a lot of time, and you would probably point out how it could have been done more efficiently in terms of lines of code and execution speed. So, I'm hoping that you would still be interested in taking on the task of doing those things that we have discussed earlier. I'm always impressed by the awesome Algodoo scenes that you have posted over the years, and I learn a lot from them, as I'm sure others do too.
I will probably give it a shot. I remember struggling with Rotate Polygon. Where's Kilinich when you need him?
Last edited at 2023/03/05 12:11:47 by s_noonan
Quote: "Where's Kilinich when you need him?"

I don't know, but I sure hope he'll come back to Algobox and upload more of his amazing scenes!
That is amazing! well done :tup:
Thanks lololoer! :)

Hey, my friend..... It's been about three years since you've uploaded your last scene. Is there a chance you might decide to create and upload a few more in the near future? Your scenes are amazing too! :tup:
s_noonan, can you please explain to me how the rotation works, I'm trying to make a 3D game engine on algodoo and I cant seem to implement 3D rotation.
Averagecoder you can use rotation matrices, you just need to dot multiply each one by each other by the order z,y,x I'm pretty sure and then you dot multiply the combined matrix with the 3d position, that will give you the position of the point rotated around [0,0,0] by the 3 angles x,y and z and yeah I think that's how it works.
I am trying to make a cube with a 3D polygon renderer I made, and I am basically just NOT able to get camera rotation to work. It seems like it is creating some problems with some points getting behind the +z axis. I also do NOT understand how Z-clipping can work. Checking this scene to see what I'm doing wrong...