Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > line vector cube/parallel lines
2008-08-31 15:48
Testa
Account closed

Registered: Oct 2004
Posts: 197
line vector cube/parallel lines

hello,

i have a question about line vectors (3d projections) lets take for example a cube with 8 corners rotating around in 3d perspective.. each line of the cube got his parallel line(s). the question i have: does this paralell line use the same line patern as the line it is parallel too, so i only have to calculate (linedrawing) this line only one time and reuse the table for the other (parallel) lines.

a friend of my says that this called a orthogon projecttion and not a perspective projection: when you draw for example a house you see in perspective projection that the lines comes closer when farer away and touch at some point in infinity, becoz of this, each line has i own linepatern,
and so you must calculate each line..

i hope you understand my question
mcd


2008-08-31 15:53
Oswald

Registered: Apr 2002
Posts: 5094
your line routine probably doesnt follows the fastest solutions, since those use only one lda # to get the line pattern, as the line-loop is unrolled.

edit: check the c=hacking series on codebase, in the "different perspective.." article series there are various lineroutines discussed.
2008-08-31 16:04
Testa
Account closed

Registered: Oct 2004
Posts: 197
oswald: i don't know what you mean. i use a unrolled routine to calculate lines and store it into a tabel
so i use two separate routines. one for calulating lines and the other for pasting them... thanks anyway... i know
you are a master in vectors...
2008-08-31 16:11
Oswald

Registered: Apr 2002
Posts: 5094
maybe if you paste your line "pasting" source we can be more of a help. I guess you want to save time by reusing slopes.
2008-08-31 17:34
Testa
Account closed

Registered: Oct 2004
Posts: 197
well.

the line calculation routine looks like this:

ldx #0
lda #0

clc
adc $40
cmp $41
bmi con
inx
sec
sbc $41
con stx $0f00
clc
adc $40
cmp $41
bmi con2
inx
sec
sbc $41
con2 stx $0f01

enz


you can skip al the clc and sec when the resuls are never
higher dan $ff (the carry doesn't change in this case)
you also can skip the cmp $41 and just test if the number becomes a negative or positive number..





2008-08-31 17:47
Testa
Account closed

Registered: Oct 2004
Posts: 197
oops i forgot the write down the paste routine
it is nothing special but here it comes.

ldx #0
lda lobyte kolum,x
sta $a0
lda hibyte kolom,x
sta $a1
lda pixel,x
ldy $0f00 (the tabel with the linedrawing data)
ora ($a0),y
sta ($a0),y

enz
2008-08-31 18:26
Oswald

Registered: Apr 2002
Posts: 5094
you can skip both clc and sec:

you start with height in the accu and carry set:

sbc $width
bcs con ; no underflow skip (result>0)
adc $height ;underflow carry CLEAR now
inx ;adc will set carry high again because overflow (result>255)
con stx $0f00

big slope case:

con sbc $width
inx
bcs con
adc $height
stx $0f00

$width and $height may be to be swapped (incl. accu initialisation), I have now just thrown them in without thinking about their orders.

line drawing, can be more precalculated:

ldy $0f0x
lda $currentcolumn,y
ora #pixel
sta $currentcolumn,y
ldy $0f0x
lda $currentcolumn,y
ora #pixel
sta $currentcolumn,y
ldy $0f0x
lda $currentcolumn,y
ora #pixel
sta $currentcolumn,y
...

you simply jump into the above speedcode at you desired "xstart" coordinate, and selfmod it to an rts to exit at the desired "xend" coordinate.
2008-08-31 19:26
Testa
Account closed

Registered: Oct 2004
Posts: 197
hell yeah! very cool! thanks a lot! i hope you don't mind asking you something again but: do you also have a clear answer about parallel lines using the same line-drawn patern... or is it an stopid question..

mcd
2008-08-31 20:07
Oswald

Registered: Apr 2002
Posts: 5094
how about:

lda $0f0x,y ;adjust slope for the needed shift horizontally with Y
adc $offset ;adjust slope for the needed shift vertically
tax
lda actcolumn,x
ora #pixel
sta acrcolumn,x
iny

tho if you count the cycles carefully, it will be clear that its faster to calculate the slope each time :)

like this:

lda actcolumn,y
ora #pixels
sta actcolumn,y
txa
sbc $width
bcs con
iny
adc $height
con tax


even faster, but only if you can come up with a division based on log/exp:

lda actcolumn,y
ora #pixels
sta actcolumn,y
txa
adc $slope ;=widht/height or vice versa depending on the case
bcc con
iny
con tax
2008-09-01 06:09
Martin Piper

Registered: Nov 2007
Posts: 722
Quote: hello,

i have a question about line vectors (3d projections) lets take for example a cube with 8 corners rotating around in 3d perspective.. each line of the cube got his parallel line(s). the question i have: does this paralell line use the same line patern as the line it is parallel too, so i only have to calculate (linedrawing) this line only one time and reuse the table for the other (parallel) lines.

a friend of my says that this called a orthogon projecttion and not a perspective projection: when you draw for example a house you see in perspective projection that the lines comes closer when farer away and touch at some point in infinity, becoz of this, each line has i own linepatern,
and so you must calculate each line..

i hope you understand my question
mcd




Sounds like orthographic projection.
2008-09-01 10:50
Testa
Account closed

Registered: Oct 2004
Posts: 197
martin piper, do you know if it is possible to make a nice 3d projection with this so called 'orthograpics' or do i miss something here... anyway this week i'am gonna study the different perspective articles in c=hacking..
 
... 4 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
LKP/CFN
Dr.Science/Atlantis
iAN CooG/HVSC
Elder0010/G★P
zscs
Youth
MCM/ONSLAUGHT
TheRyk/MYD!
Laddh
Holy Moses/Role
Smasher/F4CG
Acidchild/Padua
Guests online: 108
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Sabbi  (9.5)
4 Morpheus  (9.4)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.