Here is the drawing code for the "3d" objects (called in draw event):
//f3d_draw_block(x1,y1,z1,x2,y2,z2,texid,rotate,roof)
/*
Below you see the surface of the block, with the names of the coordinates.
These are called 'd'(draw), '1' or '2'(level of height), 'x' or 'y', '1' or '2' or '3' or '4'(the number of the corner)
So for example d2x3 is the x-coordinate of the right-under corner at the second level of the block.
wx |
1------------2
| | |
wy | | |
---|------mid |
| |
| |
4------------3
*/
var x1,x2,y1,y2,z1,z2,texid,dir,lines,wx,wy,surf_mid_x,surf_mid_y,mid_x,mid_y,d1x1,d1y1,d1x2,d1y2,d1x3,d1y3,d1x4,d1y4,d2x1,d2y1,d2x2,d2y2,d2x3,d2y3,d2x4,d2y4,c1x,c1y,c2x,c2y;
/////////////////////////////////////////////Init\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
x1=argument0
y1=argument1
z1=argument2
x2=argument3
y2=argument4
z2=argument5
texid=argument6
texroof=argument7
dir=argument8
wx=(x2-x1)/2 //width
wy=(y2-y1)/2 //width
//////////////////////////////////////////Setting 3d-coordinates\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//the middlepoint on the surface
surf_mid_x=x1+wx
surf_mid_y=y1+wy
//coordinates on the surface when rotated
d1x1=surf_mid_x+lengthdir_x(-point_distance(x1,y1,surf_mid_x,surf_mid_y),point_direction(x1,y1,surf_mid_x,surf_mid_y)+dir)
d1y1=surf_mid_y+lengthdir_y(-point_distance(x1,y1,surf_mid_x,surf_mid_y),point_direction(x1,y1,surf_mid_x,surf_mid_y)+dir)
d1x2=surf_mid_x+lengthdir_x(-point_distance(x2,y1,surf_mid_x,surf_mid_y),point_direction(x2,y1,surf_mid_x,surf_mid_y)+dir)
d1y2=surf_mid_y+lengthdir_y(-point_distance(x2,y1,surf_mid_x,surf_mid_y),point_direction(x2,y1,surf_mid_x,surf_mid_y)+dir)
d1x3=surf_mid_x+lengthdir_x(-point_distance(x2,y2,surf_mid_x,surf_mid_y),point_direction(x2,y2,surf_mid_x,surf_mid_y)+dir)
d1y3=surf_mid_y+lengthdir_y(-point_distance(x2,y2,surf_mid_x,surf_mid_y),point_direction(x2,y2,surf_mid_x,surf_mid_y)+dir)
d1x4=surf_mid_x+lengthdir_x(-point_distance(x1,y2,surf_mid_x,surf_mid_y),point_direction(x1,y2,surf_mid_x,surf_mid_y)+dir)
d1y4=surf_mid_y+lengthdir_y(-point_distance(x1,y2,surf_mid_x,surf_mid_y),point_direction(x1,y2,surf_mid_x,surf_mid_y)+dir)
d2x1=d1x1
d2y1=d1y1
d2x2=d1x2
d2y2=d1y2
d2x3=d1x3
d2y3=d1y3
d2x4=d1x4
d2y4=d1y4
//coordinates at the z level
if z1<>0
{
d1x1+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d1x1,d1y1)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x1,d1y1))
d1y1+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d1x1,d1y1)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x1,d1y1))
d1x2+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d1x2,d1y2)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x2,d1y2))
d1y2+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d1x2,d1y2)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x2,d1y2))
d1x3+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d1x3,d1y3)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x3,d1y3))
d1y3+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d1x3,d1y3)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x3,d1y3))
d1x4+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d1x4,d1y4)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x4,d1y4))
d1y4+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d1x4,d1y4)/(view_wview[0]/z1),point_direction(global.mid_x,global.mid_y,d1x4,d1y4))
}
if z2<>0
{
d2x1+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d2x1,d2y1)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x1,d2y1))
d2y1+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d2x1,d2y1)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x1,d2y1))
d2x2+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d2x2,d2y2)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x2,d2y2))
d2y2+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d2x2,d2y2)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x2,d2y2))
d2x3+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d2x3,d2y3)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x3,d2y3))
d2y3+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d2x3,d2y3)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x3,d2y3))
d2x4+=lengthdir_x(point_distance(global.mid_x,global.mid_y,d2x4,d2y4)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x4,d2y4))
d2y4+=lengthdir_y(point_distance(global.mid_x,global.mid_y,d2x4,d2y4)/(view_wview[0]/z2),point_direction(global.mid_x,global.mid_y,d2x4,d2y4))
}
//The middle point of the block
mid_x=surf_mid_x+lengthdir_x(point_distance(global.mid_x,global.mid_y,surf_mid_x,surf_mid_y)/(view_wview[0]/mean(z1,z2)),point_direction(global.mid_x,global.mid_y,surf_mid_x,surf_mid_y))
mid_y=surf_mid_y+lengthdir_y(point_distance(global.mid_x,global.mid_y,surf_mid_x,surf_mid_y)/(view_wview[0]/mean(z1,z2)),point_direction(global.mid_x,global.mid_y,surf_mid_x,surf_mid_y))
//Setting depth to prevent overlay. Not working 100%
depth = (point_distance(global.mid_x,global.mid_y,x1+wx,y1+wy))/100
/////////////////////////////////////////////DRAW\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//////////wall 1-2
//Middlepoints of the wall
c1x=d1x1+lengthdir_x(point_distance(d1x1,d1y1,d1x2,d1y2)/2,point_direction(d1x1,d1y1,d1x2,d1y2))
c1y=d1y1+lengthdir_y(point_distance(d1x1,d1y1,d1x2,d1y2)/2,point_direction(d1x1,d1y1,d1x2,d1y2))
c2x=d2x1+lengthdir_x(point_distance(d2x1,d2y1,d2x2,d2y2)/2,point_direction(d2x1,d2y1,d2x2,d2y2))
c2y=d2y1+lengthdir_y(point_distance(d2x1,d2y1,d2x2,d2y2)/2,point_direction(d2x1,d2y1,d2x2,d2y2))
//check if it has to be drawn
if point_distance(mid_x,mid_y,c1x,c1y)>point_distance(mid_x,mid_y,c2x,c2y)
{
//light
draw_set_color(make_color_hsv(global.light_hue,global.light_saturation,f3d_light_value(point_direction(d1x1,d1y1,d1x2,d1y2)-90)))
//drawing rectangle
draw_primitive_begin_texture(pr_trianglelist,texid)
draw_vertex_texture(d1x1,d1y1,0,0)
draw_vertex_texture(d1x2,d1y2,1,0)
draw_vertex_texture(d2x1,d2y1,0,1)
draw_vertex_texture(d2x1,d2y1,0,1)
draw_vertex_texture(d2x2,d2y2,1,1)
draw_vertex_texture(d1x2,d1y2,1,0)
draw_primitive_end()
}
/////////wall 2-3
c1x=d1x2+lengthdir_x(point_distance(d1x2,d1y2,d1x3,d1y3)/2,point_direction(d1x2,d1y2,d1x3,d1y3))
c1y=d1y2+lengthdir_y(point_distance(d1x2,d1y2,d1x3,d1y3)/2,point_direction(d1x2,d1y2,d1x3,d1y3))
c2x=d2x2+lengthdir_x(point_distance(d2x2,d2y2,d2x3,d2y3)/2,point_direction(d2x2,d2y2,d2x3,d2y3))
c2y=d2y2+lengthdir_y(point_distance(d2x2,d2y2,d2x3,d2y3)/2,point_direction(d2x2,d2y2,d2x3,d2y3))
if point_distance(mid_x,mid_y,c1x,c1y)>point_distance(mid_x,mid_y,c2x,c2y)
{
draw_set_color(make_color_hsv(global.light_hue,global.light_saturation,f3d_light_value(point_direction(d1x2,d1y2,d1x3,d1y3)-90)))
draw_primitive_begin_texture(pr_trianglelist,texid)
draw_vertex_texture(d1x2,d1y2,0,0)
draw_vertex_texture(d1x3,d1y3,1,0)
draw_vertex_texture(d2x2,d2y2,0,1)
draw_vertex_texture(d2x2,d2y2,0,1)
draw_vertex_texture(d2x3,d2y3,1,1)
draw_vertex_texture(d1x3,d1y3,1,0)
draw_primitive_end()
}
///////////wall 3-4
c1x=d1x3+lengthdir_x(point_distance(d1x3,d1y3,d1x4,d1y4)/2,point_direction(d1x3,d1y3,d1x4,d1y4))
c1y=d1y3+lengthdir_y(point_distance(d1x3,d1y3,d1x4,d1y4)/2,point_direction(d1x3,d1y3,d1x4,d1y4))
c2x=d2x3+lengthdir_x(point_distance(d2x3,d2y3,d2x4,d2y4)/2,point_direction(d2x3,d2y3,d2x4,d2y4))
c2y=d2y3+lengthdir_y(point_distance(d2x3,d2y3,d2x4,d2y4)/2,point_direction(d2x3,d2y3,d2x4,d2y4))
if point_distance(mid_x,mid_y,c1x,c1y)>point_distance(mid_x,mid_y,c2x,c2y)
{
draw_set_color(make_color_hsv(global.light_hue,global.light_saturation,f3d_light_value(point_direction(d1x3,d1y3,d1x4,d1y4)-90)))
draw_primitive_begin_texture(pr_trianglelist,texid)
draw_vertex_texture(d1x3,d1y3,0,0)
draw_vertex_texture(d1x4,d1y4,1,0)
draw_vertex_texture(d2x3,d2y3,0,1)
draw_vertex_texture(d2x3,d2y3,0,1)
draw_vertex_texture(d2x4,d2y4,1,1)
draw_vertex_texture(d1x4,d1y4,1,0)
draw_primitive_end()
}
////////////wall 4-1
c1x=d1x4+lengthdir_x(point_distance(d1x4,d1y4,d1x1,d1y1)/2,point_direction(d1x4,d1y4,d1x1,d1y1))
c1y=d1y4+lengthdir_y(point_distance(d1x4,d1y4,d1x1,d1y1)/2,point_direction(d1x4,d1y4,d1x1,d1y1))
c2x=d2x4+lengthdir_x(point_distance(d2x4,d2y4,d2x1,d2y1)/2,point_direction(d2x4,d2y4,d2x1,d2y1))
c2y=d2y4+lengthdir_y(point_distance(d2x4,d2y4,d2x1,d2y1)/2,point_direction(d2x4,d2y4,d2x1,d2y1))
if point_distance(mid_x,mid_y,c1x,c1y)>point_distance(mid_x,mid_y,c2x,c2y)
{
draw_set_color(make_color_hsv(global.light_hue,global.light_saturation,f3d_light_value(point_direction(d1x4,d1y4,d1x1,d1y1)-90)))
draw_primitive_begin_texture(pr_trianglelist,texid)
draw_vertex_texture(d1x4,d1y4,0,0)
draw_vertex_texture(d1x1,d1y1,1,0)
draw_vertex_texture(d2x4,d2y4,0,1)
draw_vertex_texture(d2x4,d2y4,0,1)
draw_vertex_texture(d2x1,d2y1,1,1)
draw_vertex_texture(d1x1,d1y1,1,0)
draw_primitive_end()
}
/////////////Roof
draw_set_color(c_white)
draw_primitive_begin_texture(pr_trianglelist,texroof)
draw_vertex_texture(d2x1,d2y1,0,0)
draw_vertex_texture(d2x2,d2y2,1,0)
draw_vertex_texture(d2x3,d2y3,1,1)
draw_vertex_texture(d2x1,d2y1,0,0)
draw_vertex_texture(d2x4,d2y4,0,1)
draw_vertex_texture(d2x3,d2y3,1,1)
draw_primitive_end()This is the problem I'm encountering:

Is there a way that I could get the door to be drawn correctly? I figured that having the door on a depth of 10 and the building on a depth or 0 could help, but it did nothing. Any ideas?
Is there some way that I could get the depth of the top face of the cube to be drawn at a depth corresponding to the depth of the object? That would cause the roof of the building to overlap, would it not?
Thanks for any help!



Find content
Not Telling




