56 #include "GridNode.hh" 76 minRefinementDistance_(10),
78 baseLineColor_(
Vec3f(0.5f, 0.5f, 0.5f) ),
79 midLineColor_(
Vec3f(0.3f, 0.3f, 0.3f) ),
81 orientation_(XZ_PLANE)
137 glPushAttrib( GL_LIGHTING_BIT );
140 glPushAttrib( GL_DEPTH_TEST );
148 for (
unsigned int i = 0 ; i < 3 ; ++i ) {
150 Vec3d viewDirection(0.0, 1.0, 0.0);
157 double distance = 0.0;
162 distance = fabs( eye |
ACG::Vec3d(0.0,1.0,0.0 ) );
166 distance = fabs( eye |
ACG::Vec3d(0.0,0.0,1.0 ) );
170 distance = fabs( eye |
ACG::Vec3d(1.0,0.0,0.0 ) );
184 int vertical = verticalLines_;
188 vertical = maxRefinement_;
189 horizontal = maxRefinement_;
191 }
else if (factor > 0){
195 for (
int j=0; j < factor; j++)
196 rest -= floor( pow(
double(2.0), j));
198 vertical = vertical * floor( pow(
double(2.0),factor)) + rest;
199 horizontal = horizontal * floor( pow(
double(2.0),factor)) + rest;
201 vertical = std::min(vertical, maxRefinement_ );
202 horizontal = std::min(vertical, maxRefinement_ );
247 glColor3f( 0.7f, 0.0f, 0.0f );
249 glVertex( direction1 * gridSize_ + direction2 * gridSize_ * 0.5 );
252 glColor3f( 0.0f, 0.0f, 0.7f );
253 glVertex( direction1 * gridSize_ * 0.5 );
254 glVertex( direction1 * 0.5 * gridSize_ + direction2 * gridSize_);
257 for (
int j = 0 ; j < vertical ; ++j ) {
262 double big = gridSize_ / (vertical-1) * j;
263 double next = gridSize_ / (vertical-1) * (j+1);
266 glVertex( direction1 * big + direction2 * gridSize_ );
269 for (
int k=1; k < 10; k++){
272 glColor3fv( &midLineColor_[0] );
274 double smallPos = big + (next - big) / 10.0 * k;
276 glVertex( direction1 * smallPos + direction2 * gridSize_);
281 for (
int j = 0 ; j < horizontal; ++j ) {
286 double big = gridSize_ / (vertical-1) * j;
287 double next = gridSize_ / (vertical-1) * (j+1);
289 glVertex( direction2 * gridSize_ / (horizontal-1) * j);
290 glVertex( direction1 * gridSize_ + direction2 * gridSize_ / (horizontal-1) * j);
293 for (
int k=1; k < 10; k++){
296 glColor3fv( &midLineColor_[0] );
298 double smallPos = big + (next - big) / 10.0 * k;
300 glVertex( direction1 * gridSize_ + direction2 * smallPos );
356 void GridNode::autoResize(
bool _auto)
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
double minRefinementDistance()
returns the minimal refinement distance
double minRefinementDistance_
Vec3f baseLineColor_
colors for the grid
GridNode(BaseNode *_parent=0, const std::string &_name="<GridNode>")
Default constructor.
void pop_modelview_matrix()
pop modelview matrix
Namespace providing different geometric functions concerning angles.
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
drawing the primitive
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const override
return available draw modes
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Vec3d bb_min_
bounding box
PickTarget
What target to use for picking.
void pick(GLState &_state, PickTarget _target) override
don't pick me
void push_modelview_matrix()
push modelview matrix
void setOrientation(unsigned int _orientation)
Set the plane orientation.
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
VectorT< float, 3 > Vec3f
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
unsigned int orientation_
Contains all orientations to draw.
DrawMode WIREFRAME
draw wireframe
float gridSize()
Get GridSize.
const GLMatrixd & modelview() const
get modelview matrix
int horizontalLines_
initial number of baseLines
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
float gridSize_
dimensions of the grid
Vec3d eye() const
get eye point
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)