arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

GLClipPlane.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Mark Hartner
00004 //     9-18-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 // GLClipPlane.cpp
00019 
00020 #include "GLClipPlane.h"
00021 #include <iostream>
00022 #include <GL/glew.h>
00023 
00024 using namespace std; //<iostream>
00025 using namespace gutz;
00026 
00027 GLClipPlane::GLClipPlane()
00028 {
00029 }
00030 
00031 GLClipPlane::GLClipPlane(gutz::planef p)
00032 {
00033   GLdouble eqn[4] = {p.n.x, p.n.y, p.n.z, -p.n.dot(p.p)};
00034   cout<<"Orig clip eqn is "<<p.n.x<<" "<<p.n.y<<" "<<p.n.z<<" "<<-p.n.dot(p.p)<<endl;
00035   glClipPlane(GL_CLIP_PLANE5,eqn);
00036 }
00037 
00038 GLClipPlane::GLClipPlane(FrameWidget *fw)
00039 {
00040   gutz::planef p = fw->getPlane();
00041   GLdouble eqn[4] = {p.n.x, p.n.y, p.n.z, -p.n.dot(p.p)};
00042   cout<<"Orig clip eqn is "<<p.n.x<<" "<<p.n.y<<" "<<p.n.z<<" "<<-p.n.dot(p.p)<<endl;
00043   glClipPlane(GL_CLIP_PLANE5,eqn);
00044   //gutz::connect(fw->planeChanged, &someClipObj, &GLClipPlane::updateClipPlane);
00045   gutz::connect(fw->planeChanged, this, &GLClipPlane::updateClipPlane);
00046 }
00047 
00048 GLClipPlane::~GLClipPlane()
00049 {
00050 }
00051 
00052 //connect this function to FrameWidget::planeChanged()
00053 //in your main function
00054 // gutz::connect(someFrame.planeChanged, &someClipObj, &GLClipPlane::updateClipPlane)
00055 void GLClipPlane::updateClipPlane(gutz::planef p)
00056 {
00057   cout<<"Hey, we need to update our clipping plane"<<endl;
00058 
00059   // convert eqn to plane equation
00060   cout<<"New clip eqn is "<<p.n.x<<" "<<p.n.y<<" "<<p.n.z<<" "<<-p.n.dot(p.p)<<endl;
00061   //GLdouble eqn[4] = {0.0, 0.0, 1.0, 0.0};
00062   
00063 
00064   // -P dot N = D
00065   // (A B C) = N
00066   // N = plane.n p=plane.p
00067 
00068   //vec3f abc = p.n;
00069   //float d = -abc.dot(p.p);
00070 
00071   GLdouble eqn[4] = {p.n.x, p.n.y, p.n.z, -p.n.dot(p.p)};
00072   
00073   glClipPlane(GL_CLIP_PLANE5,eqn);
00074   
00075 }

Send questions, comments, and bug reports to:
jmk