summaryrefslogtreecommitdiffhomepage
path: root/pose-widget/glwidget.h
blob: 66d4289d3f55de3d6acb5f82110c896c2d61b008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright (c) 2013, 2015 Stanislaw Halik <sthalik@misaki.pl>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#pragma once

#include <QtGlobal>
#include <QWidget>
#include <QPixmap>
#include "api/plugin-api.hpp"
#include "compat/euler.hpp"

#ifdef BUILD_POSE_WIDGET
#   define POSE_WIDGET_EXPORT Q_DECL_EXPORT
#else
#   define POSE_WIDGET_EXPORT Q_DECL_IMPORT
#endif

namespace pose_widget_impl {

using num = float;
using vec3 = Mat<num, 3, 1>;
using vec2 = Mat<num, 2, 1>;

using namespace euler;

class POSE_WIDGET_EXPORT GLWidget : public QWidget
{
public:
    using rmat = Mat<num, 3, 3>;

    GLWidget(QWidget *parent);
    ~GLWidget();
    void rotateBy(double xAngle, double yAngle, double zAngle, double x, double y, double z);
protected:
    void paintEvent(QPaintEvent *event) override;
private:
    vec2 project(const vec3& point);
    vec3 project2(const vec3& point);
    void project_quad_texture();
    static vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3);

    rmat rotation;
    vec3 translation;
    QImage front;
    QImage back;
    QImage image;
};

}

using pose_widget_impl::GLWidget;