Is there any way to create polygons given vertexes?

Is there any way to create polygons given vertexes?

UUhhhh I want this!!! API to create and modify meshes during runtime

2 Likes
local wedge = Instance.new("WedgePart");
wedge.Anchored = true;
wedge.TopSurface = Enum.SurfaceType.Smooth;
wedge.BottomSurface = Enum.SurfaceType.Smooth;

local function draw3dTriangle(a, b, c, parent)
	local edges = {
		{longest = (c - a), other = (b - a), origin = a},
		{longest = (a - b), other = (c - b), origin = b},
		{longest = (b - c), other = (a - c), origin = c}
	};

	local edge = edges[1];
	for i = 2, #edges do
		if (edges[i].longest.magnitude > ed.   ge.longest.magnitude) then
			edge = edges[i];
		end
	end

	local theta = math.acos(edge.longest.unit:Dot(edge.other.unit));
	local w1 = math.cos(theta) * edge.other.magnitude;
	local w2 = edge.longest.magnitude - w1;
	local h = math.sin(theta) * edge.other.magnitude;

	local p1 = edge.origin + edge.other * 0.5;
	local p2 = edge.origin + edge.longest + (edge.other - edge.longest) * 0.5;

	local right = edge.longest:Cross(edge.other).unit;
	local up = right:Cross(edge.longest).unit;
	local back = edge.longest.unit;

local cf1 = CFrame.new(
		p1.x, p1.y, p1.z,
		-right.x, up.x, back.x,
		-right.y, up.y, back.y,
		-right.z, up.z, back.z
	);

local cf2 = CFrame.new(
		p2.x, p2.y, p2.z,
		right.x, up.x, -back.x,
		right.y, up.y, -back.y,
		right.z, up.z, -back.z
	);

	-- put it all together by creating the wedges

	local wedge1 = wedge:Clone();
	wedge1.Size = Vector3.new(0.2, h, w1);
	wedge1.CFrame = cf1;
	wedge1.Parent = parent;

	local wedge2 = wedge:Clone();
	wedge2.Size = Vector3.new(0.2, h, w2);
	wedge2.CFrame = cf2;
	wedge2.Parent = parent;
end

The Link of this script(Made by Egomoose)

1 Like

Im right now using it, but it has issues

  1. Redundant faces (back, side). For larger poly u can do the math :confused:
  2. Because it’s 0.05 thick (roblox min size), when 2 triangles have different angles and a common edge, one can see the gap opening

Currently the only way to generate polygons from vertices is to use the method you’re already using - triangular parts. You can improve upon it perhaps by creating an equivalently shaped triangular part using blender that only has one face and a very thin thickness, but you might run into problems with players clipping through the parts if they’re moving too fast.

1 Like

Is there something like a voting for a feature request?

You can use Post Approval to reply to the feature request, explaining why you need the feature and how it would help you solve your problems.

For some reason I can’t do reply for that topic… duno

1 Like

You can inset each triangle by half the thickness of the wedgeparts to get rid of those gaps. This will look even worse if you have external corners that are more than 90 degrees tho. A solution that looks good no matter what is to put a SpecialMesh in each wedge, set the MeshType to "Wedge" and the Scale to (0, 1, 1). This will make the collision shapes different from the visual shape, which can be confusing if you need to to hit detection or something. It’ll be off by 0.05 studs, which might not be noticeable in your game.

2 Likes

You can still follow the instructions in the rules for categories that disallow use of the reply button.

Wow thanks. The scale thing works for me for now :slight_smile:

1 Like