Skip to main content
gamedev.net
🔒 Locked

3D Engine

Started by Saba Jun 29, 2000 at 3:52 AM 5 replies 350+ views
Original Post
Saba
Saba
OK, here goes: I am using Pascal/Delphi and I want to make a 3D cube spinning. This will be my first attempt at doing anything 3D. I will just be drawing onto the canvas of the form. I want to know how to create a simple wireframe cube spinning on the form. I would like to know how to do this manually because I really need to know the concepts behind it. What would be the easiest way to do this, without going into asembly. I am using Pascal/Delphi, but I understand C++. Any help would be apprieciated. Thanks, Saba
XBTC
XBTC
Read the huge portal-series on www.flipcode.com,the first couple of articles describes the coding of a simple software wire-frame renderer and starts with rendering a cube....

HTH,XBTC!
Saba
Saba
I meant doing the good ol'' manual way. No direct-draw rubbish or stuff like that. I mean doing it MANUALLY. :-) Sorry, but I can do anything except 3d, and its starting to annoy me :-)
Jrz
Jrz
saba, obviously you don''t have a clue
to drawing line manually you''ll need a buffer to draw on, now you could do that with GDI, but ddraw is faster.
ddraw does not provide any functions to draw lines, so you''ll have to do it manually

''but I can do anything except 3d'' emm I don''t get it
JOL
JOL
Well.... it''s not easy to explain without drawing and stuff like that, but here''s one way

we will represent the coords of the corners of the cube with x,y,z

then figure out how to rotate these points in space around some kind of centerpoint. i mean, this representation has nothing to do with what you see on the screen (in a way), as long as you decide how to represent a world with 3 dimensions and know howto then that problem is solved.

ok so now we have made us a 3d world .... to bad it can''t be seen yet but thats because we dont know where the points will be on the screen that is the tricky part.

ok, consider your 3dworld to be inside the screen. ok, so where would i see the actual point, that is inside there, on the screen, well of course by drawing a line between the point and your eye. ok so how do we accomplish that. you have the z of the point,(and x, y) but not the screenx, screeny locations, (where the line from your eye to the point intersects the screen). now if we draw a straight line from the screen center to your eye and add the points z coord we will have a triangle (for now we will ignore the y coord because we can calculate the x and y seperately), that triangle is the same shape as the triangle formed by the point.z coord and point.x - newscreen.x and the line we first draw as the hypotenusa.
ok...
(point.z + viewdistance from screenconstant)/point.z = point.x / point.x - screen.x

write this formula on some paper and derive what you need

do the same thing with the y coords and your done...


hm.. sounds complicated
but actally isn''t.

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I'm looking for work
JOL
JOL
hm...
did anyone get that.....
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I'm looking for work
warpexplorer
warpexplorer
I just finished writing a simple 3D wireframe engine that can do all the stuff you want(i think) and it doesnt use a buffer or all that stuff it just uses the LineTo command to draw the lines in the window and then i clear the window and draw the lines again it does this every time you rotate the object. its not very fast but it works. the source is in C++ but its very simple.
If you want the source code or info on how it works you can contact me at roundup@midrivers.com or ICQ UIN: 2434022

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.