2 using namespace Psychlops;
6 Point toGround(Point p, double high) {
9 r.x = p.x / ((high-p.z)/high);
10 r.y = p.y / ((high-p.z)/high);
14 void psychlops_main() {
15 Canvas cnv(Canvas::window);
16 Psychlops::Point p[4];
17 p[0]= toGround(Psychlops::Point(60, 60, 60), 120);
18 p[1]= toGround(Psychlops::Point(-60, 60, 60), 120);
19 p[2]= toGround(Psychlops::Point(-60, 60, 0), 120);
20 p[3]= toGround(Psychlops::Point(60, 60, 0), 120);
21 for(int i=0; i<4; i++) { p[i].x+=100; }
22 Image img("monalisa1.png");
25 cnv.drawImage(img, p[0], p[1], p[2], p[3]);
27 while(!Keyboard::esc.pushed()) {
33 namespace VirtualReality {
37 enum { AMBIENT, DIRECTIONAL };
38 enum Material { DIFFUSE, SPECULAR };
39 Point position, direction;
40 void lookAt(Point target);
41 void locateToLook(Psychlops::Point pos, Point target);
42 void apply(Drawable3D &target = *Drawable3D::prime);
47 double top, bottom, left, right, near, far;
48 // Point datum, direction;
58 void set(Point position, Point target, double top_direction) {
60 void lookAt(Point target, double top_direction) {
62 void draw(Canvas &target = *Canvas::prime);
67 void Camera::draw(Canvas &target) {
69 target.RenderModeSmooth3D(left, right, top, bottom, near, far);
70 contents.draw(target);
72 target.pushPixToPixProjection();
79 void psychlops_main() {
80 Canvas cnvs(Canvas::window);
84 Widgets::Button but(L"ใในใ");
85 but.centering().shift(100,100);
86 Widgets::Dial dial(40);
88 dial.centering().shift(-100,0);
90 Image gabor(200,200, Image::RGBA);
91 for(int iy=0; iy<200; iy++) {
92 for(int ix=0; ix<200; ix++) {
93 gabor.pix(ix,iy,Color(.5+.5*sin(ix/10.0)));
94 gabor.alpha(ix,iy, exp( -((ix-100)*(ix-100)+(iy-100)*(iy-100)) /2.0 / (30*30) ) );
100 VirtualReality::Camera cam;
102 cam.contents.axis.set(1,1,0);
103 cam.contents.scaling.set(.5,.5,.5);
104 cam.contents.centering(0,0,0).shift(0,0,100);
106 sl1(cam.contents.scaling.x, 0<=rng<=100, 1.0, 10.0),
107 sl2(cam.contents.scaling.y, 0<=rng<=100, 1.0, 10.0),
108 sl3(cam.contents.scaling.z, 0<=rng<=100, 1.0, 10.0);
113 sl11(cam.left, -1000<=rng<=1000, 1.0, 10.0),
114 sl12(cam.right, -1000<=rng<=1000, 1.0, 10.0),
115 sl13(cam.top, -1000<=rng<=1000, 1.0, 10.0),
116 sl14(cam.bottom, -1000<=rng<=1000, 1.0, 10.0),
117 sl15(cam.near, -1000<=rng<=1000, 1.0, 10.0),
118 sl16(cam.far, -1000<=rng<=1000, 1.0, 10.0);
126 for(int i=0; i<6; i++) {
128 cam.contents.append(h[i]);
131 h[1].shift(0,0,-100);
133 h[2].axis.set(1,0,0);
135 h[3].shift(0,-100,0);
136 h[3].axis.set(1,0,0);
139 h[4].axis.set(0,1,0);
141 h[5].shift(-100,0,0);
142 h[5].axis.set(0,1,0);
145 while(!Keyboard::esc.pushed()) {
146 cnvs.clear( but.pushed() ? Color::red : Color::gray );
156 cnvs.var(x, 200, 100);
157 cnvs.var(y, 200, 130);
158 cam.contents.rotation = y;