i want to use mesh.vertex draw two vertex to a rect ,but i can’t seem like opengl have vertex index,how i do it? i don’t want to use draw rect. just vertex to do it. any sample? thanks!
Here’s a small example I have that uses vertices. Use the slider for 3 examples.
function setup()
parameter.integer("value",1,3,1,set)
end
function draw()
background(40, 40, 50)
myMesh:draw()
end
function set()
myMesh = mesh()
myMesh.vertices = {vec2(0,0),vec2(100,0),vec2(0,100),
vec2(0,100),vec2(100,100),vec2(100,0)}
if value==1 then
-- set color for whole mesh
myMesh:setColors(255,0,0)
elseif value==2 then
-- set color for whole mesh
myMesh:setColors(255,0,0)
-- then set color for each of the 6 vertices
myMesh:color(1,255,0,0)
myMesh:color(2,255,0,0)
myMesh:color(3,255,0,0)
myMesh:color(4,0,255,0)
myMesh:color(5,0,255,0)
myMesh:color(6,0,255,0)
elseif value==3 then
-- get texture image
img = readImage("Planet Cute:Icon")
-- set texture image
myMesh.texture = img --Set the image as texture
-- set texture coordinates
t={vec2(0,0),vec2(1,0),vec2(0,1),vec2(0,1),vec2(1,1),vec2(1,0)}
myMesh.texCoords=t
end
end
Yo thank you. It work .thanks!!