Changeset 2405


Ignore:
Timestamp:
Feb 13, 2013, 4:42:11 PM (7 years ago)
Author:
touky
Message:

easymesh : all radius are now diameters so all mesh operation size values are coherent.

Location:
trunk
Files:
3 edited

Legend:

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

    r2404 r2405  
    10071007
    10081008//-----------------------------------------------------------------------------
    1009 void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2,
     1009void EasyMesh::AppendCylinder(int nsides, float h, float d1, float d2,
    10101010                              int dualside, int smooth, int close)
    10111011{
     1012    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1013    float r1 = d1 * .5f;
     1014    float r2 = d2 * .5f;
     1015
    10121016    //SAVE
    10131017    vec4 Saved_Color = m_color;
     
    10911095
    10921096//-----------------------------------------------------------------------------
    1093 void EasyMesh::AppendSphere(int ndivisions, float r)
    1094 {
    1095     AppendCapsule(ndivisions, 0.f, r);
    1096 }
    1097 
    1098 //-----------------------------------------------------------------------------
    1099 void EasyMesh::AppendCapsule(int ndivisions, float h, float r)
    1100 {
     1097void EasyMesh::AppendSphere(int ndivisions, float d)
     1098{
     1099    AppendCapsule(ndivisions, 0.f, d);
     1100}
     1101
     1102//-----------------------------------------------------------------------------
     1103void EasyMesh::AppendCapsule(int ndivisions, float h, float d)
     1104{
     1105    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1106    float r = d * .5f;
     1107
    11011108    int ibase = m_indices.Count();
    11021109
     
    12381245
    12391246//-----------------------------------------------------------------------------
    1240 void EasyMesh::AppendTorus(int ndivisions, float r1, float r2)
    1241 {
     1247void EasyMesh::AppendTorus(int ndivisions, float d1, float d2)
     1248{
     1249    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1250    float r1 = d1 * .5f;
     1251    float r2 = d2 * .5f;
     1252
    12421253    int ibase = m_indices.Count();
    12431254    int nidiv = ndivisions; /* Cross-section */
     
    14191430
    14201431//-----------------------------------------------------------------------------
    1421 void EasyMesh::AppendStar(int nbranches, float r1, float r2,
     1432void EasyMesh::AppendStar(int nbranches, float d1, float d2,
    14221433                          int fade, int fade2)
    14231434{
     1435    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1436    float r1 = d1 * .5f;
     1437    float r2 = d2 * .5f;
     1438
    14241439    //TODO: It would probably be good to think of another way of UV painting this, like "branch repeating"
    14251440    int vbase = m_vert.Count();
     
    14551470
    14561471//-----------------------------------------------------------------------------
    1457 void EasyMesh::AppendExpandedStar(int nbranches, float r1,
    1458                                   float r2, float extrar)
    1459 {
     1472void EasyMesh::AppendExpandedStar(int nbranches, float d1, float d2, float extrad)
     1473{
     1474    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1475    float r1 = d1 * .5f;
     1476    float r2 = d2 * .5f;
     1477    float extrar = extrad * .5f;
     1478
    14601479    int vbase = m_vert.Count();
    14611480    float maxr = (float)max(max(r1, r2), max(r1 + extrar, r2 + extrar));
     
    14951514
    14961515//-----------------------------------------------------------------------------
    1497 void EasyMesh::AppendDisc(int nsides, float r, int fade)
    1498 {
     1516void EasyMesh::AppendDisc(int nsides, float d, int fade)
     1517{
     1518    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1519    float r = d * .5f;
     1520
    14991521    int vbase = m_vert.Count();
    15001522
     
    15171539
    15181540//-----------------------------------------------------------------------------
    1519 void EasyMesh::AppendSimpleTriangle(float size, int fade)
    1520 {
     1541void EasyMesh::AppendSimpleTriangle(float d, int fade)
     1542{
     1543    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1544    float size = d * .5f;
     1545
    15211546    mat3 m = mat3::rotate(120.f, 0.f, 1.f, 0.f);
    15221547    vec3 p(0.f, 0.f, size);
     
    15581583
    15591584//-----------------------------------------------------------------------------
    1560 void EasyMesh::AppendCog(int nbsides, float h, float r10, float r20,
    1561                          float r1, float r2, float r12, float r22,
     1585void EasyMesh::AppendCog(int nbsides, float h, float d10, float d20,
     1586                         float d1, float d2, float d12, float d22,
    15621587                         float sidemul, int offset)
    15631588{
     1589    //XXX : This operation is done to convert radius to diameter without changing all the code.
     1590    float r10 = d10 * .5f;
     1591    float r20 = d20 * .5f;
     1592    float r1  = d1  * .5f;
     1593    float r2  = d2  * .5f;
     1594    float r12 = d12 * .5f;
     1595    float r22 = d22 * .5f;
     1596
    15641597    int ibase = m_indices.Count();
    15651598    int vbase = m_vert.Count();
  • trunk/src/easymesh/easymesh.h

    r2404 r2405  
    236236    //-------------------------------------------------------------------------
    237237
    238     /* [cmd:ac] Cylinder centered on (0,0,0) with BBox [-max(r1, r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)]
    239         - nbsides : Number of sides.
     238    /* [cmd:ac] Cylinder centered on (0,0,0) with BBox [-.5*max(d1, d2), -.5*h, -.5*max(d1, d2)]
     239        - nbsides : Number of sides.                   [+.5*max(d1, d2), +.5*h, +.5*max(d1, d2)]
    240240        - h : Height of the cylinder.
    241         - r1 : Lower radius. TODO:convert to diameter to be coherent with other funcs
    242         - r2 : Upper radius. TODO:convert to diameter to be coherent with other funcs
     241        - d1 : Lower diameter.
     242        - d2 : Upper diameter.
    243243        - dualside : if (1) will also create inner sides : TOOD:TOREMOVE?? : needed ?
    244244        - smooth : if (1) will smooth normals : TOOD:TOREMOVE : smooth should be handled elsewhere
    245245        - close : if (1) will add discs to close the cylinder
    246246     */
    247     void AppendCylinder(int nsides, float h, float r1, float r2,
     247    void AppendCylinder(int nsides, float h, float d1, float d2,
    248248                        int dualside, int smooth, int close);
    249     /* [cmd:asph] Sphere centered on (0,0,0) with BBox [-size][size]
     249    /* [cmd:asph] Sphere centered on (0,0,0) with BBox [-.5*d][.5*d]
    250250        - ndivisions : number of subdivisions each Sphere triangle will sustain.
    251         - size : size of the Sphere.
    252      */
    253     void AppendSphere(int ndivisions, float r);
    254     /* [cmd:acap] Capsule centered on (0,0,0) with BBox [-r, -(r+h) ,-r][r, (r+h) ,r]
     251        - d : Diameter.
     252     */
     253    void AppendSphere(int ndivisions, float d);
     254    /* [cmd:acap] Capsule centered on (0,0,0) with BBox [-.5*d, -(.5*d+h), -.5*d][.5*d, (.5*d+h), .5*d]
    255255        - ndivisions : number of subdivisions each Sphere triangle will sustain.
    256256        - h : Inner height.
    257         - r : Radius. TODO:convert to diameter to be coherent with other funcs
    258      */
    259     void AppendCapsule(int ndivisions, float h, float r);
    260     /* [cmd:ato] Torus centered on (0,0,0) with BBox [-r2][r2]
     257        - d : Diameter.
     258     */
     259    void AppendCapsule(int ndivisions, float h, float d);
     260    /* [cmd:ato] Torus centered on (0,0,0) with BBox [-.5*d2][.5*d2]
    261261        - ndivisions : number of subdivisions of the torus.
    262         - r1 : Inner radius. TODO:convert to diameter to be coherent with other funcs
    263         - r2 : Outer radius. TODO:convert to diameter to be coherent with other funcs
    264      */
    265     void AppendTorus(int ndivisions, float r1, float r2);
     262        - d1 : Inner diameter.
     263        - d2 : Outer diameter.
     264     */
     265    void AppendTorus(int ndivisions, float d1, float d2);
    266266    /* [cmd:ab] Box centered on (0,0,0) with BBox [-.5 * size][.5 * size]
    267267        - size : size of the box.
     
    277277    void AppendBox(vec3 const &size, float chamf, bool smooth);
    278278    /* [cmd:as]
    279        Append a Star centered on (0,0,0) contained within a disc of "max(r1, r2)" radius.
     279       Append a Star centered on (0,0,0) contained within a disc of "max(d1, d2)" diameter.
    280280        - nbranches : Number of branches.
    281         - r1 : Length of the branches.
    282         - r2 : Length of the "branch" located between r1-branches.
     281        - d1 : double Length of the branches.
     282        - d2 : double Length of the "branch" located between d1-branches.
    283283        - fade : if (1) in-between branches use Color2.
    284284        - fade2 : if (1) Star branches use Color2.
    285285     */
    286     void AppendStar(int nbranches, float r1, float r2,
     286    void AppendStar(int nbranches, float d1, float d2,
    287287                    int fade = 0, int fade2 = 0);
    288     /* [cmd:aes] Star centered on (0,0,0) contained within a disc of "max(max(r1, r2), max(r1 + extrar, r2 + extrar))" radius.
     288    /* [cmd:aes] Star centered on (0,0,0) contained within a disc of "max(max(d1, d2), max(d1 + extrad, d2 + extrad))" diameter.
    289289       Expanded star branches use Color2.
    290290        - nbranches : Number of branches.
    291         - r1 : Length of the branches.
    292         - r2 : Length of the "branch" located between r1-branches.
    293         - extrar : Extra length added to expand all branches.
    294      */
    295     void AppendExpandedStar(int nbranches, float r1, float r2, float extrar);
    296     /* [cmd:ad] Disc centered on (0,0,0) with BBox [-size][size]
     291        - d1 : Double Length of the branches.
     292        - d2 : Double Length of the "branch" located between r1-branches.
     293        - extrad : Extra length added to expand all branches.
     294     */
     295    void AppendExpandedStar(int nbranches, float d1, float d2, float extrad);
     296    /* [cmd:ad] Disc centered on (0,0,0) with d diameter.
    297297        - nbsides : Number of sides.
    298         - r : Radius. TODO:convert to diameter to be coherent with other funcs
     298        - d : Diameter.
    299299        - fade : if (1) Outer vertices will use Color2
    300300     */
    301     void AppendDisc(int nsides, float r, int fade = 0);
    302     /* [cmd:at] Triangle centered on (0,0,0) contained within a disc of "size" radius.
    303         - size : Size of vector : origin-TO-vertex.
     301    void AppendDisc(int nsides, float d, int fade = 0);
     302    /* [cmd:at] Triangle centered on (0,0,0) contained within a disc of "d" diameter.
     303        - d : diameter of the containing disc..
    304304        - fade : if (1) 2nd & 3rd Vertices will use Color2
    305305     */
    306     void AppendSimpleTriangle(float size, int fade = 0);
    307     /* [cmd:aq] Quad centered on (0,0,0) contained within BBox [-size,0,-size][size,0,size]
     306    void AppendSimpleTriangle(float d, int fade = 0);
     307    /* [cmd:aq] Quad centered on (0,0,0) contained within BBox [-size*.5f, 0, -size*.5f][size*.5f, 0, size*.5f]
    308308        - size : Size of quad.
    309309        - fade : if (1) 3rd & 4th Vertices will use Color2
     
    314314    void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0);
    315315public:
    316     /* [cmd:acg] Gear centered on (0,0,0) contained within BBox [-max(r1,r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)]
    317         - h : Height of the Gear.
    318         - r10 : Upper Inner radius.
    319         - r20 : Lower Inner radius.
    320         - r1  : Upper Outer radius.
    321         - r2  : Lower Outer radius.
    322         - r12 : Upper Cog radius.
    323         - r22 : Lower Cog radius.
     316    /* [cmd:acg] Gear centered on (0,0,0) contained within BBox [-.5*max(d1,d2), -.5*h, -.5*max(d1, d2)]
     317        - h : Height of the Gear.                               [+.5*max(d1,d2), +.5*h, +.5*max(d1, d2)]
     318        - d10 : Upper Inner diameter.
     319        - d20 : Lower Inner diameter.
     320        - d1  : Upper Outer diameter.
     321        - d2  : Lower Outer diameter.
     322        - d12 : Upper Cog diameter.
     323        - d22 : Lower Cog diameter.
    324324        - sidemul : multiplier for the size of the cogs.
    325325        - offset : useless
    326326     */
    327     void AppendCog(int nbsides, float h, float r10, float r20, float r1,
    328                    float r2, float r12, float r22, float sidemul, int offset);
     327    void AppendCog(int nbsides, float h, float d10, float d20, float d1,
     328                   float d2, float d12, float d22, float sidemul, int offset);
    329329
    330330    //-------------------------------------------------------------------------
  • trunk/test/MeshViewerBuffer.txt

    r2404 r2405  
    1 [sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0]
     1//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0]
     2//[sc#88f ab 4 4 4]
    23//[sc#ff2 asph 2 4 tx 4 tax 1 1 0]
     4[sc#ff2 asph 2 4]
    35//[sc#ff2 acap 1 4 4]
    46//[sc#ff2 scb#ff2 ac 10 4 4 4 0 0 1]
     
    810//[sc#ff2 scb#2ff aq 4 0]
    911//[sc#ff2 scb#2ff aes 5 3 6 2]
    10 //[sc#ff2 scb#2ff as 5 2 5 0 0]
     12//[sc#ff2 scb#2ff as 4 2 4 0 0]
    1113//[sc#ff2 scb#2ff acg 2 10 .1 .1 .4 .4 .1 .1 0 1]
    1214
Note: See TracChangeset for help on using the changeset viewer.