Subversion Repositories gelsvn

Rev

Rev 650 | Rev 657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 650 Rev 656
Line 16... Line 16...
16
 
16
 
17
namespace GLGraphics {
17
namespace GLGraphics {
18
    
18
    
19
    class MeshEditor
19
    class MeshEditor
20
    {
20
    {
21
        Console theConsole;
-
 
22
        bool console_visible = false;
21
        bool console_visible = false;
-
 
22
        
-
 
23
        bool dragging = false;
-
 
24
        int mouse_x, mouse_y;
-
 
25
        float depth;
-
 
26
        HMesh::VertexAttributeVector<float> weight_vector;
-
 
27
        HMesh::VertexAttributeVector<CGLA::Vec3d> orig_pos;
-
 
28
 
23
        static const int NO_MESHES = 9;
29
        static const int NO_MESHES = 9;
24
        std::array<VisObj,NO_MESHES> vo;
30
        std::array<VisObj,NO_MESHES> vo;
25
        Console::variable<int> active;
-
 
26
        Console::variable<std::string> display_render_mode;
-
 
27
        Console::variable<int> display_smooth_shading;
-
 
28
        Console::variable<float> display_gamma;
-
 
29
 
-
 
30
        VisObj& active_visobj() { return vo[active]; }
31
        VisObj& active_visobj() { return vo[active]; }
31
        const VisObj& active_visobj() const { return vo[active]; }
32
        const VisObj& active_visobj() const { return vo[active]; }
32
        
-
 
33
        GLViewController& active_view_control() {
33
        GLViewController& active_view_control() {
34
            return active_visobj().view_control();
34
            return active_visobj().view_control();
35
        }
35
        }
36
 
36
 
-
 
37
        Console theConsole;
-
 
38
        Console::variable<int> active;
-
 
39
        Console::variable<std::string> display_render_mode;
-
 
40
        Console::variable<std::string> edit_mode;
-
 
41
        Console::variable<int> display_smooth_shading;
-
 
42
        Console::variable<float> display_gamma;
37
 
43
 
38
    public:
44
    public:
39
        MeshEditor():active(0), display_render_mode("normal"), display_smooth_shading(true),
45
        MeshEditor():active(0), display_render_mode("normal"), display_smooth_shading(true),
40
        display_gamma(2.2) {}
46
        display_gamma(2.2) {}
41
 
47
 
42
        /// Initialize the mesh editor. Do this only when OpenGL state is available.
48
        /// Initialize the mesh editor. Do this only when OpenGL state is available.
43
        void init();
49
        void init();
-
 
50
        
-
 
51
        
-
 
52
        /** Tests whether the position passed as argument is on the mesh (return true) 
-
 
53
         or background (false). This function also retains the 3D unprojection of the 
-
 
54
         grabbed position. */
-
 
55
        bool grab_mesh(const CGLA::Vec2i& pos);
-
 
56
        
-
 
57
        /** Provided grab_mesh has been called and returned true, drag_mesh computes a 
-
 
58
         vector to the new position given as argument and moves a small subset of the mesh
-
 
59
         according to the vector from grabbed to dragged position. */
-
 
60
        bool drag_mesh(const CGLA::Vec2i& pos);
-
 
61
        
-
 
62
        /** Releases the mesh. We are no longer dragging. */
-
 
63
        void release_mesh();
-
 
64
        
-
 
65
        
44
 
66
 
45
        // GLViewController stuff
67
        // GLViewController stuff
46
        void reshape(int w, int h);
68
        void reshape(int w, int h);
47
        void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
69
        void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
48
        void roll_ball(const CGLA::Vec2i& pos);
70
        void roll_ball(const CGLA::Vec2i& pos);