Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need help creating a loop cut algorithm

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 8th Jun 2011 18:19 Edited at: 8th Jun 2011 18:20
Ok, so I've picked up a project I was working on several months ago. I need to figure out how to cut a face so that it splits into 2 faces and then use that to completely split an object in half like so. Is there any specific algorithm that solves this? I already have come up with code to detect the faces that will be cut and where they will be cut. I just need to figure out how to move the vertices for the cut.


Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 9th Jun 2011 03:34 Edited at: 9th Jun 2011 03:46
Hmm... I do believe when you cut a triangle, you either get two triangles, or a triangle and a convex quad. To divide a convex quad into two triangles, you draw a line from one vertex to another vertex not directly touching it.

So, FOR EACH triangle, get the points on the triangle V1, V2, and V3. Then get the two points of intersection, I1 and I2.

If I1 and I2 BOTH are vertices of the triangle, DONT cut anything (endfunction)

else if I1 or I2 are vertices of the triangle, divide up the triangle into two triangles. (So if I1=V1, you would get two triangles: V1,V2,I2; V1,V3,I2) (endfunction)

else, neither I2 or I1 are vertices of the triangle. This means that line I1/I2 divides the vertices such that one vertex lies on one side of I1/I2, and two vertices lie on the other side of I2.

-let A be the lone vertex, let B be the vertice that lies on line A/I1, and let C be the vertice that lies on line A/I2.
-return three triangles: A/I1/I2, I2/I1/B, I2/C/B;
(endfunction)

image of what I mean:


[edit]
o_o I thought i got rid of that whitespace...

Oh well, too late. (me being lazy)


Why does blue text appear every time you are near?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 9th Jun 2011 04:54
This was exactly what I was looking for. Thanks so much. You don't know how many times I've sat in history class trying to come up with an algorithm for it. I will post back with code (working or non working).

Olby
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 5th Jul 2011 23:10
@Madscientist: Any luck with your project? This (and the other thread) sounds really interesting.

ACER Aspire 5920G: Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, Windows Vista Ultimate SP1, DBPro 7.5 + PureGDK 2.0b
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 9th Jul 2011 17:43
Well not really atm, I've gotten completely stumped on something and can't figure out what to do.

Login to post a reply

Server time is: 2026-07-10 21:41:56
Your offset time is: 2026-07-10 21:41:56