Subversion Repositories gelsvn

Rev

Rev 667 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 667 Rev 676
Line 7... Line 7...
7
//
7
//
8
 
8
 
9
#ifndef __GEL__MeshEditor__
9
#ifndef __GEL__MeshEditor__
10
#define __GEL__MeshEditor__
10
#define __GEL__MeshEditor__
11
 
11
 
-
 
12
#include <mutex>
12
#include <string>
13
#include <string>
13
#include "../GLGraphics/Console.h"
14
#include "../GLGraphics/Console.h"
14
#include "../GLGraphics/VisObj.h"
15
#include "../GLGraphics/VisObj.h"
15
#include "../GLGraphics/GLViewController.h"
16
#include "../GLGraphics/GLViewController.h"
16
 
17
 
-
 
18
 
17
namespace GLGraphics {
19
namespace GLGraphics {
-
 
20
    extern std::mutex parallel_work;
18
    
21
    
19
    class MeshEditor
22
    class MeshEditor
20
    {
23
    {
21
        bool console_visible;
24
        bool console_visible = false;
22
        
25
        
23
        bool dragging;
26
        bool dragging = false;
24
        int mouse_x, mouse_y;
27
        int mouse_x, mouse_y;
25
        float depth;
28
        float depth;
26
        HMesh::VertexAttributeVector<float> weight_vector;
29
        HMesh::VertexAttributeVector<float> weight_vector;
27
        HMesh::VertexAttributeVector<CGLA::Vec3d> orig_pos;
30
        HMesh::VertexAttributeVector<CGLA::Vec3d> orig_pos;
28
 
31
 
29
        static const int NO_MESHES = 9;
32
        static const int NO_MESHES = 9;
30
        std::array<VisObj,NO_MESHES> vo;
33
        std::array<VisObj,NO_MESHES> vo;
-
 
34
        
-
 
35
    public:
31
        VisObj& active_visobj() { return vo[active]; }
36
        VisObj& active_visobj() { return vo[active]; }
32
        const VisObj& active_visobj() const { return vo[active]; }
37
        const VisObj& active_visobj() const { return vo[active]; }
-
 
38
    private:
33
        GLViewController& active_view_control() {
39
        GLViewController& active_view_control() {
34
            return active_visobj().view_control();
40
            return active_visobj().view_control();
35
        }
41
        }
36
 
42
 
37
        Console theConsole;
43
        Console theConsole;
Line 40... Line 46...
40
        Console::variable<float> brush_size;
46
        Console::variable<float> brush_size;
41
        Console::variable<int> display_smooth_shading;
47
        Console::variable<int> display_smooth_shading;
42
        Console::variable<float> display_gamma;
48
        Console::variable<float> display_gamma;
43
 
49
 
44
    public:
50
    public:
45
        MeshEditor():active(0), console_visible(false), dragging(false),  display_render_mode("normal"), brush_size(0.01), display_smooth_shading(true),
51
        MeshEditor():active(0), display_render_mode("normal"), brush_size(0.01), display_smooth_shading(true),
46
        display_gamma(2.2) {}
52
        display_gamma(2.2) {}
47
 
53
 
48
        /// Initialize the mesh editor. Do this only when OpenGL state is available.
54
        /// Initialize the mesh editor. Do this only when OpenGL state is available.
49
        void init();
55
        void init();
50
        
56
        
Line 75... Line 81...
75
        void reshape(int w, int h);
81
        void reshape(int w, int h);
76
        void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
82
        void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
77
        void roll_ball(const CGLA::Vec2i& pos);
83
        void roll_ball(const CGLA::Vec2i& pos);
78
        void release_ball();
84
        void release_ball();
79
        bool try_spinning_ball();
85
        bool try_spinning_ball();
-
 
86
        void save_ball();
-
 
87
        void load_ball();
80
        
88
        
81
        /// Align means that we sync view controllers.
89
        /// Align means that we sync view controllers.
82
        void align(int src, int dst)
90
        void align(int src, int dst)
83
        {
91
        {
84
            vo[dst].view_control() =
92
            vo[dst].view_control() =
Line 121... Line 129...
121
        void key_home();
129
        void key_home();
122
        void key_end();
130
        void key_end();
123
 
131
 
124
        /// Returns a reference to active mesh.
132
        /// Returns a reference to active mesh.
125
        HMesh::Manifold& active_mesh() { return active_visobj().mesh(); }
133
        HMesh::Manifold& active_mesh() { return active_visobj().mesh(); }
-
 
134
 
126
        
135
        /// Returns a reference to mesh i
-
 
136
        HMesh::Manifold& get_mesh(int i) { return vo[i].mesh(); }
-
 
137
 
127
       /// Add a file to the next empty slot.
138
       /// Add a file to the next empty slot.
128
        bool add_file(const std::string& str);
139
        bool add_file(const std::string& str);
129
        
140
        
130
        /// Load the mesh given as argument to the current slot.
141
        /// Load the mesh given as argument to the current slot.
131
        bool reload_active_from_file(const std::string& str);
142
        bool reload_active_from_file(const std::string& str);
132
        
143
        
133
        /// Load the mesh but without clearing, effectively combining it with existing mesh.
144
        /// Load the mesh but without clearing, effectively combining it with existing mesh.
134
        bool add_to_active_from_file(const std::string& str);
145
        bool add_to_active_from_file(const std::string& str);
135
        
146
        
136
        void harmonics_analyze_mesh() {active_visobj().harmonics_analyze();}
147
        void harmonics_analyze_mesh() {active_visobj().harmonics_analyze();}
-
 
148
        void harmonics_reset_shape() {active_visobj().harmonics_reset_shape();}
-
 
149
        void harmonics_partial_reconstruct(int E0, int E1, float scale) {active_visobj().harmonics_partial_reconstruct(E0, E1, scale);}
137
 
150
 
138
    };
151
    };
139
}
152
}
140
 
153
 
141
#endif /* defined(__GEL__MeshEditor__) */
154
#endif /* defined(__GEL__MeshEditor__) */