Author |
Message |
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 05 May 2009 07:43:40 pm Post subject: |
|
|
I couple of days ago i tried to make 3D graphic on the calculator. I did it on basic but i couldn't apply a camera to it. I'm wondering how to apply a camera to it and using that knowledge to do it in Assembly. Also you can be as vauge or specific as you want as i basically i can only make 3D things in Basic using lines |
|
Back to top |
|
|
Galandros
Active Member
Joined: 29 Aug 2008 Posts: 565
|
Posted: 06 May 2009 11:44:50 am Post subject: |
|
|
tiuser1010 wrote: I couple of days ago i tried to make 3D graphic on the calculator. I did it on basic but i couldn't apply a camera to it. I'm wondering how to apply a camera to it and using that knowledge to do it in Assembly. Also you can be as vauge or specific as you want as i basically i can only make 3D things in Basic using lines
Could you post the BASIC program when it is done, please? I would like to learn too. :biggrin:
I would like to do a simple BASIC program to do:
view a 3D cube
capable of changing the observer position and the "direction" (or focus?) of the eyes
rotate the 3D cube
You don't need to super optimize it, at least in the first example. Ijust need to understand the implementation.
*waiting anxious and sitted* |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 06 May 2009 05:34:44 pm Post subject: |
|
|
tiuser1010 wrote: I couple of days ago i tried to make 3D graphic on the calculator. I did it on basic but i couldn't apply a camera to it. I'm wondering how to apply a camera to it and using that knowledge to do it in Assembly. Also you can be as vague or specific as you want as i basically i can only make 3D things in Basic using lines
I was working on something like that too a while ago, this is the topic it is on. I had some luck at applying a camera, but it wasn't perfect, and I couldn't quit figure out how it works, if I were you I would look up perspective projection on Wikipedia. What exactly was the code you used? |
|
Back to top |
|
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 07 May 2009 12:24:11 am Post subject: |
|
|
Hmm, well, let's start out with some geometry.
Assume, first of all, that the eye is a point. If you imagine that there is actually a 3-dimensional scene floating behind your calculator screen, then what you want to do is, for each object in the scene, draw a line from that object to your eye. The place where that line intersects the screen is where you want to draw the object.
So, let's say that our eye is at (0, 0, 0), and the screen is the plane Z = 500. If we have an object located at (Xw, Yw, Zw), then the line from the eye to the object is defined by (X(t), Y(t), Z(t)) = (Xw * t, Yw * t, Zw * t). The place where that intersects the plane Z = 500 is [whiteout](Xw * 500 / Zw, Yw * 500 / Zw, 500)[/whiteout].
Now, if you were to try to implement this, you'd probably run into a couple of problems. First, we defined X = 0, Y = 0 to be the position of the eye, but the normal convention is that X = 0, Y = 0 is the top left corner of the screen. So, after you apply the above transformation, you then want to [whiteout]subtract 47 from X and subtract 31 from Y[/whiteout] before calling your drawing functions.
The second problem is what happens when Z = 0. (Think about that: what does it mean for an object to be at Z <= 0?)
If all of that made sense, we can move on to some more interesting questions, such as moving the viewpoint, in the next lesson.
Last edited by Guest on 12 Jul 2010 01:13:10 am; edited 1 time in total |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 08 May 2009 07:38:00 pm Post subject: |
|
|
Okay here is what i got so far for it:
PROMGRAM: SPACE
[[0,2,2,0,0,0,2,2,0,0][0,0,2,2,0,0,0,2,2,0][0,0,0,0,0,2,2,2,2,2]]->[A] ;3-D matrix
[[0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0]->[C] ; Place holders of your 2-D projection matrix
For(P,1,10) ; Find 2-D projection of 3-D point
[[1,0,0][0,cos(-A),sin(-A)][0,-sin(-A),cos(-A)]]*[[cos(-E),0,-sin(-E)][0,1,0][sin(-E),0,cos(-E)]]*[[cos(-C),sin(-C),0][-sin(-C),cos(-C),0][0,0,1]]->[E]
[E]*([[[A](1,P)][[A](2,P)][[A](3,P)]]-[[0,0,-9]]->[D]
([D](1,1)-1)(9/[D](3,1))->[C](P,1)
([D](1,2)-2)(9/[D](3,1))->[C](P,2)
End
For(P,1,15)
Line([C](1,P),[C](2,P),[C](1,P+1),[C](2,P+1) ;Draws shape
End
Okay i know it is not the best code for this because it takes forever to go through the for loops and the matrix muliplcation so it is very slow and doesn't even work right.
Last edited by Guest on 08 May 2009 07:39:11 pm; edited 1 time in total |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 08 May 2009 08:52:37 pm Post subject: |
|
|
Pretty sweet, should be a good project in ASM.
There are some nice 3D projects around on the z80 calcs, but nothing ever truely finished. There was a cool wireframe quake, Juha3D, qarnos's engine and some other small projects. |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 16 May 2009 10:23:42 pm Post subject: |
|
|
Quote: Hmm, well, let's start out with some geometry.
Assume, first of all, that the eye is a point. If you imagine that there is actually a 3-dimensional scene floating behind your calculator screen, then what you want to do is, for each object in the scene, draw a line from that object to your eye. The place where that line intersects the screen is where you want to draw the object.
So, let's say that our eye is at (0, 0, 0), and the screen is the plane Z = 500. If we have an object located at (Xw, Yw, Zw), then the line from the eye to the object is defined by (X(t), Y(t), Z(t)) = (Xw * t, Yw * t, Zw * t). The place where that intersects the plane Z = 500 is (Xw * 500 / Zw, Yw * 500 / Zw, 500).
Now, if you were to try to implement this, you'd probably run into a couple of problems. First, we defined X = 0, Y = 0 to be the position of the eye, but the normal convention is that X = 0, Y = 0 is the top left corner of the screen. So, after you apply the above transformation, you then want to subtract 47 from X and subtract 31 from Y before calling your drawing functions.
The second problem is what happens when Z = 0. (Think about that: what does it mean for an object to be at Z <= 0?)
If all of that made sense, we can move on to some more interesting questions, such as moving the viewpoint, in the next lesson.
wouldn't z=0 be the plane where your eye is located |
|
Back to top |
|
|
Graphmastur
Advanced Member
Joined: 25 Mar 2009 Posts: 360
|
Posted: 17 May 2009 03:03:57 pm Post subject: |
|
|
no, because if an object was located at (0,0,0) in (x,y,z) coordinate plane, and your object was rotating around (0,0,0) then the camera wouldn't look right. There are also some math complications with it at 0, so watch out with that math, and break it down into smaller pieces and test with many numbers. I don't know for sure, but if you use appBackupScreen or something to maintain a single point, you could look at what value messed it up using an emulator or something. |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 17 May 2009 03:19:00 pm Post subject: |
|
|
wait i think i get it if Z=0, then wouldn't the equation (Xw * 0 / Zw, Yw * 0 / Zw, 0) be undefined |
|
Back to top |
|
|
Graphmastur
Advanced Member
Joined: 25 Mar 2009 Posts: 360
|
Posted: 17 May 2009 06:08:33 pm Post subject: |
|
|
0 times any number = 0, and as such, dividing by zero is mathematically impossible. |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 22 May 2009 02:20:19 pm Post subject: |
|
|
Quote: I was working on something like that too a while ago, this is the topic it is on. I had some luck at applying a camera, but it wasn't perfect, and I couldn't quit figure out how it works, if I were you I would look up perspective projection on Wikipedia. What exactly was the code you used?
Hey Eeems, how do you use your program? (The one on
http://www.cemetech.net/forum/viewtopic.ph...mp;highlight=3d |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 22 May 2009 03:51:46 pm Post subject: |
|
|
well I didn't finish it but I stored
x in L1
y in L2
z in L3
camera in L4 and L5
I can't remember what exactly I did but it worked. I searched perspective projection on Wikipedia and used the formulas there for the camera ones, the other one I borrowed Kerm Martian's 3d engine...I'll send you my last backup of it if you want |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 23 May 2009 10:09:18 pm Post subject: |
|
|
qarnos has a fantastic 3D engine in the works, im pretty sure he will be releasing the source at some stage again too:
Last edited by Guest on 23 May 2009 10:28:24 pm; edited 1 time in total |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 24 May 2009 12:20:24 am Post subject: |
|
|
Holy crap, thats amazing. It might be as good as Graph3D Flash app |
|
Back to top |
|
|
Mapar007
Advanced Member
Joined: 04 Oct 2008 Posts: 365
|
Posted: 24 May 2009 03:42:12 am Post subject: |
|
|
It will most likely be better when it's finished.... |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
|
Back to top |
|
|
|