Changeset 2226 for trunk/tutorial


Ignore:
Timestamp:
Jan 17, 2013, 9:49:29 PM (8 years ago)
Author:
touky
Message:

Added CSG v0.001a : not optimized, too much operation makes it slow. triangle count is not optimized.
Useage : "...[.... csg*]" equals "current mesh -CSG- the mesh in the braces".
Keywords : CsgUnion<csgu>, CsgSubstract<csgs>, CsgAnd<csga>, CsgXor<csgx>
TODO : cleanup useless code.
TODO : Some bugs are still present, some face that disappear should not.
TODO : Correct epsilon useage (see geometry files).
TODO : Coplanar face are not handled -at all-.
TODO : Vertex count goes through the roof in case of a Xor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tutorial/05_easymesh.cpp

    r2183 r2226  
    22// Lol Engine - EasyMesh tutorial
    33//
    4 // Copyright: (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2011-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2012-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    56//   This program is free software; you can redistribute it and/or
    67//   modify it under the terms of the Do What The Fuck You Want To
     
    2930        m_gears.Push(EasyMesh(), mat4(1.0f), 180.0f / 18);
    3031
    31         m_gears[0].m1.Compile("sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1");
     32        m_gears[0].m1.Compile("[sc#00f ab 8 1 8 ty -.25]\
     33                              [sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 ty -.1 csgu]\
     34                              [sc#fff scb#000 acg 12 10 10 10 20 20 5 5 0.1 0 s .05 .05 .05 tx -1.5 ty .3 csgu]\
     35                              [sc#00f ab 5 3 9 tx 2.5 csgs]\
     36                              [[ sc#fff ab 3   1.4 2   tx -2 tz -2 \
     37                               [sc#fff ab 2.1  .7 1.1 ty .5 tx -1.4 tz -1.4 csgs] mz] csgu] \
     38                              ");
     39        //m_gears[0].m1.Compile("[sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 [sc#00f ab 3 1 2 ty .25 tx 1 csgs]]");
    3240        m_gears[1].m1.Compile("sc#ff9 scb#ff9 acg 54 10 95 95 90 90 -5 -5 0.1 0 s .1 .1 .1");
    33         m_gears[2].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
    34         m_gears[3].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
    35         m_gears[4].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
     41        //m_gears[2].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     42        //m_gears[3].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     43        //m_gears[4].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     44        m_gears[2].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgu]]");
     45        m_gears[3].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgs]]");
     46        m_gears[4].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csga]]");
    3647
    3748        m_angle = 0;
     
    4051                              vec3(0.f, 0.f, 0.f),
    4152                              vec3(0, 1, 0));
    42         m_camera->SetPerspective(70.f, 960.f, 600.f, .1f, 1000.f);
     53        m_camera->SetPerspective(30.f, 960.f, 600.f, .1f, 1000.f);
    4354        m_camera->SetTarget(vec3(0.f, -1.f, 0.f));
    44         m_camera->SetPosition(vec3(-15.f, 10.f, 0.f));
     55        m_camera->SetPosition(vec3(-15.f, 5.f, 0.f));
    4556        Ticker::Ref(m_camera);
    4657
     
    5970        m_angle += seconds * 70.0f;
    6071        m_mat = mat4::rotate(10.0f, vec3(0, 0, 1))
    61               * mat4::rotate(m_angle, vec3(0, 1, 0));
     72                * mat4::rotate(100, vec3(0, 1, 0));
     73        //      * mat4::rotate(m_angle, vec3(0, 1, 0));
    6274
    63         m_gears[0].m3 += seconds * 150.0f;
    64         m_gears[1].m3 += seconds * 150.0f * -2 / 9;
    65         m_gears[2].m3 += seconds * 150.0f * -2 / 3;
    66         m_gears[3].m3 += seconds * 150.0f * -2 / 3;
    67         m_gears[4].m3 += seconds * 150.0f * -2 / 3;
     75        m_gears[0].m3 += seconds * 20.0f;
     76        m_gears[1].m3 += seconds * 20.0f * -2 / 9;
     77        m_gears[2].m3 += seconds * 20.0f * -2 / 3;
     78        m_gears[3].m3 += seconds * 20.0f * -2 / 3;
     79        m_gears[4].m3 += seconds * 20.0f * -2 / 3;
    6880
    69         m_gears[0].m2 = mat4::translate(vec3(0, 0, 0))
    70                       * mat4::rotate(m_gears[0].m3, vec3(0, 1, 0));
     81        m_gears[0].m2 = mat4::translate(vec3(0, -1, 0))
     82                      * mat4::rotate(m_gears[0].m3 - 130.0f, vec3(0, 1, 0))
     83                      * mat4::rotate(40.0f, vec3(0, 0, 1));
    7184        m_gears[1].m2 = mat4::translate(vec3(0, 0, 0))
    7285                      * mat4::rotate(m_gears[1].m3, vec3(0, 1, 0));
    7386        m_gears[2].m2 = mat4::translate(vec3(0, 0, 5.5f))
    74                       * mat4::rotate(m_gears[2].m3, vec3(0, 1, 0));
     87                      * mat4::rotate(m_gears[2].m3 - 40.0f, vec3(0, 1, 0))
     88                      * mat4::rotate(90.0f, vec3(0, 0, 1));
    7589        m_gears[3].m2 = mat4::translate(vec3(5.5f * lol::sqrt(3.f) * 0.5f, 0, -5.5f * 0.5f))
    76                       * mat4::rotate(m_gears[3].m3, vec3(0, 1, 0));
     90                      * mat4::rotate(m_gears[3].m3 - 140.0f, vec3(0, 1, 0))
     91                      * mat4::rotate(-70.0f, vec3(0, 0, 1));
    7792        m_gears[4].m2 = mat4::translate(vec3(-5.5f * lol::sqrt(3.f) * 0.5f, 0, -5.5f * 0.5f))
    78                       * mat4::rotate(m_gears[4].m3, vec3(0, 1, 0));
     93                      * mat4::rotate(m_gears[4].m3 - 80.0f, vec3(0, 1, 0));
    7994    }
    8095
Note: See TracChangeset for help on using the changeset viewer.