Computer Science Canada

my crappy 3d engine

Author:  zylum [ Sun Feb 15, 2004 6:03 pm ]
Post subject:  my crappy 3d engine

heres a crappy 3d engine i made, use the mouse to rotate it shape. take the mouse off the screen and the you could use the left/right arrows to rotate and up/down to zoom in/out

Author:  Tony [ Sun Feb 15, 2004 6:07 pm ]
Post subject: 

you forgot to attach the file Confused

Author:  shorthair [ Sun Feb 15, 2004 7:00 pm ]
Post subject: 

Ummmm Is there a file to be attached , Well anyways , Im sure its great and will look at it when its up , Are you new to turing ? or have you been programming for a while

Author:  zylum [ Sun Feb 15, 2004 7:58 pm ]
Post subject: 

oh damn, i thought i did attach it -_-

btw, i'm fairly new to turing, i have had 1 semester of turing last year and have had 2 weeks worth of turing this year so far (new semester)

Author:  Tony [ Sun Feb 15, 2004 8:07 pm ]
Post subject: 

lol Laughing I wanted to delete one of 2 attachments but seeing as they got the same filename, I guess it deleted them both Laughing

sorry about that Razz

Author:  zylum [ Sun Feb 15, 2004 8:09 pm ]
Post subject: 

lol, i guess i'll post it again...

Author:  TheXploder [ Sun Feb 15, 2004 8:24 pm ]
Post subject: 

wow, that is amazing...who would of though that Turing would be capable of this, good job.

Author:  Tony [ Sun Feb 15, 2004 8:25 pm ]
Post subject: 

looks sweet Very Happy And turing is capable... Catalyst and Homer already wrote their engines a while back...

thought this one errors out if I move my mouse to the right far enough (array out of range)

Author:  jonos [ Sun Feb 15, 2004 8:28 pm ]
Post subject: 

that is awesome, so smooth and unexpected. one of the best ive seen and has a lot of potential for some cool stuff like making a program in turing to build models and whatnot. great program Very Happy Very Happy

Author:  shorthair [ Sun Feb 15, 2004 9:28 pm ]
Post subject: 

turing cant build moels although it may with immense tweaking beable to move them like move blocks aroud ot make shapes , actually though i guess if you had impoorted all hte model shapes , you could make models but this is very very complicated, good old basic has commands to do it for you

Author:  AsianSensation [ Sun Feb 15, 2004 9:32 pm ]
Post subject: 

not bad, here, have some bits

+50 bits

Author:  zylum [ Sun Feb 15, 2004 9:35 pm ]
Post subject: 

lol i just noticed that this engine is only 100 lines long!!!

btw, thanks for the input guys...

Author:  Maverick [ Sun Feb 15, 2004 9:36 pm ]
Post subject: 

Sweet prog u got there.

Author:  Andy [ Sun Feb 15, 2004 9:39 pm ]
Post subject: 

wait... u just noticed??? you programed this thing... unless oh man... we got a nother noobie scamming bits off us

Author:  zylum [ Sun Feb 15, 2004 9:44 pm ]
Post subject: 

newbie, wtf... i just programmed it yesterday and it ended up being 200 lines long with an assortment of controls but the engine itself is 100 lines long an i just noticed that looking through my program trying to fix a couple of bugs...

plz don't be so hasty as to accuse me without all the facts...

-zylum

Author:  AsianSensation [ Sun Feb 15, 2004 9:46 pm ]
Post subject: 

we are in the western world now dodge, it's innocent until proven guilty, not the other way around Rolling Eyes (too much chinese propaga...I meant education does mess with your morals...)

besides, 3D isn't that bad, it's basicly asking whether you have the ability to think outside of the xy plane, and into the xyz plane, do some vector stuff, 3D pythagoras, as I said, not that bad.

Author:  Maverick [ Sun Feb 15, 2004 9:46 pm ]
Post subject: 

psst. He was joking

Author:  zylum [ Sun Feb 15, 2004 9:52 pm ]
Post subject: 

i wasn't under the impression that he was joking ie smileys.

i don't mind anyways, it's his job as a mod to look for cheaters and such

Author:  shorthair [ Sun Feb 15, 2004 9:57 pm ]
Post subject: 

Quote:

Zylum Said : btw, i'm fairly new to turing, i have had 1 semester of turing last year and have had 2 weeks worth of turing this year so far (new semester) [/u]


Thinking Thinking Thinking

Dosent look like a newbish program to me

Author:  AsianSensation [ Sun Feb 15, 2004 10:02 pm ]
Post subject: 

1 semester of turing is plenty, SilverSprite made raycasting engine in 1 semester of turing, I'd know, that was part of our midterm project. It basicly all depends on the person's ability in logical thinking. For all we know, zylum could be an incredible math students who have no trouble with vector laws and etc, and then, wouldn't it be easy for him to make a simple 3D program?

Author:  jonos [ Sun Feb 15, 2004 10:13 pm ]
Post subject: 

it also depends on teachers and how good your program at school is. the compsci at our school sucks, i learned almost all on my own.

Author:  zylum [ Sun Feb 15, 2004 10:14 pm ]
Post subject: 

thanks for the support asiansensation,

it just so happens that i am quite good at math and logical thinking. i'd also like to note that i have had previous programming experience with flash actionscript and seeing as turing is such a simple language, it was really to switch over

i thought this would have ended with my previous post -_-

Author:  shorthair [ Sun Feb 15, 2004 10:18 pm ]
Post subject: 

Well on that note , im quite impressed with this app , and your isometric was really well done.... Keep up this excellent work , been here for a day and already gettin lots of attention , dont jsust chuck all your stuff in at once ,compsci isnt going anywhere , Very Happy Very Happy ...... Whats the array error in hte program though , is the mouse in an array when you move it out of the screen srea

Author:  zylum [ Sun Feb 15, 2004 10:24 pm ]
Post subject: 

i ought to fix that... i tried to make my program more efficient by making a look up table for sin and cos so that it wouldnt have to do those calculatoins at runtime... the look up table is an array and i guess when you go to the extreme up and right the specified angle is greater than 360 resulting in an error...

Author:  Homer_simpson [ Sun Feb 15, 2004 11:26 pm ]
Post subject: 

nice... both mine and catalyst 3d engine are open-sourced in the forum u might wanna take a look at those...

Author:  Catalyst [ Mon Feb 16, 2004 12:10 am ]
Post subject: 

good job Very Happy

about the look up table thing just make the array go from like -1200 to 1200 it will solve the problem (well ive never had a problem doing it that way Laughing )

edit : tony's way is better

shorthair:
shorthair wrote:

turing cant build moels although it may with immense tweaking beable to move them like move blocks aroud ot make shapes , actually though i guess if you had impoorted all hte model shapes , you could make models but this is very very complicated, good old basic has commands to do it for you

turing can be used to edit and create models and its not that complicated (turing can do anything, just not quickly)

Author:  Tony [ Mon Feb 16, 2004 12:15 am ]
Post subject: 

you should have used
code:

angle mod 360


that way you can keep on rotating it indefinatly since as soon as the number gets to 360+ it will be cut down to keep it within the range

got to watch out for the negatives thought. If angle is under 0, use
code:

 -(abs(angle) mod 360)

Author:  zylum [ Mon Feb 16, 2004 12:22 am ]
Post subject: 

hmm, that's exactly what i used and i tried to replicate the error and it doesnt occur here... does anyone else have this problem???

Author:  shorthair [ Mon Feb 16, 2004 4:04 pm ]
Post subject: 

Catalyst how could it bult models , i dont understand how turing could resize an object, or build an object , i take it you would need to write many classes to do it , but whats the basis around doing it

Author:  Cervantes [ Mon Feb 16, 2004 5:06 pm ]
Post subject: 

Nice program Very Happy
I like how it follows the mouse

Author:  Tony [ Mon Feb 16, 2004 5:18 pm ]
Post subject: 

shorthair - you'd just need to design an interface similar to any of 3D design programs (3DSMAX, Maya, etc) to locate vertices in 3D space. After that you'll have your own 3D modeling program in turing Laughing

Author:  Mazer [ Mon Feb 16, 2004 5:44 pm ]
Post subject: 

tony, I'm probably annoying you by now (and if not, I will eventually), but I can't help but notice you forgot to mention Blender. Anyways, shorthair, 3D models aren't much more than a bunch of faces made up by 3 (usually) vertices which aren't much more than 3 variables for position. Of course the models could have more than that but it's all you really need for things like rotating, translating, and scaling (with trig of course).

Author:  shorthair [ Mon Feb 16, 2004 6:03 pm ]
Post subject: 

Cool , i jsut couldnt get my heasd around the idea , but after looking at rhino , all you would have to do isceat a z axis , and from there make your variables , would take alot of code to make a nice one , but its all about the z axis

Author:  Mazer [ Mon Feb 16, 2004 6:24 pm ]
Post subject: 

I've never tried my hand at 3D in turing, but I read somewhere that to get simple perspective, just take the Z coord and divide the X and Y coords by it. ie, draw a point (X,Y,Z) at (X/Z, Y/Z).

Author:  jonos [ Mon Feb 16, 2004 6:29 pm ]
Post subject: 

could you explain that a little better.

Author:  Mazer [ Mon Feb 16, 2004 6:42 pm ]
Post subject: 

I guess.
The basic idea is that you need to make the illusion of perspective (which uses 3 dimensions) and display it on a 2D surface (you're screen). Since turing doesn't have a command for drawdot (x,y,z,clr) you have to find a way to make it look like the Z coordinate of your vertice has any affect on it's perceived distance, or depth (whoa, don't I sound smart...).

To do this, you divide both the X and Y coordinates by the Z coordinate.
If you had a 2D point (X, Y) and wanted to draw it in 3D with a depth of Z (let's just make Z = 3 for this example), you would now draw it at (X/3, Y/3).
Here's a basic example of what I mean.

code:

var x, y : array 1 .. 4 of real

x (1) := -50
x (2) := 50
x (3) := 50
x (4) := -50
y (1) := -50
y (2) := -50
y (3) := 50
y (4) := 50

for z : 1 .. 100
    for i : 1 .. 4
        drawdot (round (x (i) / z) + maxx div 2, round (y (i) / z) + maxy div 2, 7)
    end for
    delay (60)
end for

Keep in mind that isn't exactly perfect, but it should give you an example of what I mean. And on the Z axis, it's increasing as it goes into your screen.

Author:  jonos [ Mon Feb 16, 2004 6:55 pm ]
Post subject: 

thanks, that really helped. but is there a way to do that with squares and lines and stuff, i don't understand any of the other things.

Author:  zylum [ Mon Feb 16, 2004 6:59 pm ]
Post subject: 

yup mazer is right. that's also the method i use but ofcoarse you wouldnt just divide it by the z, that would creat some crazy amounts of perspective. would would divide it by (z/your perspective constant) the constant is usually between 200 and 500...

Author:  zylum [ Mon Feb 16, 2004 7:03 pm ]
Post subject: 

to do it with lines and stuff, you'd need to store your coordinates in arrays or matrices and have procedures to manipulate them in 3d space. after all these coordinates are manipulated, you add the perspective and then draw the shape.

sorry i can't explain in more detail, i gtg now Sad

Author:  jonos [ Mon Feb 16, 2004 7:11 pm ]
Post subject: 

maybe someone will just do a tutorial on it, i don't think there is one. anyways, to stick to the topic: awesome engine i still want to play with it everytime im in this thread.

Author:  josh [ Mon Feb 16, 2004 7:48 pm ]
Post subject: 

Wow this thing is awsome.

i wish I I could do something like that.

neato

One problem is that the screen isn't big enough so the mous moves of the screen before I can get it to rotate fully and when I put the mouse back on it moves it back to it's original position

Author:  Cervantes [ Mon Feb 16, 2004 7:59 pm ]
Post subject: 

Well Mazer explained the basis of it pretty well. Try making a simple one yourself! I'm going to try Smile

Author:  zylum [ Tue Feb 17, 2004 9:49 pm ]
Post subject: 

if you want to rotate it more just take your mouse off the screen and then use your left/right arrow keys... also you could zoom in/out using the up/down arrow keys...

maybe later i'll make a simple tutorial on "pseudo" 3d which is a lot easier, but it's not really 3d. oh and it only works with wireframe so it's really basic...

Author:  AsianSensation [ Wed Feb 18, 2004 7:55 am ]
Post subject: 

zylum wrote:
"pseudo" 3d


we have raycasting engine and some other pseudo-raycasting engine here on this website somewhere.....

Author:  Andy [ Thu Feb 19, 2004 8:40 pm ]
Post subject: 

lol zylum, i didnt mean to imply that u were cheatin... just saying how its weird that u didnt notice the length of ur code... i usually pride myself on that lol. and lol u called me a n00b... juss wait until u get ur hands on my whatdotcolor programs


: