@Bri_G Don’t know if this is of any help, but @LoopSpace was talking about a texture on a cylinder. The below example will put a texture on a cylinder. You can change the variable “sides” from 3 to a higher number to create a smooth cylinder.
You can change the Startup_Screen to some other texture. Are you trying to unwrap a model to get an image. I’m not sure how I’d unwrap the cylinder to get an image.
PS. Just read your post again and if you just have colors per triangle instead of an image, that might be easier to unwrap. I’ll have to think about that. Currently watching football so I’m not concentrating on coding.
viewer.mode=FULLSCREEN
function setup()
sides=5
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
scene = craft.scene()
v=scene.camera:add(OrbitViewer,vec3(px,100,pz), 1000, 0, 10000)
v.camera.farPlane=10000
pos={}
cm = craft.material(asset.builtin.Materials.Basic)
rm=readImage(asset.builtin.Cargo_Bot.Startup_Screen)
for a=359,0,-360/sides do
x=math.cos(math.rad(a))*50
y=math.sin(math.rad(a))*50
z=200
table.insert(pos,vec3(x,y,z))
x=math.cos(math.rad(a))*50 --1
y=math.sin(math.rad(a))*50 --1
z=-200
table.insert(pos,vec3(x,y,z))
end
s1=0
for z=1,#pos-2,2 do
p1=pos[z]
p2=pos[z+2]
p3=pos[z+3]
p4=pos[z+1]
nor={}
norm(p1,p3,p4)
norm(p1,p2,p3)
createTile(p1,p2,p3,p4,s1,s1+1/sides)
s1=s1+1/sides
end
p1=pos[#pos-1]
p2=pos[1]
p3=pos[2]
p4=pos[#pos]
nor={}
norm(p1,p3,p4)
norm(p1,p2,p3)
createTile(p1,p2,p3,p4,s1,s1+1/sides)
end
function draw()
update(DeltaTime)
scene:draw()
end
function update(dt)
scene:update(dt)
end
function createTile(p1,p2,p3,p4,s1,s2)
local c=color(255, 255, 255, 255)
r=scene:entity()
r.model = craft.model()
r.model.positions={p1,p3,p4,p1,p2,p3}
r.model.indices={1,2,3,4,5,6,6,5,4,3,2,1}
r.model.colors={c,c,c,c,c,c}
r.model.uvs={vec2(s1,0),vec2(s2,1),vec2(s1,1),vec2(s1,0),vec2(s2,0),vec2(s2,1)}
r.model.normals=nor
r.material = cm
r.material.map=rm
end
function norm(a,b,c)
v1=b-a
v2=c-b
n1=v1:cross(v2)
table.insert(nor,n1)
table.insert(nor,n1)
table.insert(nor,n1)
end