예제 #1
0
 // initial setup / referential setup
 void InitiateVertices()
 {
     legacyVertices = new Dictionary <ProceduralObject, Dictionary <Vertex, KeyValuePair <Vector3, Vector3> > >();
     foreach (var obj in selection)
     {
         if (obj.isRootOfGroup && logic.selectedGroup == null)
         {
             foreach (var o in obj.group.objects)
             {
                 var dict = new Dictionary <Vertex, KeyValuePair <Vector3, Vector3> >();
                 foreach (Vertex v in o.vertices)
                 {
                     dict.Add(v, new KeyValuePair <Vector3, Vector3>(ProceduralUtils.VertexWorldPosition(v, o), Vector3.zero));
                 }
                 legacyVertices.Add(o, dict);
             }
         }
         else
         {
             var dict = new Dictionary <Vertex, KeyValuePair <Vector3, Vector3> >();
             foreach (Vertex v in obj.vertices)
             {
                 dict.Add(v, new KeyValuePair <Vector3, Vector3>(ProceduralUtils.VertexWorldPosition(v, obj), Vector3.zero));
             }
             legacyVertices.Add(obj, dict);
         }
     }
 }
예제 #2
0
 void CalculateProjection()
 {
     foreach (var obj in selection)
     {
         if (obj.isRootOfGroup && logic.selectedGroup == null)
         {
             // when root of group
             var bounds = obj.m_mesh.bounds;
             foreach (var po in obj.group.objects)
             {
                 // this should eventually take into account the global bounds of the group, not only itself,
                 // so as to project groups as structured units, not each individual PO
                 var vertexDict = legacyAndProjectedVertices[po];
                 foreach (Vertex v in po.vertices)
                 {
                     var old       = vertexDict[v].Key;
                     var projected = ProjectPoint(ProceduralUtils.VertexWorldPosition(old, po), projectionDirection);
                     projected = Quaternion.Inverse(po.m_rotation) * (projected - po.m_position);
                     if (offset != 0f)
                     {
                         projected -= (projected - old).normalized * offset;
                     }
                     vertexDict[v] = new KeyValuePair <Vector3, Vector3>(old, projected);
                 }
             }
         }
         else
         {
             // when inside group / not root of group
             var bounds     = obj.m_mesh.bounds;
             var vertexDict = legacyAndProjectedVertices[obj];
             foreach (Vertex v in obj.vertices)
             {
                 var old       = vertexDict[v].Key;
                 var projected = ProjectPoint(ProceduralUtils.VertexWorldPosition(old, obj), projectionDirection);
                 projected = Quaternion.Inverse(obj.m_rotation) * (projected - obj.m_position);
                 if (offset != 0f)
                 {
                     projected -= (projected - old).normalized * offset;
                 }
                 vertexDict[v] = new KeyValuePair <Vector3, Vector3>(old, projected);
             }
         }
     }
 }