These can be found in the examples directory, they replace your main.cc file.
// See main.orig.cc
{
double thetax = 1.2;
double thetay = 1.2;
double thetaz = 1.2;
/ make cube model instance, width = 3 /
ray3d::CubeModel cm(dpyb.get_display(),&w,&gc,3);
/ make a matrix (e.g. for rotating) engine /
ray3d::Engine engine(thetax,0,0,0.9,100,10,1.2);
/ fill it up with a color (given to draw_offset) /
cm.fill(dpyb.get_display(), &w,200,200);
/ start a window event loop (also processes X11 events) /
XEvent e;
for (;;) {
/ rotate cube with angles /
cm.rotate(engine, thetax, thetay, thetaz);
/ draw it at x == 200 , y == 200 pixels in the orange red color /
cm.draw_offset(dpyb.get_display(), &w,200,200,200,const_cast<char*>("orange red"));
/ translate to z == -60 /
cm.translate(engine, 0, 0, -60);
/ process window management e.g. moving via the titlebar /
xmantaray.eventloop(xmantaray,&e);
/ update rotating angles /
thetax += 0.1;
thetay += 0.1;
thetaz += 0.1;
}
}
// See main.planegrid.cc
{
double thetax = 1.2;
double thetay = 1.2;
double thetaz = 1.2;
/ make planegrid model /
ray3d::game::PlaneGrid planegrid(dpyb.get_display(),&w,100,100);
/ make a matrix (e.g. for rotating) engine /
ray3d::Engine engine(thetax,0,0,0.9,100,10,1.2);
/ give the plane a depth perspective, 2 far points and 2 near points /
planegrid.depth_f(0.55,0.55);
/ put the planegrid further away in the 3D world /
planegrid.perspective(-20,20,PI/180*270);
/ start a window event loop (also processes X11 events) /
XEvent e;
for (;;) {
/ rotate cube with angles /
planegrid.rotate(engine, thetax, thetay, thetaz);
/ draw it /
planegrid.draw(dpyb.get_display(),&w, 100,100);
/ process window management e.g. moving via the titlebar /
xmantaray.eventloop(xmantaray,&e);
/ update rotating angles in radians /
thetax += 0.1;
thetay += 0.1;
thetaz += 0.1;
}
}
//See main.cc in top directory.
ray3d::game::PlaneGrid planegrid(dpyb.get_display(),&w,100,100);
planegrid.depth_f(0.55,0.55);
double perspectiveangle = PI/180*90;
planegrid.perspective(-2,2,perspectiveangle);
planegrid.map(&dpy,&w,"./pics/texturetest1.xpm",600,375);
double thetax = 0.2;
double thetay = 0.2;
double thetaz = 0.2;
ray3d::Engine engine(thetax,0,0,0.9,100,10,1.2);
const char *colorname = "chartreuse";
XEvent e;
for (int k = 0; k < 100000; k++) {
/* blank screen */
XFillRectangle(dpy, titlebarw, gc,0,0,800,20);
XFillRectangle(dpy, w, gc,0,0,800,600);
/* draw 3d world */
planegrid.draw(dpyb.get_display(),&w, 100,100);
planegrid.perspective(-2,2,perspectiveangle);
planegrid.map(&dpy,&w,"./pics/texturetest1.xpm",600,375);
//planegrid.rotate(engine, thetax, thetay, thetaz);
xmantaray.eventloop(xmantaray,&e);
/* update movement of world */
perspectiveangle += 0.1;
thetax += 0.01;
thetay += 0.01;
thetaz += 0.01;
struct timespec ts;
ts.tv_sec = 0; /* seconds */
ts.tv_nsec = 500000000; /* nanoseconds */
nanosleep(&ts,NULL);
XFlush(dpy);
}
}
/*
Copyright (C) Johan Ceuppens 2011-2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/