Changeset 1784


Ignore:
Timestamp:
Aug 21, 2012, 2:09:14 PM (11 years ago)
Author:
elliotek
Message:

EsayMesh : RadialJitter func & demo added

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.cpp

    r1719 r1784  
    238238}
    239239
     240void EasyMesh::RadialJitter(float r)
     241{
     242    Array<int> Welded;
     243        Welded.Push(-1);
     244    for (int i = m_cursors.Last().m1 + 1; i < m_vert.Count(); i++)
     245        {
     246                int j;
     247                for (j = m_cursors.Last().m1; j < i; j++)
     248                {
     249                        if(sqlength(m_vert[i].m1 - m_vert[j].m1) < 0.1f)
     250                                break;
     251                }
     252
     253                if(j == i)
     254                        Welded.Push(-1);
     255                else
     256                        Welded.Push(j);
     257        }
     258
     259        int i, j;
     260    for (i = m_cursors.Last().m1, j = 0; i < m_vert.Count(); i++, j++)
     261        {
     262                if(Welded[j] == -1)
     263                        m_vert[i].m1 *= 1.0f + RandF(r);
     264                else
     265                        m_vert[i].m1 = m_vert[Welded[j]].m1;
     266        }
     267
     268        ComputeNormals(m_cursors.Last().m2, m_indices.Count() - m_cursors.Last().m2);
     269}
     270
    240271void EasyMesh::TaperX(float y, float z, float xoff)
    241272{
  • trunk/src/easymesh/easymesh.h

    r1705 r1784  
    5252    void SetCurVertNormal(vec3 const &normal);
    5353    void SetCurVertColor(vec4 const &color);
     54
     55    void RadialJitter(float r);
    5456
    5557    void Translate(vec3 const &v);
  • trunk/tutorial/05_easymesh.cpp

    r1705 r1784  
    3030                m_mesh.Compile("ad12,2.2,0 ty.1 ac12,.2,2.4,2.2,0,1 ty.8 ac12,1.7,2.4,2.4,0,1 ty2.5");
    3131                m_mesh.Translate(vec3(i * 8.f, (h - 1) * 3.2f, j * 8.f));
    32                 m_mesh.CloseBrace();
     32
     33                                m_mesh.CloseBrace();
    3334            }
    3435        m_mesh.OpenBrace();
     
    3738        m_mesh.CloseBrace();
    3839        m_mesh.Translate(vec3(dx * 8.f, dh * 3.2f, dy * 8.f));
     40
    3941        m_mesh.CloseBrace();
    4042    }
     
    4345    {
    4446        m_angle = 0;
    45         //m_mesh.Compile("sc#e94 scb#964 [asph11 7 7 7 tx10]");
     47        m_mesh.Compile("sc#800 [asph10 20 20 20]");
     48                m_mesh.RadialJitter(0.2f);             
    4649        //m_mesh.Compile("sc#94e scb#649 [asph3 7 7 7 tx-6 tz-9]");
    4750        //m_mesh.Compile("sc#49e scb#469 [asph31 7 7 7 tx-6 tz9]");
Note: See TracChangeset for help on using the changeset viewer.