Re: CSG operations on textured meshes -- something better than CGAL?

Jon Watte <[email protected]> Wed, 21 May 2014 08:05:49 -0700
Newsgroups gmane.games.devel.algorithms
Message-ID <CAJgyHGP7HmRjPpFc+CV+-E6JQFOcEfRG-hQH7+dRRi1PGqdWzA@mail.gmail.com>
--===============1503169222679303069==
Content-Type: multipart/alternative; boundary=001a11c2980eefda8904f9ea5447

--001a11c2980eefda8904f9ea5447
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

> You are going to be distorting triangles in different ways depending on
the overall shape of the mesh at any given point though.
> If you just retain existing UV coordinates for the new vertices, the
results will be...  strange.

I do this operation with some frequency in 3ds Max, and it works the way I
expect there.

The 3ds Max boolean (and proboolean) modifier behavior would be good enough
for my purposes, although they do have some edge cases and limitaitons (a k
a "bugs" :-)
But I don't want to buy a copy of 3ds Max per server that will be running
this code, not to mention I want to run the servers on Linux.

So, does anyone know of any textured-triangle-mesh CSG library out there,
free or paid for, that would work?

Sincerely,

jw






Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas
Jefferson


On Tue, May 13, 2014 at 10:07 PM, James Robertson <[email protected]> wrote=
:

>  You are going to be distorting triangles in different ways depending on
> the overall shape of the mesh at any given point though.  If you just
> retain existing UV coordinates for the new vertices, the results will
> be...  strange.
>
> Consider the case where a convex region meets a concave one.  One side of
> the triangle will be slightly expanded, while the other side will be
> contracted.  Of course you know your input data better than us, so maybe
> such distortions are acceptable or won't be noticeable, but they will be
> there.
>
>
>
> On 14/05/2014 01:41, Jon Watte wrote:
>
>  I don=E2=80=99t believe you will be able to use your existing uv values =
with the
>> mesh that results from this csg operation
>
>
>  The operations I want to do are rigid and well conditioned and do not
> stretch or generate new surfaces compared to the input meshes. They may
> invert the winding of triangles, though (so normal maps would have to be
> flipped) in the case of a cut-out.
> I also need to preserve vertex bone weighting, too... something that can
> preserve UV should be able to preserve that, too. Worst case, I put in a
> vertex ID value in the UV channel and loop up the other parameters based =
on
> that.
>
>  So... no general purpose parameterized trimesh CSG library available?
>
>  Sincerely,
>
>  jw
>
>
>
>
>
> Sincerely,
>
> Jon Watte
>
>
> --
> "I find that the harder I work, the more luck I seem to have." -- Thomas
> Jefferson
>
>
> On Thu, May 8, 2014 at 12:28 PM, Chris Green <[email protected]>wr=
ote:
>
>>  I don=E2=80=99t believe you will be able to use your existing uv values=
 with
>> the mesh that results from this csg operation =E2=80=93 it has a differe=
nt
>> topology, and there will be changes in the ratios of the areas of differ=
ent
>> parts of the model, with really bumpy areas of the mesh being smoothed o=
ut,
>> etc. You=E2=80=99ll even have brand new areas emerge that don=E2=80=99t =
have corresponding
>> areas on the original model, as holes are filled in, etc.
>>
>>
>>
>> What might work better is to just do the csg operation and generate a uv
>> atlas for the resultant mesh. You can then generate a new texture map fo=
r
>> this uv parametization by sampling from the original one, in a similar
>> manner to the way in which people produce bumpmaps mapping the normals o=
f
>> highly tessellated models onto low-detail models.
>>
>>
>>
>>
>>
>>
>>
>> *From:* Jon Watte [mailto:[email protected]]
>> *Sent:* Thursday, May 08, 2014 11:08 AM
>> *To:* Game Development Algorithms
>> *Subject:* [Algorithms] CSG operations on textured meshes -- something
>> better than CGAL?
>>
>>
>>
>> I have a triangle mesh composed of many submeshes with different
>> textures/materials. This mesh may not be a 2-manifold -- it may have ope=
n
>> edges. Typical game art.
>>
>>
>>
>> I now want to create a 3mm thick shell of this mesh. As an approximation=
,
>> taking each triangle, and extrude it back along the normal of each verte=
x,
>> and union all of those generated chopped pyramids would be an approximat=
ion
>> of what I want. If I do literally that, and self-union the result, then
>> that should resolve the self-intersection problems I'll run into along
>> narrow sharp creases etc.
>>
>>
>>
>> I can't find any library to do this, though. CGAL has some fairly robust
>> functions on NEF polyhedra, but those polyhedra don't seem to allow
>> parameterization (which is academic speak for texture coordinates that m=
ay
>> have discontinuities across edges.)
>>
>>
>>
>> So, what are some robust CSG libraries available that work on such
>> game-style meshes, preserving texture coordinates?
>>
>>
>>
>> (And actually, I don't have one such mesh; I have > 120 million such
>> meshes, so a by-hand or even script-the-Max-shell-modifier solution is
>> unlikely to work. I do have hundreds of Linux servers at my disposal,
>> though.)
>>
>>
>>
>> Sincerely,
>>
>> Jon Watte
>>
>>
>> --
>> "I find that the harder I work, the more luck I seem to have." -- Thomas
>> Jefferson
>>
>>
>> ------------------------------------------------------------------------=
------
>> Is your legacy SCM system holding you back? Join Perforce May 7 to find
>> out:
>> &#149; 3 signs your SCM is hindering your productivity
>> &#149; Requirements for releasing software faster
>> &#149; Expert tips and advice for migrating your SCM now
>> http://p.sf.net/sfu/perforce
>> _______________________________________________
>> GDAlgorithms-list mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
>> Archives:
>> http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgorithms-l=
ist
>>
>
>
>
> -------------------------------------------------------------------------=
-----
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform avai=
lable
> Simple to use. Nothing to install. Get started now for free."http://p.sf.=
net/sfu/SauceLabs
>
>
>
> _______________________________________________
> GDAlgorithms-list mailing [email protected]=
s://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
> Archives:http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo=
rithms-list
>
>
>
>
> ------------------------------
>    <http://www.avast.com/>
>
> This email is free from viruses and malware because avast! Antivirus<http=
://www.avast.com/>protection is active.
>
>
>
> -------------------------------------------------------------------------=
-----
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> GDAlgorithms-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgorithms-li=
st
>

--001a11c2980eefda8904f9ea5447
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><span style=3D"font-family:arial,sans-serif;font-size:16.3=
63636016845703px">&gt; You are going to be distorting triangles in differen=
t ways depending on the overall shape of the mesh at any given point though=
.=C2=A0</span><div>
<span style=3D"font-family:arial,sans-serif;font-size:16.363636016845703px"=
>&gt; If you just retain existing UV coordinates for the new vertices, the =
results will be...=C2=A0 strange.</span><br><div><span style=3D"font-family=
:arial,sans-serif;font-size:16.363636016845703px"><br>
</span></div><div><span style=3D"font-family:arial,sans-serif;font-size:16.=
363636016845703px">I do this operation with some frequency in 3ds Max, and =
it works the way I expect there.</span></div><div><span style=3D"font-famil=
y:arial,sans-serif;font-size:16.363636016845703px"><br>
</span></div><div><span style=3D"font-family:arial,sans-serif;font-size:16.=
363636016845703px">The 3ds Max boolean (and proboolean) modifier behavior w=
ould be good enough for my purposes, although they do have some edge cases =
and limitaitons (a k a &quot;bugs&quot; :-)</span></div>
</div><div><span style=3D"font-family:arial,sans-serif;font-size:16.3636360=
16845703px">But I don&#39;t want to buy a copy of 3ds Max per server that w=
ill be running this code, not to mention I want to run the servers on Linux=
.</span></div>
<div><span style=3D"font-family:arial,sans-serif;font-size:16.3636360168457=
03px"><br></span></div><div><span style=3D"font-family:arial,sans-serif;fon=
t-size:16.363636016845703px">So, does anyone know of any textured-triangle-=
mesh CSG library out there, free or paid for, that would work?</span></div>
<div><span style=3D"font-family:arial,sans-serif;font-size:16.3636360168457=
03px"><br></span></div><div><span style=3D"font-family:arial,sans-serif;fon=
t-size:16.363636016845703px">Sincerely,</span></div><div><span style=3D"fon=
t-family:arial,sans-serif;font-size:16.363636016845703px"><br>
</span></div><div><span style=3D"font-family:arial,sans-serif;font-size:16.=
363636016845703px">jw</span></div><div><span style=3D"font-family:arial,san=
s-serif;font-size:16.363636016845703px"><br></span></div><div><span style=
=3D"font-family:arial,sans-serif;font-size:16.363636016845703px"><br>
</span></div></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div d=
ir=3D"ltr"><font face=3D"courier new, monospace"><br><br><br><font>Sincerel=
y,</font><br><br><font>Jon Watte</font><br><br><br>--<br>&quot;<span style=
=3D"color:rgb(0,0,0)">I find that the harder I work, the more luck I seem t=
o have.&quot; -- Thomas Jefferson</span></font></div>
</div>
<br><br><div class=3D"gmail_quote">On Tue, May 13, 2014 at 10:07 PM, James =
Robertson <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex">

 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    You are going to be distorting triangles in different ways depending
    on the overall shape of the mesh at any given point though.=C2=A0 If yo=
u
    just retain existing UV coordinates for the new vertices, the
    results will be...=C2=A0 strange.<br>
    <br>
    Consider the case where a convex region meets a concave one.=C2=A0 One
    side of the triangle will be slightly expanded, while the other side
    will be contracted.=C2=A0 Of course you know your input data better tha=
n
    us, so maybe such distortions are acceptable or won&#39;t be noticeable=
,
    but they will be there.<div><div class=3D"h5"><br>
    <br>
    <br>
    <div>On 14/05/2014 01:41, Jon Watte wrote:<br>
    </div>
    </div></div><blockquote type=3D"cite"><div><div class=3D"h5">
      <div dir=3D"ltr">
        <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style=
:solid;padding-left:1ex"><span style=3D"color:rgb(31,73,125);font-family:Ca=
libri,sans-serif;font-size:14.399999618530273px">I
            don=E2=80=99t believe you will be able to use your existing uv
            values with the mesh that results from this csg operation</span=
></blockquote>
        <div><br>
        </div>
        <div>The operations I want to do are rigid and well conditioned
          and do not stretch or generate new surfaces compared to the
          input meshes. They may invert the winding of triangles, though
          (so normal maps would have to be flipped) in the case of a
          cut-out.</div>
        <div>I also need to preserve vertex bone weighting, too...
          something that can preserve UV should be able to preserve
          that, too. Worst case, I put in a vertex ID value in the UV
          channel and loop up the other parameters based on that.</div>
        <div><br>
        </div>
        <div>So... no general purpose parameterized trimesh CSG library
          available?=C2=A0</div>
        <div><br>
        </div>
        <div>Sincerely,</div>
        <div><br>
        </div>
        <div>jw</div>
        <div><br>
        </div>
      </div>
      <div class=3D"gmail_extra"><br clear=3D"all">
        <div>
          <div dir=3D"ltr"><font face=3D"courier new, monospace"><br>
              <br>
              <br>
              <font>Sincerely,</font><br>
              <br>
              <font>Jon Watte</font><br>
              <br>
              <br>
              --<br>
              &quot;<span style=3D"color:rgb(0,0,0)">I find that the harder=
 I
                work, the more luck I seem to have.&quot; -- Thomas Jeffers=
on</span></font></div>
        </div>
        <br>
        <br>
        <div class=3D"gmail_quote">On Thu, May 8, 2014 at 12:28 PM, Chris
          Green <span dir=3D"ltr">&lt;<a href=3D"mailto:cgreen@valvesoftwar=
e.com" target=3D"_blank">[email protected]</a>&gt;</span>
          wrote:<br>
          <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex">
            <div link=3D"blue" vlink=3D"purple" lang=3D"EN-US">
              <div>
                <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font=
-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I
                    don=E2=80=99t believe you will be able to use your exis=
ting
                    uv values with the mesh that results from this csg
                    operation =E2=80=93 it has a different topology, and th=
ere
                    will be changes in the ratios of the areas of
                    different parts of the model, with really bumpy
                    areas of the mesh being smoothed out, etc. You=E2=80=99=
ll
                    even have brand new areas emerge that don=E2=80=99t hav=
e
                    corresponding areas on the original model, as holes
                    are filled in, etc.</span></p>
                <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font=
-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0</s=
pan></p>
                <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font=
-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">What
                    might work better is to just do the csg operation
                    and generate a uv atlas for the resultant mesh. You
                    can then generate a new texture map for this uv
                    parametization by sampling from the original one, in
                    a similar manner to the way in which people produce
                    bumpmaps mapping the normals of highly tessellated
                    models onto low-detail models.
                  </span></p>
                <div>
                  <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;fo=
nt-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0<=
/span></p>
                  <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;fo=
nt-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0<=
/span></p>
                  <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;fo=
nt-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">=C2=A0<=
/span></p>
                  <p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt=
;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><sp=
an style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-seri=
f&quot;">
                      Jon Watte [mailto:<a href=3D"mailto:[email protected]"=
 target=3D"_blank">[email protected]</a>]
                      <br>
                      <b>Sent:</b> Thursday, May 08, 2014 11:08 AM<br>
                      <b>To:</b> Game Development Algorithms<br>
                      <b>Subject:</b> [Algorithms] CSG operations on
                      textured meshes -- something better than CGAL?</span>=
</p>
                  <p class=3D"MsoNormal">=C2=A0</p>
                </div>
                <div>
                  <p class=3D"MsoNormal">I have a triangle mesh composed
                    of many submeshes with different textures/materials.
                    This mesh may not be a 2-manifold -- it may have
                    open edges. Typical game art.</p>
                  <div>
                    <div>
                      <div>
                        <p class=3D"MsoNormal">=C2=A0</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">I now want to create a 3mm
                          thick shell of this mesh. As an approximation,
                          taking each triangle, and extrude it back
                          along the normal of each vertex, and union all
                          of those generated chopped pyramids would be
                          an approximation of what I want. If I do
                          literally that, and self-union the result,
                          then that should resolve the self-intersection
                          problems I&#39;ll run into along narrow sharp
                          creases etc.</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">=C2=A0</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">I can&#39;t find any library=
 to
                          do this, though. CGAL has some fairly robust
                          functions on NEF polyhedra, but those
                          polyhedra don&#39;t seem to allow parameterizatio=
n
                          (which is academic speak for texture
                          coordinates that may have discontinuities
                          across edges.)</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">=C2=A0</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">So, what are some robust
                          CSG libraries available that work on such
                          game-style meshes, preserving texture
                          coordinates?</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">=C2=A0</p>
                      </div>
                      <div>
                        <p class=3D"MsoNormal">(And actually, I don&#39;t h=
ave
                          one such mesh; I have &gt; 120 million such
                          meshes, so a by-hand or even
                          script-the-Max-shell-modifier solution is
                          unlikely to work. I do have hundreds of Linux
                          servers at my disposal, though.)<br clear=3D"all"=
>
                        </p>
                        <div>
                          <div>
                            <p class=3D"MsoNormal"><span><br>
                                <br>
                                Sincerely,<br>
                                <br>
                                Jon Watte<br>
                                <br>
                                <br>
                                --<br>
                                &quot;<span style=3D"color:black">I find th=
at
                                  the harder I work, the more luck I
                                  seem to have.&quot; -- Thomas Jefferson</=
span></span></p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <br>
---------------------------------------------------------------------------=
---<br>
            Is your legacy SCM system holding you back? Join Perforce
            May 7 to find out:<br>
            &amp;#149; 3 signs your SCM is hindering your productivity<br>
            &amp;#149; Requirements for releasing software faster<br>
            &amp;#149; Expert tips and advice for migrating your SCM now<br=
>
            <a href=3D"http://p.sf.net/sfu/perforce" target=3D"_blank">http=
://p.sf.net/sfu/perforce</a><br>
            _______________________________________________<br>
            GDAlgorithms-list mailing list<br>
            <a href=3D"mailto:[email protected]" targ=
et=3D"_blank">[email protected]</a><br>
            <a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgor=
ithms-list" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/=
gdalgorithms-list</a><br>
            Archives:<br>
            <a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_n=
ame=3Dgdalgorithms-list" target=3D"_blank">http://sourceforge.net/mailarchi=
ve/forum.php?forum_name=3Dgdalgorithms-list</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>----------------------------------------------------=
--------------------------
&quot;Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform availa=
ble
Simple to use. Nothing to install. Get started now for free.&quot;
<a href=3D"http://p.sf.net/sfu/SauceLabs" target=3D"_blank">http://p.sf.net=
/sfu/SauceLabs</a></pre><div class=3D"">
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
GDAlgorithms-list mailing list
<a href=3D"mailto:[email protected]" target=3D"_blank=
">[email protected]</a>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gdalgorithms=
-list</a>
Archives:
<a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo=
rithms-list" target=3D"_blank">http://sourceforge.net/mailarchive/forum.php=
?forum_name=3Dgdalgorithms-list</a></pre>
    </div></blockquote>
    <br>
 =20
<br><br>
<hr style=3D"border:none;color:#909090;background-color:#b0b0b0;min-height:=
1px;width:99%">
<table style=3D"border-collapse:collapse;border:none">
	<tbody><tr>
		<td style=3D"border:none;padding:0px 15px 0px 8px">
			<a href=3D"http://www.avast.com/" target=3D"_blank">
				<img border=3D"0">
			</a>
		</td>
		<td>
			<p style=3D"color:#3d4d5a;font-family:&quot;Calibri&quot;,&quot;Verdana&=
quot;,&quot;Arial&quot;,&quot;Helvetica&quot;;font-size:12pt">
				This email is free from viruses and malware because <a href=3D"http://w=
ww.avast.com/" target=3D"_blank">avast! Antivirus</a> protection is active.
			</p>
		</td>
	</tr>
</tbody></table>
<br>
</div>

<br>-----------------------------------------------------------------------=
-------<br>
&quot;Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE=
<br>
Instantly run your Selenium tests across 300+ browser/OS combos.<br>
Get unparalleled scalability from the best Selenium testing platform availa=
ble<br>
Simple to use. Nothing to install. Get started now for free.&quot;<br>
<a href=3D"http://p.sf.net/sfu/SauceLabs" target=3D"_blank">http://p.sf.net=
/sfu/SauceLabs</a><br>_______________________________________________<br>
GDAlgorithms-list mailing list<br>
<a href=3D"mailto:[email protected]">GDAlgorithms-lis=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gdalgorithms=
-list</a><br>
Archives:<br>
<a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo=
rithms-list" target=3D"_blank">http://sourceforge.net/mailarchive/forum.php=
?forum_name=3Dgdalgorithms-list</a><br></blockquote></div><br></div>

--001a11c2980eefda8904f9ea5447--


--===============1503169222679303069==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
--===============1503169222679303069==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
--===============1503169222679303069==--