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

#1 2008-06-29 10:54:24

bigB
Scratcher
Registered: 2007-06-09
Posts: 100+

3D Perspective Tutorial

Just a little tutorial to explain how to show persective on scratch.

Perspective is How we view a 3D world in just 2 dimensions.
   Objects in the distance look smaller than objects close too but there are other things to consider with perspective as well.

Firstly when dealing in 3 dimensions a Z variable is used as well as X and Y.
The Z variable deals with how far in front or behind you an item is.

When Starting off choose the sprite that you are going to view with perspective.
In this sprite make three variables called X, Y and Z.  It may help later on to make these variables for that sprite only.
   Now start your script by setting each of the variables to a random number.  Use numbers between about -1000 and 1000.  If you want the object to be in front of you make the Z variable positive and preferably at least about 500.
   Now make the sprite that you are going to view from.  This could be a person or animal or plane.  Remember you are looking at it from behind.
   In this sprite make new variables called something like personX personY and personZ.  make these variables work for all sprites. 
   In this sprite you can make you movement scripts, but instead of moving the sprite you are just changing variables.  For Example if key up arrow pressed change personY by 5, or if left arrow pressed change personX by -5.  You can also have if space pressed change personZ by 5.
   Now go into the sprite you want to look at.  This is where you calculate where the sprite should be on the screen.  Make a forever loop and inside it put this script:
Set X position to [(X-personX)/(Z-personZ)]x200
Set Y position to [(Y-personY)/(Z-personZ)]x200
Set size to ???/(Z-personZ)%
you'll have to try using different numbers for the ???'s but numbers around 10000.

You can also copy the sprite you are viewing so there are 2 or more objects to look at.

Last edited by bigB (2008-06-29 10:57:01)


http://scratch.mit.edu/projects/bigB/260981 Draw to Text
http://scratch.mit.edu/projects/bigB/181829 3D Stunt Flyer

Offline

 

#2 2008-06-29 11:33:11

s_federici
Scratcher
Registered: 2007-12-18
Posts: 500+

Re: 3D Perspective Tutorial

Thanks bigB, very simple and intuitive tutorial.

Offline

 

Board footer