Can some help me add better cubes to my 3d engine?
id: 746994
category: Help with Scripts
posts: 10
Mar 11, 2024 15:10:03
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Coding3dnow
loading
hello i am currently making a 3d engine I have all the hard parts down I just need help adding a cube that you can rotate
https://scratch.mit.edu/projects/972151946/
https://scratch.mit.edu/projects/972151946/
Mar 11, 2024 15:44:06
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Create-Scratch101
loading
hello i am currently making a 3d engine I have all the hard parts down I just need help adding a cube that you can rotate
https://scratch.mit.edu/projects/972151946/
Sorry sir, but 3d Engines are fairly hard to make. Searching “3D Engine” may help (look at the code)
Mar 11, 2024 16:01:55
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Coding3dnow
loading
oh I already have a 3d engine I just need to add stuff in it like cubes but it is already workinghello i am currently making a 3d engine I have all the hard parts down I just need help adding a cube that you can rotate
https://scratch.mit.edu/projects/972151946/
Sorry sir, but 3d Engines are fairly hard to make. Searching “3D Engine” may help (look at the code)
Mar 11, 2024 16:07:21
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
NIKI-KOLCHAGOV
loading
Oh interesting
Mar 11, 2024 16:16:11
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
10SmartGaming
loading
To create a cube, you need 6 faces. Each face is made up of either 1 quad or 2 triangles. For the sake of this example I will use quads.
At the very basics, a cube goes like this:
EXAMPLE P1(x, y, z), P2(x, y, z), P3(x, y, z) | P = Triangle Vertice
Tri 1: (0, 0, 0), (0, 1, 0) (1, 0, 0)
Tri 2: (1, 1, 0), (0, 1, 0) (1, 0, 0)
Tri 3: (0, 0, 0), (0, 1, 0), (0, 0, 1)
Tri 4: (0, 1, 1), (0, 1, 0), (0, 0, 1)
Tri 5: (1, 0, 0), (1, 1, 0), (1, 0, 1)
Tri 6: (1, 1, 1), (1, 1, 0), (1, 0, 1)
Tri 7: (0, 0, 1), (0, 1, 1) (1, 0, 1)
Tri 8: (1, 1, 1), (0, 1, 1) (1, 0, 1)
Tri 9: (0, 0, 0), (0, 0, 1) (1, 0, 0)
Tri 10: (1, 0, 1), (0, 0, 1) (1, 0, 0)
Tri 11: (0, 1, 0), (0, 1, 1) (1, 1, 0)
Tri 12: (1, 1, 1), (0, 1, 1) (1, 1, 0)
You can multiply every number by the desired size of the square
At the very basics, a cube goes like this:
EXAMPLE P1(x, y, z), P2(x, y, z), P3(x, y, z) | P = Triangle Vertice
Tri 1: (0, 0, 0), (0, 1, 0) (1, 0, 0)
Tri 2: (1, 1, 0), (0, 1, 0) (1, 0, 0)
Tri 3: (0, 0, 0), (0, 1, 0), (0, 0, 1)
Tri 4: (0, 1, 1), (0, 1, 0), (0, 0, 1)
Tri 5: (1, 0, 0), (1, 1, 0), (1, 0, 1)
Tri 6: (1, 1, 1), (1, 1, 0), (1, 0, 1)
Tri 7: (0, 0, 1), (0, 1, 1) (1, 0, 1)
Tri 8: (1, 1, 1), (0, 1, 1) (1, 0, 1)
Tri 9: (0, 0, 0), (0, 0, 1) (1, 0, 0)
Tri 10: (1, 0, 1), (0, 0, 1) (1, 0, 0)
Tri 11: (0, 1, 0), (0, 1, 1) (1, 1, 0)
Tri 12: (1, 1, 1), (0, 1, 1) (1, 1, 0)
You can multiply every number by the desired size of the square
Mar 14, 2024 13:15:35
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Coding3dnow
loading
ok but how do I rotate that cube by the x y and z axis To create a cube, you need 6 faces. Each face is made up of either 1 quad or 2 triangles. For the sake of this example I will use quads.
At the very basics, a cube goes like this:
EXAMPLE P1(x, y, z), P2(x, y, z), P3(x, y, z) | P = Triangle Vertice
Tri 1: (0, 0, 0), (0, 1, 0) (1, 0, 0)
Tri 2: (1, 1, 0), (0, 1, 0) (1, 0, 0)
Tri 3: (0, 0, 0), (0, 1, 0), (0, 0, 1)
Tri 4: (0, 1, 1), (0, 1, 0), (0, 0, 1)
Tri 5: (1, 0, 0), (1, 1, 0), (1, 0, 1)
Tri 6: (1, 1, 1), (1, 1, 0), (1, 0, 1)
Tri 7: (0, 0, 1), (0, 1, 1) (1, 0, 1)
Tri 8: (1, 1, 1), (0, 1, 1) (1, 0, 1)
Tri 9: (0, 0, 0), (0, 0, 1) (1, 0, 0)
Tri 10: (1, 0, 1), (0, 0, 1) (1, 0, 0)
Tri 11: (0, 1, 0), (0, 1, 1) (1, 1, 0)
Tri 12: (1, 1, 1), (0, 1, 1) (1, 1, 0)
You can multiply every number by the desired size of the square
Mar 14, 2024 14:21:52
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
MineTurte
loading
ok but how do I rotate that cube by the x y and z axis To create a cube, you need 6 faces. Each face is made up of either 1 quad or 2 triangles. For the sake of this example I will use quads.
At the very basics, a cube goes like this:
EXAMPLE P1(x, y, z), P2(x, y, z), P3(x, y, z) | P = Triangle Vertice
Tri 1: (0, 0, 0), (0, 1, 0) (1, 0, 0)
Tri 2: (1, 1, 0), (0, 1, 0) (1, 0, 0)
Tri 3: (0, 0, 0), (0, 1, 0), (0, 0, 1)
Tri 4: (0, 1, 1), (0, 1, 0), (0, 0, 1)
Tri 5: (1, 0, 0), (1, 1, 0), (1, 0, 1)
Tri 6: (1, 1, 1), (1, 1, 0), (1, 0, 1)
Tri 7: (0, 0, 1), (0, 1, 1) (1, 0, 1)
Tri 8: (1, 1, 1), (0, 1, 1) (1, 0, 1)
Tri 9: (0, 0, 0), (0, 0, 1) (1, 0, 0)
Tri 10: (1, 0, 1), (0, 0, 1) (1, 0, 0)
Tri 11: (0, 1, 0), (0, 1, 1) (1, 1, 0)
Tri 12: (1, 1, 1), (0, 1, 1) (1, 1, 0)
You can multiply every number by the desired size of the square
You'd just gradually change it's generation x, y, and z I believe (idk much about how 3D projects work lol)
Example:
Stamp 1: Tri 1: (0,1,1), (0,1,0),(0,0,1)
Stamp 2: Tri 1: (0,1,2), (0,1,1),(0,0,2)
Mar 27, 2024 16:52:59
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
10SmartGaming
loading
I don't know the specifics, but you would definitely use some trig.ok but how do I rotate that cube by the x y and z axis To create a cube, you need 6 faces. Each face is made up of either 1 quad or 2 triangles. For the sake of this example I will use quads.
At the very basics, a cube goes like this:
EXAMPLE P1(x, y, z), P2(x, y, z), P3(x, y, z) | P = Triangle Vertice
Tri 1: (0, 0, 0), (0, 1, 0) (1, 0, 0)
Tri 2: (1, 1, 0), (0, 1, 0) (1, 0, 0)
Tri 3: (0, 0, 0), (0, 1, 0), (0, 0, 1)
Tri 4: (0, 1, 1), (0, 1, 0), (0, 0, 1)
Tri 5: (1, 0, 0), (1, 1, 0), (1, 0, 1)
Tri 6: (1, 1, 1), (1, 1, 0), (1, 0, 1)
Tri 7: (0, 0, 1), (0, 1, 1) (1, 0, 1)
Tri 8: (1, 1, 1), (0, 1, 1) (1, 0, 1)
Tri 9: (0, 0, 0), (0, 0, 1) (1, 0, 0)
Tri 10: (1, 0, 1), (0, 0, 1) (1, 0, 0)
Tri 11: (0, 1, 0), (0, 1, 1) (1, 1, 0)
Tri 12: (1, 1, 1), (0, 1, 1) (1, 1, 0)
You can multiply every number by the desired size of the square
Mar 27, 2024 17:13:01
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Malicondi
loading
Because this was brought back up, I felt that I should answer this and it's quite simple, it just uses a little trigonometry. The formula to rotate around the y axis(left right) is this: ok but how do I rotate that cube by the x y and z axis
x' = (x * cos of (y dir)) - (z * sin of (y dir))
z' = (x * sin of (y dir)) + (z * cos of (y dir))
for the x axis (up down) it's this:
y' = (y * cos of (x dir)) - (z * sin of (x dir))
z' = (y * sin of (x dir)) + (z * cos of (x dir))
and for the z axis (imagine turning your head to the side) it's this:
x' = (x * cos of (z dir)) - (y * sin of (z dir))
y' = (x * sin of (z dir)) + (y * cos of (z dir))
For these, its best to use a custom block to store the original x, y, and z values or this won't work, as x', y', and z' all stand for the changed variables, but the formulas depend on the original values.
For 3d projects, since sin and cos are computationally expensive, using sin and cos in all of these formulas a total of 12 times for a single object is very slow. So i recommend first getting the cos and sin values at the start of every tick before you any formulas to speed this up greatly, like so: (directions will also need variables)
define calc trigin scratch blocks the way to use these formulas will be as so: (i will be using cos and sin variables for this)
set [cosX v] to ([cos v] of (x dir))
set [sinX v] to ([sin v] of (x dir))
set [cosY v] to ([cos v] of (y dir))
set [sinY v] to ([sin v] of (y dir))
set [cosZ v] to ([cos v] of (z dir))
set [sinZ v] to ([sin v] of (z dir))
for y rotation (left right):
set [x v] to (((x) * (cosY)) - ((z) * (sinYfor x rotation (up down):
set [z v] to (((x) * (sinY)) - ((z) * (sinY
set [y v] to (((y) * (cosX)) - ((z) * (sinXfor z rotation (turning head to side):
set [z v] to (((y) * (sinX)) - ((z) * (sinX
set [x v] to (((x) * (cosZ)) - ((y) * (sinZIf you want a little more explanation, see this tutorial.
set [y v] to (((x) * (sinZ)) - ((y) * (sinZ
Hope this helps!
Mar 27, 2024 17:42:11
Can some help me add better cubes to my 3d engine?
view on scratch
view on legacy ocular
Coding3dnow
loading
ya your a little work I already added this it was simpler than I thought but thank you for the helpBecause this was brought back up, I felt that I should answer this and it's quite simple, it just uses a little trigonometry. The formula to rotate around the y axis(left right) is this: ok but how do I rotate that cube by the x y and z axis
x' = (x * cos of (y dir)) - (z * sin of (y dir))
z' = (x * sin of (y dir)) + (z * cos of (y dir))
for the x axis (up down) it's this:
y' = (y * cos of (x dir)) - (z * sin of (x dir))
z' = (y * sin of (x dir)) + (z * cos of (x dir))
and for the z axis (imagine turning your head to the side) it's this:
x' = (x * cos of (z dir)) - (y * sin of (z dir))
y' = (x * sin of (z dir)) + (y * cos of (z dir))
For these, its best to use a custom block to store the original x, y, and z values or this won't work, as x', y', and z' all stand for the changed variables, but the formulas depend on the original values.
For 3d projects, since sin and cos are computationally expensive, using sin and cos in all of these formulas a total of 12 times for a single object is very slow. So i recommend first getting the cos and sin values at the start of every tick before you any formulas to speed this up greatly, like so: (directions will also need variables)define calc trigin scratch blocks the way to use these formulas will be as so: (i will be using cos and sin variables for this)
set [cosX v] to ([cos v] of (x dir))
set [sinX v] to ([sin v] of (x dir))
set [cosY v] to ([cos v] of (y dir))
set [sinY v] to ([sin v] of (y dir))
set [cosZ v] to ([cos v] of (z dir))
set [sinZ v] to ([sin v] of (z dir))
for y rotation (left right):set [x v] to (((x) * (cosY)) - ((z) * (sinYfor x rotation (up down):
set [z v] to (((x) * (sinY)) - ((z) * (sinYset [y v] to (((y) * (cosX)) - ((z) * (sinXfor z rotation (turning head to side):
set [z v] to (((y) * (sinX)) - ((z) * (sinXset [x v] to (((x) * (cosZ)) - ((y) * (sinZIf you want a little more explanation, see this tutorial.
set [y v] to (((x) * (sinZ)) - ((y) * (sinZ
Hope this helps!