So I was attempting wireframe 3d, and made a cube, and it was extremely glitchy. Here's a short version of the script without the rotation or camera if anyone can fix it, unless ill just have to start from scratch (haha)
when gf clicked set [fl v] to [50] set [xr v] to [0] set [yr v] to [0] set [zr v] to [0] set [cx v] to [0] set [cy v] to [0] set [cz v] to [200] forever if <key [left arrow v] pressed?> change [xr v] by (3) end if <key [right arrow v] pressed?> change [xr v] by (-3) end if <key [up arrow v] pressed?> change [yr v] by (3) end if <key [down arrow v] pressed?> change [yr v] by (-3) end pen down set [i v] to [1] set [xy v] to ((( [cos v] of (xr)) * (item (i) of [y v] )) - (( [sin v] of (xr)) * (item (i) of [z v] ))) set [xz v] to ((( [sin v] of (xr)) * (item (i) of [y v] )) + (( [cos v] of (xr)) * (item (i) of [z v] ))) set [yz v] to ((( [cos v] of (yr)) * (xz)) - (( [sin v] of (yr)) * (item (i) of [x v] ))) set [yx v] to ((( [sin v] of (xr)) * (xz)) + (( [cos v] of (yr)) * (item (i) of [x v] ))) set [zx v] to ((( [cos v] of (zr)) * (yx)) - (( [sin v] of (zr)) * (xy))) set [zy v] to ((( [sin v] of (zr)) * (yx)) + (( [cos v] of (zr)) * (xy))) change [i v] by (1) set [sf v] to ((fl) / ((fl) + (((yz) - (cz)) + (item (i) of [z v] )))) go to x: ((((zx) * (sf)) + (((cx) * (-1)) * (sf))) * (zoom)) y: ((((zy) * (sf)) + (((cx) * (-1)) * (sf))) * (zoom)) clear endThanks in advance if anyone can help (and I'm unsure as to wheter this belongs in advanced topics
Offline
well the first problem i see is the clear is at the end of the script
always put it at the beginning
the next problem i see is there's only one go to. cubes have 8 vertices, therefore there should be multiple go-to's
Offline
Again. "a short version". It's actually got 16 of those which are the basic building blocks. The clear is only after the first one so that there's no trace line. Sorry for not clarifying well.
Offline
Bump. Anyone?
Offline
Bump. ANYONE? (emphasis )
Offline
The ones that aren't obvious- c(_) is camera position, (_)r is a rotation, and fl and sf are focal length and scale factor respectively. Thanks for replying
Offline
I think all you should have to do is switch the clear and the pen down. Make sure the pen is lifted at the end of the script as well.
Offline
Actually that wouldn't matter, it clears after going to the firt point. If you want to see the full script and results... http://scratch.mit.edu/projects/zubblewutests/2763114
Offline
zubblewu wrote:
Actually that wouldn't matter, it clears after going to the firt point. If you want to see the full script and results... http://scratch.mit.edu/projects/zubblewutests/2763114
It doesn't matter in theory, but Scratch doesn't always run in the same way you think...try the suggestions you're given, it can help us give you a valid solution.
Offline
AtomicBawm3 wrote:
zubblewu wrote:
Actually that wouldn't matter, it clears after going to the firt point. If you want to see the full script and results... http://scratch.mit.edu/projects/zubblewutests/2763114
It doesn't matter in theory, but Scratch doesn't always run in the same way you think...try the suggestions you're given, it can help us give you a valid solution.
I'll try that when I have a chance (aka tomorrow)
Offline
Bumpeth
Offline
Bumpeth. Again.
Offline
Ummm bump...
Edit: 600th post
Last edited by zubblewu (2012-09-18 17:09:49)
Offline
Did you try the idea? What happened if you did? I need details before I can help...
Offline
Ok, first thing I noticed now is that your calculation for rotations is backwards. It should be addition (for xy) and then subtraction (for xz) etc.
Second, your 'sf' (scale factor?) Is incorrectly calculated. You should be using 'yz' instead of "item i of z."
Third, you can combine your terms to simplify the location:
( (sf)*( (zx) - (cx) ) ) * (zoom)
( (sf)*( (zy) - (cy) ) ) * (zoom)
Offline