Iām sorry if this question sounds silly, but isnāt that still useless? Letās face it. Ok, Iāll give you more information on my case/problem:
Iām currently working on a way to upgrade my custom mesh importer. Pictures are better than words, so hereās what I have now:
At first glance, it just looks normal, but hereās the problem. If you look better, you see empty areas that are impossible to cover:
(Yellow square)
So I got the idea: Hey, why donāt you create a triangle mesh with length x, width Z and height 0? And this leads me to the current situation.
@starmaq why does it annoy me? Once again, a picture is better than words here:
And here you can clearly see the problem:
The thing I didnāt count with is that my TriangleMesh is stretching upwards. To form the triangles, which then connect the different vertices, I use EgoMoose 3DTriangelModules. So the code I am currently using is this one:
local wedge = script.TriangleMeshPart
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 > edge.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, h, w1); --SEE HERE
wedge1.CFrame = cf1;
wedge1.Parent = parent;
local wedge2 = wedge:Clone();
wedge2.Size = Vector3.new(0, h, w2); --SEE HERE
wedge2.CFrame = cf2;
wedge2.Parent = parent;
end
Now the lines that give me problems are this one:
wedge1.Size = Vector3.new(0, h, w1);
and
wedge2.Size = Vector3.new(0, h, w2);
So I hope it was all the information you needed. With the module, you calculate where the triangle should be. It calculates not only its position, but also its size and changes the size of the triangle to get a perfect triangle between the 3 points. Real problem: In my case, if the angle of two faces of an imported mesh is over 90 degrees, this kind of empty space is created. To solve this problem, I have 2 kinds of solutions: The first would be to extend the relatively right side of the face by a few āCentiStudsā, not really the most ideal one, as there could be many other problems that I donāt really want to solve. The second would be to simply create a face with height 0, as it really is, which is the right solution. But there is only one wall left which blocks me and my goal: My mesh stretches when I change the height. When I import my triangle into Studio, the height is 0, but as soon as I change it via script, it becomes exactly above 0, which leads to my problem. Iām not really the worldās best explainer, so thereās still something unclear, just ask.
Again, for those who don't understand anything yet: the size of my mesh needs to change, but as long as part of my size doesn't change. Later I'll try both of your methods, @Quoteory and @megatank58, hope it works (although I'm a bit sceptical).