-
Notifications
You must be signed in to change notification settings - Fork 0
/
vxMouseRay_UT.cpp
60 lines (50 loc) · 1.27 KB
/
vxMouseRay_UT.cpp
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
56
57
58
59
60
/**
*
* file vxMouseRay_UT.cpp
*
* This test file is a part of VoxelBrain software.
*
* (c) Nanyang Technological University
*
* Author: Konstantin Levinski
*
*/
#include <gtest/gtest.h>
#include "vxScene.h"
#include "vxMouseRay.h"
#include "vxDrawSphere.h"
#include "vxOpenGlTools.h"
struct InflateAction: Action {
int radius;
InflateAction(): radius(10){};
void Do(){ radius += (motion.dx+motion.dy); radius %=100; if(radius < 10) radius=10;};
};
/*
MouseRay() is used as:
*/
struct PointerAction: Action {
PointerAction(InflateAction & in){p_inflater = & in;};
InflateAction * p_inflater;
V3f cursor;
void Do()
{
Intersection hit_position;
IntersectRaySphere(MouseRay(), V3f(0,0,0), p_inflater->radius, hit_position);
if(hit_position.hit) cursor = MouseRay().Travel(hit_position.distance);
};
};
TEST(MAIN, MouseRay){
struct SphereThing: public Drawable{
InflateAction inflater;
PointerAction pointer;
SphereThing():pointer(inflater){};
void Draw(){
DrawSphere( V3f( 0, 0, 0), inflater.radius, 8).Draw();
DrawSphere( pointer.cursor, 10, 8).Draw();
};
} scene;
Scene::bind(GLFW_KEY_RSHIFT, & scene.inflater);
Scene::bind(GLFW_KEY_RCTRL, & scene.pointer);
Scene::run(scene);
};
//End of vxMouseRay_UT.cpp