If we draw a mesh at one place and then draw it again somewhere else then why doesn’t the first mesh disappear and come at the second place. Here’s the code it’ll give you some idea of what I am trying to say. And why does the alpha of the wall keep changing its less in the begging and then for some angles it becomes 255 any reason for that??
--# Main
function setup()
CreateImage()
w,h = i.width/2,i.height/2
m = mesh()
m.texture = i
m.vertices = {vec3(-w,-h,0),vec3(-w,h,0),vec3(w,h,0),vec3(w,-h,0),vec3(-w,-h,0),vec3(w,h,0)}
m.texCoords = {vec2(0,0),vec2(0,1),vec2(1,1),vec2(1,0),vec2(0,0),vec2(1,1)}
mf = mesh()
i = readImage("SpaceCute:Background")
w,h = i.width,i.height
mf.texture = i
mf.vertices = {vec3(-w,-h,0),vec3(-w,h,0),vec3(w,h,0),vec3(w,-h,0),vec3(-w,-h,0),vec3(w,h,0)}
mf.texCoords = {vec2(0,0),vec2(0,1),vec2(1,1),vec2(1,0),vec2(0,0),vec2(1,1)}
X = 0
Z = 0
angle = 0
end
function draw()
background(255)
perspective(45,WIDTH/HEIGHT)
fill(255)
angle = angle+1
X = 400*math.cos(math.rad(angle))
Z = -1100 - 400*math.sin(math.rad(angle))
camera(X,0,Z,0,0,-1000,0,1,0)
pushMatrix()
translate(0,0,-1000)
m:draw()
popMatrix()
pushMatrix()
translate(100,0,-1100)
rotate(90,0,1,0)
m:draw()
popMatrix()
pushMatrix()
translate(-100,0,-1100)
rotate(90,0,1,0)
m:draw()
popMatrix()
pushMatrix()
translate(0,0,-1200)
m:draw()
popMatrix()
pushMatrix()
translate(0,-50,-1100)
rotate(90,1,0,0)
mf:draw()
popMatrix()
end
function CreateImage()
i = image(200,100)
local w,h = i.width,i.height
setContext(i)
rectMode(CORNER)
fill(255, 194, 0, 71)
rect(0,0,w,h)
fill(255, 0, 0, 255)
ellipse(w/2,h/2,h/2)
setContext()
end