How to make a simple triangle through scripting

My bad, it’s actually called a Highlight.
image
It is able to give an object (or a group of objects) an outline and even a fill color.
image
image
In your case you could particularly use only the fill. You could have a model with all your triangle parts and have a Highlight in that model, giving your triangles a single fill color. However, you would have to somehow address the issue with transparency of the wedges.

Edit: Highlights don’t support non-opaque parts, so this is likely not practical.

1 Like

Make a MeshPart that is just a one sided wedge

2 Likes

What would using that MeshPart solve?

1 Like

There would only be one flush face so you wouldn’t see the darker areas where you’re looking through two faces.

1 Like

i.e. like this

4 Likes

How did you do that? Add a flush face?

2 Likes

I just made a single right triangle in blender and used that instead of a wedge part.

2 Likes

Here is my triangle:


If i add it in it looks like this :confused:

1 Like

You exported with the wrong forward and up axes. Also I noticed theres another weird render bug if you just use a single triangle, it shades weird. Probably the normals are getting squished too much. I got the best results by making a default wedge with just the square faces deleted and turning off DoubleSided.

2 Likes

Thank you very much! I was just about to mark your answer down when i noticed that there is a gap on the sides

Topview:

Sideview:

I know that this is due to the faces being deleted, but do you know how I could add this in. If not then please just state that, then I can finally close down this topic :smile:

EDIT: I have finally fixed it!

1 Like

Theres not a super easy way to do this. You would need two kinds of triangle, the one you have now, one with one side still there, and one with two sides. Then you’d have to change the triangle code to make sure that side is always placed so it faces out. I don’t think anyone will notice the difference.

1 Like

Already did it. It was a super easy fix:

local function draw3dTriangle(a, b, c, condition)
	local ab, ac, bc = b - a, c - a, c - b;
	local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);
	local Wedge = RangeWedge1
	
	if condition == false then
		Wedge = RangeWedge2
		if (abd > acd and abd > bcd) then
			c, a = a, c;
		elseif (acd > bcd and acd > abd) then
			a, b = b, a;
		end

		ab, ac, bc = b - a, c - a, c - b;
	end

	local right = ac:Cross(ab).unit;
	local up = bc:Cross(right).unit;
	local back = bc.unit;

	local height = math.abs(ab:Dot(up));
	local w1, w2

	w1 = Wedge:Clone();
	w1.Size = Vector3.new(0.1, height, math.abs(ab:Dot(back)));
	w1.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back);
	w1.Parent = RangeParts;

	w2 = Wedge:Clone();
	w2.Size = Vector3.new(0.1, height, math.abs(ac:Dot(back)));
	w2.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back);
	w2.Parent = RangeParts;
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.