Esempio n. 1
0
        //build a full tree
        public SamplerNode(int sub, Vector3 center, Vector2 size, Vector2 uv, Vector2 uvstep)
        {
            mVertex          = new SampleVertexData();
            mVertex.Position = center;
            mVertex.UV       = uv;
            Vector2 subsize   = 0.5f * size;
            Vector2 subuvstep = 0.5f * uvstep;

            if (sub > 1)
            {
                Children[0] = new SamplerNode(sub - 1,
                                              new Vector3(center.x - 0.5f * subsize.x, center.y, center.z - 0.5f * subsize.y), subsize,
                                              new Vector2(uv.x - 0.5f * subuvstep.x, uv.y - 0.5f * subuvstep.y), subuvstep);
                Children[1] = new SamplerNode(sub - 1,
                                              new Vector3(center.x + 0.5f * subsize.x, center.y, center.z - 0.5f * subsize.y), subsize,
                                              new Vector2(uv.x + 0.5f * subuvstep.x, uv.y - 0.5f * subuvstep.y), subuvstep);
                Children[2] = new SamplerNode(sub - 1,
                                              new Vector3(center.x - 0.5f * subsize.x, center.y, center.z + 0.5f * subsize.y), subsize,
                                              new Vector2(uv.x - 0.5f * subuvstep.x, uv.y + 0.5f * subuvstep.y), subuvstep);
                Children[3] = new SamplerNode(sub - 1,
                                              new Vector3(center.x + 0.5f * subsize.x, center.y, center.z + 0.5f * subsize.y), subsize,
                                              new Vector2(uv.x + 0.5f * subuvstep.x, uv.y + 0.5f * subuvstep.y), subuvstep);
            }
            else
            {
                Children[0] = new SamplerLeaf(new Vector3(center.x - 0.5f * subsize.x, center.y, center.z - 0.5f * subsize.y),
                                              new Vector2(uv.x - 0.5f * subuvstep.x, uv.y - 0.5f * subuvstep.y));
                Children[1] = new SamplerLeaf(new Vector3(center.x + 0.5f * subsize.x, center.y, center.z - 0.5f * subsize.y),
                                              new Vector2(uv.x + 0.5f * subuvstep.x, uv.y - 0.5f * subuvstep.y));
                Children[2] = new SamplerLeaf(new Vector3(center.x - 0.5f * subsize.x, center.y, center.z + 0.5f * subsize.y),
                                              new Vector2(uv.x - 0.5f * subuvstep.x, uv.y + 0.5f * subuvstep.y));
                Children[3] = new SamplerLeaf(new Vector3(center.x + 0.5f * subsize.x, center.y, center.z + 0.5f * subsize.y),
                                              new Vector2(uv.x + 0.5f * subuvstep.x, uv.y + 0.5f * subuvstep.y));
            }
        }
Esempio n. 2
0
 public void AddBoundary(int subdivision, int x, int z, byte bk, SampleVertexData vert)
 {
     if (mNode is SamplerNode)
     {
         SamplerNode node = (SamplerNode)mNode;
         node.AddBoundary(subdivision, x, z, bk, vert);
     }
 }
Esempio n. 3
0
 private void CombineTree(float angleErr)
 {
     if (mNode is SamplerNode)
     {
         SamplerNode node = (SamplerNode)mNode;
         node.CombineNode(angleErr);
         if (node.isFullLeaf)
         {
             SamplerLeaf leaf = node.Combine(angleErr);
             if (leaf != null)
             {
                 mNode = leaf;
             }
         }
     }
 }
Esempio n. 4
0
 public void CombineNode(float angleErr)
 {
     for (int i = 0; i < 4; ++i)
     {
         if (Children[i] is SamplerNode)
         {
             SamplerNode subNode = (SamplerNode)Children[i];
             subNode.CombineNode(angleErr);
             if (subNode.isFullLeaf)
             {
                 SamplerLeaf replacedLeaf = subNode.Combine(angleErr);
                 if (replacedLeaf != null)
                 {
                     Children[i] = replacedLeaf;
                 }
             }
         }
     }
 }