Hi, have been looking at 3D stuff, using the labs and @Ignatz’s tutorials…and have a few questions but will only ask one for the moment…if it’s answered elsewhere please direct me if you can - I have looked but can’t seem to find it…
The following code produces two ‘entwined’ tetrahedra as something to try to understand the sequence of 3D construction…
-- tetrahedron/stella octangular
function setup()
screen=image(WIDTH,HEIGHT)
parameter.number("Angle",0,360)
v={}
v[1]=vec3(-1000,-1000,-1000)
v[2]=vec3(1000,-1000,1000)
v[3]=vec3(1000,1000,-1000)
v[4]=vec3(-1000,1000,1000)
tetra1=mesh()
tetra1.vertices = {v[1],v[2],v[3],
v[2],v[3],v[4],
v[3],v[4],v[1],
v[4],v[1],v[2]}
tetra1.texCoords= {vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0)}
tetra1.texture=("Documents:floo")
tetra1:setColors (255,255,255,255)
p={}
p[1]=vec3(1000,1000,1000)
p[2]=vec3(-1000,1000,-1000)
p[3]=vec3(-1000,-1000,1000)
p[4]=vec3(1000,-1000,-1000)
tetra2=mesh()
tetra2.vertices = {p[1],p[2],p[3],
p[2],p[3],p[4],
p[3],p[4],p[1],
p[4],p[1],p[2]}
tetra2.texCoords= {vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0),
vec2(0,0),vec2(.5,1),vec2(1,0)}
tetra2.texture=("Documents:shader")
tetra2:setColors (255,255,255,255)
end
function draw()
background(0)
perspective(100, WIDTH/HEIGHT)
camera(0,3000,-3000, 0,0,0, 0,1,0)
rotate(Angle,0,1,0)
-- setContext(screen)
tetra1:draw()
tetra2:draw()
-- setContext()
-- spriteMode(CENTER)
-- sprite(screen,WIDTH/2,HEIGHT/2)
end
so obviously it draws okay…
You can also see that I’ve tried drawing the tetras onto a dummy “screen” to try and get an image copy so that I can then play around with that but keep failing…Any suggestions much appreciated.