This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-09-04 20:26:04

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Wireframe 3d

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

end

Thanks in advance if anyone can help (and I'm unsure as to wheter this belongs in advanced topics  tongue )


........................................................................................................................................................................................................................................

Offline

 

#2 2012-09-04 20:34:53

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Wireframe 3d

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


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#3 2012-09-04 22:05:13

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

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

 

#4 2012-09-08 08:54:34

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

Bump. Anyone?


........................................................................................................................................................................................................................................

Offline

 

#5 2012-09-08 21:40:40

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

Bump. ANYONE? (emphasis  tongue )


........................................................................................................................................................................................................................................

Offline

 

#6 2012-09-10 11:02:58

boaz4
Scratcher
Registered: 2010-04-07
Posts: 31

Re: Wireframe 3d

I could help, but try explain what each of the variables mean.


http://img822.imageshack.us/img822/8274/625265805511fc3m3.png

Offline

 

#7 2012-09-10 16:51:31

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

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

 

#8 2012-09-10 19:35:49

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Wireframe 3d

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.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#9 2012-09-10 19:46:44

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

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

 

#10 2012-09-10 23:09:03

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Wireframe 3d

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.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#11 2012-09-10 23:16:05

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

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

 

#12 2012-09-12 14:56:24

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

Bumpeth


........................................................................................................................................................................................................................................

Offline

 

#13 2012-09-14 12:49:30

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

Bumpeth. Again.


........................................................................................................................................................................................................................................

Offline

 

#14 2012-09-18 17:09:18

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Wireframe 3d

Ummm bump...

Edit: 600th post  yikes

Last edited by zubblewu (2012-09-18 17:09:49)


........................................................................................................................................................................................................................................

Offline

 

#15 2012-09-18 18:40:03

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Wireframe 3d

Did you try the idea? What happened if you did?  I need details before I can help...


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#16 2012-09-18 18:53:51

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Wireframe 3d

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)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

Board footer