Run it
Copy the script and paste it into your executor.
plr = :().LocalPlayer;
rs = :();
buildevt = rs.Remotes.BuildEvent;
objfile = ;
mtlfile = ;
voxsize = ;
offset = plr.Character.HumanoidRootPart.Position;
centermodel = ;
createdparts = {};
waitingforparts = ;
buildevt.OnClientEvent:((parts)
parts waitingforparts
_, part parts
.(createdparts, part);
)
(filename)
filepath = filename .. ;
(filepath)
(, filepath);
;
data = (filepath);
lines = {};
line data:()
.(lines, line);
width, height = lines[]:();
width = (width);
height = (height);
pixels = {};
i = , #lines
r, g, b = lines[i]:();
r g b
.(pixels, .((r), (g), (b)));
(, filename, width .. .. height, #pixels, );
{
width = width,
height = height,
pixels = pixels
};
(tex, u, v)
tex .(, , );
u = u % ;
v = v % ;
u < u = u + ;
v < v = v + ;
v = - v;
x = .(u * tex.width);
y = .(v * tex.height);
x = .(x, , tex.width - );
y = .(y, , tex.height - );
idx = y * tex.width + x + ;
tex.pixels[idx] .(, , );
(data)
mats = {};
current;
line data:()
stripped = line:();
stripped:(, ) ~= stripped ~=
cmd = stripped:();
cmd ==
current = stripped:();
mats[current] = {color = .(, , ), texture = };
cmd == current
r, g, b = stripped:();
r g b
mats[current].color = .((r), (g), (b));
cmd == current
texfile = stripped:();
texfile
texfile = texfile:();
(, texfile, , current);
mats[current].texture = (texfile);
mats;
(data)
verts = {};
uvs = {};
faces = {};
currentmtl;
line data:()
stripped = line:();
stripped:(, ) ~= stripped ~=
cmd = stripped:();
cmd ==
x, y, z = stripped:();
x y z
.(verts, .((x), (y), (z)));
cmd ==
u, v = stripped:();
u v
.(uvs, .((u), (v)));
cmd ==
vindices = {};
uvindices = {};
vert stripped:()
vert ~=
parts = {};
part vert:()
.(parts, part);
#parts >=
vidx = (parts[]);
vidx < vidx = #verts + vidx + ;
.(vindices, vidx);
#parts >= parts[] ~=
uvidx = (parts[]);
uvidx < uvidx = #uvs + uvidx + ;
.(uvindices, uvidx);
#vindices >=
.(faces, {
vindices = vindices,
uvindices = #uvindices > uvindices ,
mtl = currentmtl
});
cmd ==
currentmtl = stripped:();
(, #verts, , #uvs, , #faces, );
verts, uvs, faces;
(verts)
minv = .(.huge, .huge, .huge);
maxv = .(-.huge, -.huge, -.huge);
_, v verts
minv = .(.(minv.X, v.X), .(minv.Y, v.Y), .(minv.Z, v.Z));
maxv = .(.(maxv.X, v.X), .(maxv.Y, v.Y), .(maxv.Z, v.Z));
minv, maxv;
(p, a, b, c)
v0 = b - a;
v1 = c - a;
v2 = p - a;
d00 = v0:(v0);
d01 = v0:(v1);
d11 = v1:(v1);
d20 = v2:(v0);
d21 = v2:(v1);
denom = d00 * d11 - d01 * d01;
.(denom) <
, , ;
v = (d11 * d20 - d01 * d21) / denom;
w = (d00 * d21 - d01 * d20) / denom;
u = - v - w;
u, v, w;
(boxcenter, boxhalfsize, v0, v1, v2)
v0c = v0 - boxcenter;
v1c = v1 - boxcenter;
v2c = v2 - boxcenter;
e0 = v1c - v0c;
e1 = v2c - v1c;
e2 = v0c - v2c;
fex = .(e0.X);
fey = .(e0.Y);
fez = .(e0.Z);
p0 = e0.Z * v0c.Y - e0.Y * v0c.Z;
p2 = e0.Z * v2c.Y - e0.Y * v2c.Z;
rad = fez * boxhalfsize.Y + fey * boxhalfsize.Z;
.(p0, p2) > rad .(p0, p2) < -rad ;
p0 = -e0.Z * v0c.X + e0.X * v0c.Z;
p2 = -e0.Z * v2c.X + e0.X * v2c.Z;
rad = fez * boxhalfsize.X + fex * boxhalfsize.Z;
.(p0, p2) > rad .(p0, p2) < -rad ;
p0 = e0.Y * v0c.X - e0.X * v0c.Y;
p1 = e0.Y * v1c.X - e0.X * v1c.Y;
rad = fey * boxhalfsize.X + fex * boxhalfsize.Y;
.(p0, p1) > rad .(p0, p1) < -rad ;
fex = .(e1.X);
fey = .(e1.Y);
fez = .(e1.Z);
p0 = e1.Z * v0c.Y - e1.Y * v0c.Z;
p2 = e1.Z * v2c.Y - e1.Y * v2c.Z;
rad = fez * boxhalfsize.Y + fey * boxhalfsize.Z;
.(p0, p2) > rad .(p0, p2) < -rad ;
p0 = -e1.Z * v0c.X + e1.X * v0c.Z;
p2 = -e1.Z * v2c.X + e1.X * v2c.Z;
rad = fez * boxhalfsize.X + fex * boxhalfsize.Z;
.(p0, p2) > rad .(p0, p2) < -rad ;
p0 = e1.Y * v0c.X - e1.X * v0c.Y;
p1 = e1.Y * v1c.X - e1.X * v1c.Y;
rad = fey * boxhalfsize.X + fex * boxhalfsize.Y;
.(p0, p1) > rad .(p0, p1) < -rad ;
fex = .(e2.X);
fey = .(e2.Y);
fez = .(e2.Z);
p0 = e2.Z * v0c.Y - e2.Y * v0c.Z;
p1 = e2.Z * v1c.Y - e2.Y * v1c.Y;
rad = fez * boxhalfsize.Y + fey * boxhalfsize.Z;
.(p0, p1) > rad .(p0, p1) < -rad ;
p0 = -e2.Z * v0c.X + e2.X * v0c.Z;
p1 = -e2.Z * v1c.X + e2.X * v1c.Z;
rad = fez * boxhalfsize.X + fex * boxhalfsize.Z;
.(p0, p1) > rad .(p0, p1) < -rad ;
p0 = e2.Y * v0c.X - e2.X * v0c.Y;
p2 = e2.Y * v2c.X - e2.X * v2c.Y;
rad = fey * boxhalfsize.X + fex * boxhalfsize.Y;
.(p0, p2) > rad .(p0, p2) < -rad ;
minc = .(.(v0c.X, v1c.X, v2c.X), .(v0c.Y, v1c.Y, v2c.Y), .(v0c.Z, v1c.Z, v2c.Z));
maxc = .(.(v0c.X, v1c.X, v2c.X), .(v0c.Y, v1c.Y, v2c.Y), .(v0c.Z, v1c.Z, v2c.Z));
minc.X > boxhalfsize.X maxc.X < -boxhalfsize.X ;
minc.Y > boxhalfsize.Y maxc.Y < -boxhalfsize.Y ;
minc.Z > boxhalfsize.Z maxc.Z < -boxhalfsize.Z ;
;
(verts, uvs, faces, mats, size)
voxmap = {};
minbound, maxbound = (verts);
centermodel
center = (minbound + maxbound) / ;
i, v verts
verts[i] = v - center;
minbound, maxbound = (verts);
boxhalfsize = .(size / , size / , size / );
fidx, face faces
vindices = face.vindices;
#vindices >=
v0 = verts[vindices[]];
v1 = verts[vindices[]];
v2 = verts[vindices[]];
v0 v1 v2
;
mat = face.mtl mats[face.mtl];
tex = mat mat.texture;
uv0, uv1, uv2;
face.uvindices #face.uvindices >=
uv0 = uvs[face.uvindices[]];
uv1 = uvs[face.uvindices[]];
uv2 = uvs[face.uvindices[]];
trimin = .(
.(v0.X, v1.X, v2.X),
.(v0.Y, v1.Y, v2.Y),
.(v0.Z, v1.Z, v2.Z)
);
trimax = .(
.(v0.X, v1.X, v2.X),
.(v0.Y, v1.Y, v2.Y),
.(v0.Z, v1.Z, v2.Z)
);
startx = .(trimin.X / size) * size;
starty = .(trimin.Y / size) * size;
startz = .(trimin.Z / size) * size;
endx = .(trimax.X / size) * size;
endy = .(trimax.Y / size) * size;
endz = .(trimax.Z / size) * size;
x = startx;
x <= endx
y = starty;
y <= endy
z = startz;
z <= endz
boxcenter = .(x + size / , y + size / , z + size / );
(boxcenter, boxhalfsize, v0, v1, v2)
color = mat mat.color .(, , );
tex uv0 uv1 uv2
u, v, w = (boxcenter, v0, v1, v2);
uvcoord = uv0 * u + uv1 * v + uv2 * w;
color = (tex, uvcoord.X, uvcoord.Y);
key = .(, x, y, z);
voxmap[key] = {pos = .(x, y, z), color = color};
z = z + size;
y = y + size;
x = x + size;
fidx % ==
(, fidx, , #faces);
.();
voxmap;
()
(objfile)
();
;
();
objdata = (objfile);
verts, uvs, faces = (objdata);
mats = {};
(mtlfile)
();
mtldata = (mtlfile);
mats = (mtldata);
();
voxmap = (verts, uvs, faces, mats, voxsize);
voxlist = {};
_, vox voxmap
.(voxlist, vox);
(, #voxlist, );
waitingforparts = ;
i, vox voxlist
worldpos = offset + vox.pos;
createdparts = {};
buildevt:(, , worldpos);
timeout = ;
#createdparts == timeout <
.();
timeout += ;
#createdparts >
buildevt:(, {createdparts[]}, vox.color);
i % ==
(, i, , #voxlist);
.();
waitingforparts = ;
();
();take any 3d model and put it in ur exploits workspace and rename it to "model.obj" aswell as the mtl. From my discord server of unfinished projects. I won't update this.
Stay safe
Never paste your .ROBLOSECURITY cookie anywhere, and use an alt account with scripts.