User Tools

Site Tools


base:perspective
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


base:perspective [2015-04-17 04:33] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +==== Perspective ====
 +
 +by Bitbreaker/Oxyron/Nuance
 +
 +Best is to calculate the perspective during multiply with the rotation matrix. As soon as you get the value for Z, lookup a corresponding factor in a table and multply the results for X and Y with that factor:
 +
 +<code>
 +        ... matrix multipplication for Z ...
 +        tay
 +        lda z_fact,y
 +        sta z1
 +        eor #$ff
 +        sta z2
 +        
 +        ... matrix multiplication for X ...
 +        
 +        tay
 +        ;multiply with z_fact
 +        lda (z1),y
 +        sec
 +        sbc (z2),y
 +        sta final_x
 +        
 +        ... matrix multiplication for Z ...
 +        
 +        tay
 +        ;multiply with z_fact
 +        lda (z1),y
 +        sec
 +        sbc (z2),y
 +        sta final_y
 +</code>
 +
 +The factor-table you could generate like the following:
 +<code>
 +    ...
 +    d = 280.0; z0 = 5.0;
 +    for (i = 0; i < 0x100; i++) {
 +        z = i;
 +        //make things signed
 +        if(z > 127) z = z - 256;
 +        q = round(d/(z0-z/64.0));
 +        //take care that values are sane
 +        if(q > 127) q = 127;
 +        if(q < -127) q = -127;
 +
 +        if(q < 0) q = 256 + q;
 +
 +        result[i] = q;
 +    }
 +    ...
 +</code>
  
base/perspective.txt · Last modified: 2015-04-17 04:33 by 127.0.0.1