2022-11-28 19:21:26 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html class="writer-html5" lang="en" >
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
<title>dna_viewer.reader.geometry — DNA Calibration documentation</title>
|
|
|
|
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
|
|
|
|
<!--[if lt IE 9]>
|
|
|
|
<script src="../../../_static/js/html5shiv.min.js"></script>
|
|
|
|
<![endif]-->
|
|
|
|
|
|
|
|
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
|
|
|
<script src="../../../_static/jquery.js"></script>
|
|
|
|
<script src="../../../_static/underscore.js"></script>
|
|
|
|
<script src="../../../_static/doctools.js"></script>
|
|
|
|
<script src="../../../_static/js/theme.js"></script>
|
|
|
|
<link rel="index" title="Index" href="../../../genindex.html" />
|
|
|
|
<link rel="search" title="Search" href="../../../search.html" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body class="wy-body-for-nav">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
|
|
<div class="wy-side-scroll">
|
|
|
|
<div class="wy-side-nav-search" >
|
|
|
|
<a href="../../../index.html" class="icon icon-home"> DNA Calibration
|
|
|
|
</a>
|
|
|
|
<div role="search">
|
|
|
|
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
|
|
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
|
|
<input type="hidden" name="area" value="default" />
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">Contents</span></p>
|
|
|
|
<ul>
|
2022-12-02 21:35:01 +08:00
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html">MetaHuman DNA Calibration</a></li>
|
2022-11-28 19:21:26 +08:00
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html#overview">Overview</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html#examples">Examples</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html#notes">Notes</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html#license">License</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../index_.html#indices-and-tables">Indices and tables</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">Repository Organization</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../repository_organization_md.html">Repository Organization</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../repository_organization_md.html#folder-structure">Folder structure</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">DNACalib</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dnacalib_md.html">DNACalib</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">DNAViewer</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dna_viewer_md.html">DNAViewer</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dna_viewer_maya_md.html">Usage in Maya</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">DNAViewer API</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dna_viewer_api_md.html">Environment Setup</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dna_viewer_api_md.html#dna">DNA</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">Technical documentation</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../dnacalib.html">dnacalib</a></li>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../modules.html">dna_viewer</a></li>
|
|
|
|
</ul>
|
|
|
|
<p class="caption" role="heading"><span class="caption-text">FAQ</span></p>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../faq_md.html">Frequently Asked Questions (FAQ)</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
|
|
<a href="../../../index.html">DNA Calibration</a>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
|
|
<div class="rst-content">
|
|
|
|
<div role="navigation" aria-label="Page navigation">
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
<li><a href="../../../index.html" class="icon icon-home"></a> »</li>
|
|
|
|
<li><a href="../../index.html">Module code</a> »</li>
|
|
|
|
<li>dna_viewer.reader.geometry</li>
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<hr/>
|
|
|
|
</div>
|
|
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
|
|
<div itemprop="articleBody">
|
|
|
|
|
|
|
|
<h1>Source code for dna_viewer.reader.geometry</h1><div class="highlight"><pre>
|
|
|
|
<span></span><span class="kn">import</span> <span class="nn">logging</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Optional</span>
|
|
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">dna</span> <span class="kn">import</span> <span class="n">BinaryStreamReader</span>
|
|
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">..const.printing</span> <span class="kn">import</span> <span class="n">BLEND_SHAPE_PRINT_RANGE</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">..model.geometry</span> <span class="kn">import</span> <span class="n">UV</span><span class="p">,</span> <span class="n">BlendShape</span><span class="p">,</span> <span class="n">Layout</span><span class="p">,</span> <span class="n">Mesh</span><span class="p">,</span> <span class="n">Point3</span>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry">[docs]</a><span class="k">class</span> <span class="nc">Geometry</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
<span class="sd"> A class used for reading the geometry part of the DNA file</span>
|
|
|
|
|
|
|
|
<span class="sd"> Attributes</span>
|
|
|
|
<span class="sd"> ----------</span>
|
|
|
|
<span class="sd"> @type reader: BinaryStreamReader</span>
|
|
|
|
<span class="sd"> @param reader: The stream reader being used</span>
|
|
|
|
|
|
|
|
<span class="sd"> @type mesh: Mesh</span>
|
|
|
|
<span class="sd"> @param mesh: The mesh model</span>
|
|
|
|
|
|
|
|
<span class="sd"> @type mesh_index: int</span>
|
|
|
|
<span class="sd"> @param mesh_index: The mesh index</span>
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stream_reader</span><span class="p">:</span> <span class="n">BinaryStreamReader</span><span class="p">,</span> <span class="n">mesh_index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span> <span class="o">=</span> <span class="n">stream_reader</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Mesh</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span> <span class="o">=</span> <span class="n">mesh_index</span>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.read"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.read">[docs]</a> <span class="k">def</span> <span class="nf">read</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Mesh</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
<span class="sd"> Starts reading in the mesh from the geometry part of the DNA</span>
|
|
|
|
|
|
|
|
<span class="sd"> @rtype: Mesh</span>
|
|
|
|
<span class="sd"> @returns: The instance of the mesh model</span>
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span> <span class="o">=</span> <span class="n">Mesh</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_mesh_name</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_topology</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_skin_weights</span><span class="p">()</span>
|
|
|
|
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">mesh</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_mesh_name"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_mesh_name">[docs]</a> <span class="k">def</span> <span class="nf">add_mesh_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the mesh name"""</span>
|
|
|
|
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getMeshName</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_skin_weights"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_skin_weights">[docs]</a> <span class="k">def</span> <span class="nf">add_skin_weights</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the skin weights"""</span>
|
|
|
|
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">skin_weights</span><span class="o">.</span><span class="n">maximum_influence_per_vertex</span> <span class="o">=</span> <span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getMaximumInfluencePerVertex</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="k">for</span> <span class="n">vertex_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexPositionCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)):</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">skin_weights</span><span class="o">.</span><span class="n">values</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getSkinWeightsValues</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">vertex_index</span><span class="p">)</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">skin_weights</span><span class="o">.</span><span class="n">joint_indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getSkinWeightsJointIndices</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">vertex_index</span><span class="p">)</span>
|
|
|
|
<span class="p">)</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_topology"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_topology">[docs]</a> <span class="k">def</span> <span class="nf">add_topology</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the positions, texture coordinates, normals, layouts and face vertex layouts"""</span>
|
|
|
|
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_positions</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_texture_coordinates</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_normals</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_layouts</span><span class="p">()</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">add_face_vertex_layouts</span><span class="p">()</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_face_vertex_layouts"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_face_vertex_layouts">[docs]</a> <span class="k">def</span> <span class="nf">add_face_vertex_layouts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the face vertex layouts"""</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">face_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getFaceCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)):</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">face_vertex_layouts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getFaceVertexLayoutIndices</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">face_index</span><span class="p">)</span>
|
|
|
|
<span class="p">)</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_layouts"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_layouts">[docs]</a> <span class="k">def</span> <span class="nf">add_layouts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the vertex layouts"""</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">layout_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexLayoutCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)):</span>
|
|
|
|
<span class="n">position_id</span><span class="p">,</span> <span class="n">texture_coordinate_id</span><span class="p">,</span> <span class="n">normal_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexLayout</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">layout_index</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">layouts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
|
|
|
|
<span class="n">Layout</span><span class="p">(</span>
|
|
|
|
<span class="n">position_index</span><span class="o">=</span><span class="n">position_id</span><span class="p">,</span>
|
|
|
|
<span class="n">texture_coordinate_index</span><span class="o">=</span><span class="n">texture_coordinate_id</span><span class="p">,</span>
|
|
|
|
<span class="n">normal_index</span><span class="o">=</span><span class="n">normal_id</span><span class="p">,</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="p">)</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_normals"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_normals">[docs]</a> <span class="k">def</span> <span class="nf">add_normals</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the normals"""</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">normal_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexNormalCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)):</span>
|
|
|
|
<span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexNormal</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">normal_index</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">normals</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Point3</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="o">=</span><span class="n">z</span><span class="p">))</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_texture_coordinates"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_texture_coordinates">[docs]</a> <span class="k">def</span> <span class="nf">add_texture_coordinates</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the texture coordinates"""</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">texture_coordinate_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexTextureCoordinateCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)</span>
|
|
|
|
<span class="p">):</span>
|
|
|
|
<span class="n">u</span><span class="p">,</span> <span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexTextureCoordinate</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">texture_coordinate_index</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">texture_coordinates</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">UV</span><span class="p">(</span><span class="n">u</span><span class="o">=</span><span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="o">=</span><span class="n">v</span><span class="p">))</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.add_positions"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.add_positions">[docs]</a> <span class="k">def</span> <span class="nf">add_positions</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""Reads in the vertex positions"""</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">vertex_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexPositionCount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">)):</span>
|
|
|
|
<span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getVertexPosition</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">vertex_index</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">positions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Point3</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="o">=</span><span class="n">z</span><span class="p">))</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.read_target_deltas"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.read_target_deltas">[docs]</a> <span class="k">def</span> <span class="nf">read_target_deltas</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">blend_shape_target_index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Point3</span><span class="p">]:</span>
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
<span class="sd"> Reads in the target deltas</span>
|
|
|
|
|
|
|
|
<span class="sd"> @rtype: Dict[int, Point3]</span>
|
|
|
|
<span class="sd"> @returns: Mapping of vertex indices to positions</span>
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">result</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Point3</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
|
|
|
|
|
|
|
|
<span class="n">vertices</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getBlendShapeTargetVertexIndices</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">blend_shape_target_index</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">blend_shape_target_delta_count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getBlendShapeTargetDeltaCount</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">blend_shape_target_index</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="k">for</span> <span class="n">delta_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">blend_shape_target_delta_count</span><span class="p">):</span>
|
|
|
|
<span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getBlendShapeTargetDelta</span><span class="p">(</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">mesh_index</span><span class="p">,</span> <span class="n">blend_shape_target_index</span><span class="p">,</span> <span class="n">delta_index</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="n">result</span><span class="p">[</span><span class="n">vertices</span><span class="p">[</span><span class="n">delta_index</span><span class="p">]]</span> <span class="o">=</span> <span class="n">Point3</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="o">=</span><span class="n">z</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">result</span></div>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="Geometry.read_blend_shapes"><a class="viewcode-back" href="../../../dna_viewer.reader.html#dna_viewer.reader.geometry.Geometry.read_blend_shapes">[docs]</a> <span class="k">def</span> <span class="nf">read_blend_shapes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mesh</span><span class="p">:</span> <span class="n">Mesh</span><span class="p">,</span> <span class="n">mesh_index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
<span class="sd"> Reads in the blend shapes</span>
|
|
|
|
|
|
|
|
<span class="sd"> @type mesh: Mesh</span>
|
|
|
|
<span class="sd"> @param mesh: The mesh model</span>
|
|
|
|
|
|
|
|
<span class="sd"> @type mesh_index: int</span>
|
|
|
|
<span class="sd"> @param mesh_index: The mesh index</span>
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">blend_shape_target_count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getBlendShapeTargetCount</span><span class="p">(</span><span class="n">mesh_index</span><span class="p">)</span>
|
|
|
|
<span class="k">for</span> <span class="n">blend_shape_target_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">blend_shape_target_count</span><span class="p">):</span>
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="n">blend_shape_target_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">%</span> <span class="n">BLEND_SHAPE_PRINT_RANGE</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
|
|
|
<span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
|
|
|
|
<span class="sa">f</span><span class="s2">"</span><span class="se">\t</span><span class="si">{</span><span class="n">blend_shape_target_index</span> <span class="o">+</span> <span class="mi">1</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">blend_shape_target_count</span><span class="si">}</span><span class="s2">"</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">mesh</span><span class="o">.</span><span class="n">blend_shapes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
|
|
|
|
<span class="n">BlendShape</span><span class="p">(</span>
|
|
|
|
<span class="n">channel</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">reader</span><span class="o">.</span><span class="n">getBlendShapeChannelIndex</span><span class="p">(</span>
|
|
|
|
<span class="n">mesh_index</span><span class="p">,</span> <span class="n">blend_shape_target_index</span>
|
|
|
|
<span class="p">),</span>
|
|
|
|
<span class="n">deltas</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">read_target_deltas</span><span class="p">(</span><span class="n">blend_shape_target_index</span><span class="p">),</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
<span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">blend_shape_target_count</span> <span class="o">%</span> <span class="n">BLEND_SHAPE_PRINT_RANGE</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
|
|
|
<span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="se">\t</span><span class="si">{</span><span class="n">blend_shape_target_count</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">blend_shape_target_count</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span></div></div>
|
|
|
|
</pre></div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<footer>
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
<div role="contentinfo">
|
|
|
|
<p>© Copyright 2022, Epic Games.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
|
|
|
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
|
|
|
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
|
|
|
|
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
jQuery(function () {
|
|
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|