3D (isometric)

new topic     » topic index » view thread      » older message » newer message

Hi again!
Thanx for the URL!
I made a little procedure to do +-3D Isometric (Starcraft-like) texturing,
But it's very very slow and I need to speed it up!
Can You help me please ??
*********convert* (to use with mode 259)
global function convert(atom x, atom y, atom z)
  atom X,Y
  X=(x/400)*400+(y/400)*400
  Y=(1-x/400)*300+(y/400)*300-2*z
  return {X,Y}
end function
*********map3d* (it uses "convert")
include image.e
global procedure map3d(sequence bitmap, integer x1, integer y1,integer
z1,integer x2,integer y2,integer z2
                       ,integer x3,integer y3, integer z3)
atom dis1, dis2, cons1, cons2, cons3, addx1, addy1, addz1, addx2, addy2, addz2,
u1, v1, w1, u2, v2,w2
sequence bmp, dumb1
bmp=read_bitmap(bitmap)
all_palette(bmp[1]/4)
dis1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)) -- = Distance between
(x1,y1,z1) and (x2,y2,z2)
dis2=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)+(z1-z3)*(z1-z3)) -- = Distance between
(x1,y1,z1) and (x3,y3,z3)
cons1=2 -- I should'nt use cons1 & cons2, it slow up a lot,  but if I don't do
that, the textured space is very ugly
cons2=2
cons3=length(bmp[2])/dis1/cons1
addx1=(x2-x1)/dis1/cons1
addy1=(y2-y1)/dis1/cons1
addz1=(z2-z1)/dis1/cons1
addx2=(x3-x1)/dis1/cons1
addy2=(y3-y1)/dis1/cons1
addz2=(z3-z1)/dis1/cons1
u1=x1
v1=y1
w1=z1
 for i = 1 to length(bmp[2]) by cons3  do
    u1=u1 + addx1
    v1=v1 + addy1
    w1=w1 + addz1
    u2=u1
    v2=v1
    w2=w1
    for j= 1 to length(bmp[2][i]) by length(bmp[2][i])/dis2/cons2 do
      u2=u2 + addx2
      v2=v2 + addy2
      w2=w2 + addz2
      dumb1=convert(u2,v2,w2)
      pixel(bmp[2][i][j],dumb1)
    end for
  end for
end procedure
*********An Exemple* (change the bitmap!)
include get.e
integer key
if graphics_mode(259) then end if
map3d("leeloo.bmp", 1,1,1,100,1,1,1,100,1)
key=wait_key()
********************

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu