Discuss Scratch

ScratchCoolGuy
Scratcher
41 posts

3D wireframe

I can't figure out the coordinates for a cube. Any ideas? This is the project: http://scratch.mit.edu/projects/18134258/
drmcw
Scratcher
1000+ posts

3D wireframe

You need to project 3D coordinates to 2D, see this. For more complex stuff look at DadOfMrLog's projects/studio.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

Accidentally pressed report. Sorry! Meant to press quote. I know how to project 3D like that. I just need to know the items I should put in my list for a cube. Should I use Blender then export as a wavefront, then import

drmcw wrote:

You need to project 3D coordinates to 2D, see this. For more complex stuff look at DadOfMrLog's projects/studio.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

This is off topic but how do you put something under every post you make. Yours says, Blast some bugs Galaga style! Or just discuss any problems with Eliza.
drmcw
Scratcher
1000+ posts

3D wireframe

ScratchCoolGuy wrote:

This is off topic but how do you put something under every post you make. Yours says, Blast some bugs Galaga style! Or just discuss any problems with Eliza.
Go to discussion home and bottom left is a link to change signature. The text at the bottom is a signature.
What you put in the list depends on how you are doing the projection. Typically it's x,y,z coordinates.Think of a square in 2D (-1,1),(1,1),(1,-1),(-1,-1) then add in the z for a front and back face.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

drmcw wrote:

ScratchCoolGuy wrote:

This is off topic but how do you put something under every post you make. Yours says, Blast some bugs Galaga style! Or just discuss any problems with Eliza.
Go to discussion home and bottom left is a link to change signature. The text at the bottom is a signature.
What you put in the list depends on how you are doing the projection. Typically it's x,y,z coordinates.Think of a square in 2D (-1,1),(1,1),(1,-1),(-1,-1) then add in the z for a front and back face.

Thanks!
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

drmcw wrote:

ScratchCoolGuy wrote:

This is off topic but how do you put something under every post you make. Yours says, Blast some bugs Galaga style! Or just discuss any problems with Eliza.
Go to discussion home and bottom left is a link to change signature. The text at the bottom is a signature.
What you put in the list depends on how you are doing the projection. Typically it's x,y,z coordinates.Think of a square in 2D (-1,1),(1,1),(1,-1),(-1,-1) then add in the z for a front and back face.
Look at my signature! Could you enter my contest? Sadly, no one has entered yet.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

ScratchCoolGuy wrote:

drmcw wrote:

ScratchCoolGuy wrote:

This is off topic but how do you put something under every post you make. Yours says, Blast some bugs Galaga style! Or just discuss any problems with Eliza.
Go to discussion home and bottom left is a link to change signature. The text at the bottom is a signature.
What you put in the list depends on how you are doing the projection. Typically it's x,y,z coordinates.Think of a square in 2D (-1,1),(1,1),(1,-1),(-1,-1) then add in the z for a front and back face.
Look at my signature! Could you enter my contest? Sadly, no one has entered yet.

I'm going to try using blender to do it.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

Nevermind, I got it working!
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

your project was interesting
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

Do you know how to make a globe(sphere)? I may need blender for that one.
I also need to know how to do rotation. Should I use trig?
drmcw
Scratcher
1000+ posts

3D wireframe

ScratchCoolGuy wrote:

Do you know how to make a globe(sphere)? I may need blender for that one.
I also need to know how to do rotation. Should I use trig?

You either need to convert a sphere into many polygons and draw it that way or if you look at DadOfMrLog's projects he does it by drawing ellipses.
For rotation you will almost certainly need trigonometry.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

Do you have a tutorial on trigonometry? If not do you know of one?
drmcw
Scratcher
1000+ posts

3D wireframe

ScratchCoolGuy wrote:

Do you have a tutorial on trigonometry? If not do you know of one?
No and No. The username of the Front paged Newton's cradle project is a good start though SOHCAHTOA You will also need to understand matrices if that is the direction you intend to go.
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

Thanks! I'm going to do spheres later. I'll start with trig.
DadOfMrLog
Scratcher
1000+ posts

3D wireframe

The main thing that I think is useful for 3D with Scratch is to understand vectors. Essentially, a vector is just fancy sounding name for a line.

Once you know how to operate on such vectors - in particular, the vector dot product, and the vector cross product, and how such products relate to things like the angle between the lines, the lengths of the lines, as well as the direction the cross product points (90 degrees to both original lines) - then you can do loads of useful stuff. And you barely have to think about trig at all!

Nearly everything I do in my 3D framework works via consideration of 3D vectors. The only place where trig comes in is when rotating an object (or the camera), and that's simply applying a rotation matrix (containing sines & cosines of angles) to certain vectors - so once you've got that bit scripted, you can forget about it, just calling it where needed.

When thinking about vectors in 3D, I find it can help to draw some little diagrams on paper, and/or using fingers and imagination to place vectors where you want them…

Hope there's something useful in there!

ScratchCoolGuy
Scratcher
41 posts

3D wireframe

DadOfMrLog wrote:

The main thing that I think is useful for 3D with Scratch is to understand vectors. Essentially, a vector is just fancy sounding name for a line.

Once you know how to operate on such vectors - in particular, the vector dot product, and the vector cross product, and how such products relate to things like the angle between the lines, the lengths of the lines, as well as the direction the cross product points (90 degrees to both original lines) - then you can do loads of useful stuff. And you barely have to think about trig at all!

Nearly everything I do in my 3D framework works via consideration of 3D vectors. The only place where trig comes in is when rotating an object (or the camera), and that's simply applying a rotation matrix (containing sines & cosines of angles) to certain vectors - so once you've got that bit scripted, you can forget about it, just calling it where needed.

When thinking about vectors in 3D, I find it can help to draw some little diagrams on paper, and/or using fingers and imagination to place vectors where you want them…

Hope there's something useful in there!

Wow! I don't need trig? I'll think about it! Your 3D projects are very inspirational. Do you have any tutorials on rotating objects? I made a mars globe with your globe creator. How do you make a globe? 3D was confusing to me before I started using Blender about a year ago. Since then I've loved it. I just recently figured it out on scratch. It's fascinating. If you know, how did griffpatch make that 3D raycaster maze have different colors on the objects?
DadOfMrLog
Scratcher
1000+ posts

3D wireframe

ScratchCoolGuy wrote:

Wow! I don't need trig?
You can get away with less trig than people generally seem to think (from what I've read around the forums, it's all “oh, for 3D you need lots of trig here, trig there, trig everywhere…”)

Well, it's certainly handy to know how to use it for where you need it (which is mainly for rotations), but I think understanding vectors is far more useful for 3D.

Anyway, just read up on trig here: http://en.wikipedia.org/wiki/Trigonometry

If you get the first couple of paragraphs of its "Overview" section, then that's really all you need to know - the rest can be worked out from the 3 basic definitiions - sine, cosine and tangent - by drawing various perpendicular lines (vectors!) around the place to create right-angle triangles, and applying sin/cos/tan until you relate whatever things (lengths/angles/etc.) you want to know with the things you already know…

ScratchCoolGuy wrote:

I'll think about it! Your 3D projects are very inspirational. Do you have any tutorials on rotating objects?
To rotate an object you need to change the co-ordinates of its points.

It's easiest to think about rotating a point on something like the XY plane (i.e. so the Z axis remains fixed - you're rotating around that axis).

If you have a point at (x,y), the equations for the new point co-ordinates (let's call them “newx” and “newy”), after rotating by angle A measured in an anticlockwise direction when looking down from ‘above’ the XY plane, are:
newx = cos(A) * x - sin(A) * y
newy = sin(A) * x + cos(A) * y

Since the Z axis is fixed in such a rotation, a point's Z co-ordinate will remain the same (i.e. you can think of it like newz = z).

You can do exactly the same kind of things for rotations in the XZ and YZ planes.

ScratchCoolGuy wrote:

I made a mars globe with your globe creator. How do you make a globe?
You mean, how does it work out how to draw the right parts of it onto the right part of the screen…?
Basically, 3D vectors and rotation again. Then it builds up the globe picture by drawing ellipses (ovals), each drawn from numerous sides that have the appropriate pen colour for each side.

ScratchCoolGuy wrote:

3D was confusing to me before I started using Blender about a year ago. Since then I've loved it. I just recently figured it out on scratch. It's fascinating.
Blender is a really great thing to learn. It looks confusing at first, but there are plenty of youtube tutorials to watch, and that helps a lot.

ScratchCoolGuy wrote:

If you know, how did griffpatch make that 3D raycaster maze have different colors on the objects?
I haven't looked at the scripts exactly, but I'd guess it uses a list that contains values that refer to block colour (and a value that means there is no block there at all). A raycaster ‘fires’ out a fan of rays from your position amongst the blocks, and traces each ray through the list of blocks until it hits an item that isn't ‘empty’. Then all it has to do is see what colour that item in the list means, and draw a vertical line in that colour at the right place on the screen.

He added a nice new twist into his raycasting in that he also has a list with height information - meaning when the ray hits a block, he can also look up a height for it. (Though that does bring some extra complications into the tracking of the ray through the blocks…)

I think using a raycaster like this for vertical walls, combined with multiple pre-rendered costumes (each one corresponding to a different viewing angle - see the classic Coin Runners 3D for a great example) is the most effective way to make a good-looking 3D game in Scratch.

Hopefully that all makes some sense!
ScratchCoolGuy
Scratcher
41 posts

3D wireframe

It sure did! So all I have to do to make a globe is make ellipses? I am working on something that scans the scratch cat, then redraws him. It isn't working though. It's kind of like your globe creator where it scans the image you make then draws it in a globe. I figured out how to rotate.

Powered by DjangoBB