@Ignatz I can see the winding direction being important for 3D, but I don’t think it matters for 2D objects. At least I didn’t see any difference when I was trying different directions with the above program.
@dave1707 - agreed. It makes no difference for 2D because the camera is fixed at the front of the scene. All you have to is avoid crossing your triangle lines!
@Ignatz That’s what I like about Codea. There’s always new things to learn. The only problem is, as I learn new stuff, I start to forget the old stuff.
@ignatz i wanted an example to understand what you mean. So I made the one below, but i dont see any effect linked to clockwise/anticlockwise. What am i missing? Could you modify it to show your point? thanks.
[edit] modified the code to add transparency effects. I dont see anything either.
-- faces
function setup()
c = vec2(WIDTH/2, HEIGHT/2)
z = -1
parameter.integer("z",-20,20,-1,setMesh)
setMesh()
a = 0
setCam(0)
print("blue is anticlockwise")
print("red is clockwise")
print("slide right/left to rotate")
end
function setMesh()
m = mesh()
local h1,h2 = 100,200
local c1,c2 = color(255, 0, 0, 144), color(0, 4, 255, 127)
t ={ vec3(h1+c.x, c.y-h1/2,z), vec3(-h1+c.x, c.y-h1/2, z), vec3(c.x,c.y+h1,z),
vec3(-h2+c.x, c.y-h2/2,0), vec3(h2+c.x, c.y-h2/2, 0), vec3(c.x,c.y+h2,0) }
cs = {c1,c1,c1,c2,c2,c2}
m.vertices = t
m.colors = cs
end
function setCam(da)
local h = WIDTH
a = a + da
camera(
c.x + h * math.sin(a),
c.y,
h * math.cos(a),
c.x, c.y, 0,
0,1,0
)
perspective()
end
function draw()
background(40, 40, 50)
setCam(0)
m:draw()
end
function touched(t)
local da = t.deltaX * math.pi /WIDTH*3
setCam(da)
end
@Jmv38 - I can’t create the effect, I’m afraid. I do remember that on one of the 3D models I imported, some of the faces were black and I had to reverse the vertices to get them to draw, but I’m not sure how to make that happen.
maybe with many vertices then, and not only 6 as in my example…?
Just be thankful when you don’t have this problem!