62 #include "GridNode.hh"
70 namespace SceneGraph {
82 minRefinementDistance_(10),
85 orientation_(XZ_PLANE)
88 midLineColor_ =
Vec3f(0.3f, 0.3f, 0.3f);
120 _bbMax.maximize(bb_max_);
142 glPushAttrib( GL_LIGHTING_BIT );
145 glPushAttrib( GL_DEPTH_TEST );
153 for (
unsigned int i = 0 ; i < 3 ; ++i ) {
155 Vec3d viewDirection(0.0, 1.0, 0.0);
162 double distance = 0.0;
167 distance = fabs( eye |
ACG::Vec3d(0.0,1.0,0.0 ) );
171 distance = fabs( eye |
ACG::Vec3d(0.0,0.0,1.0 ) );
175 distance = fabs( eye |
ACG::Vec3d(1.0,0.0,0.0 ) );
189 int vertical = verticalLines_;
193 vertical = maxRefinement_;
194 horizontal = maxRefinement_;
196 }
else if (factor > 0){
200 for (
int i=0; i < factor; i++)
201 rest -= floor( pow(
double(2.0), i));
203 vertical = vertical * floor( pow(
double(2.0),factor)) + rest;
204 horizontal = horizontal * floor( pow(
double(2.0),factor)) + rest;
206 vertical = std::min(vertical, maxRefinement_ );
207 horizontal = std::min(vertical, maxRefinement_ );
252 glColor3f( 0.7f, 0.0f, 0.0f );
254 glVertex( direction1 * gridSize_ + direction2 * gridSize_ * 0.5 );
257 glColor3f( 0.0f, 0.0f, 0.7f );
258 glVertex( direction1 * gridSize_ * 0.5 );
259 glVertex( direction1 * 0.5 * gridSize_ + direction2 * gridSize_);
262 for (
int i = 0 ; i < vertical ; ++i ) {
267 double big = gridSize_ / (vertical-1) * i;
268 double next = gridSize_ / (vertical-1) * (i+1);
271 glVertex( direction1 * big + direction2 * gridSize_ );
274 for (
int j=1; j < 10; j++){
277 glColor3fv( &midLineColor_[0] );
279 double smallPos = big + (next - big) / 10.0 * j;
281 glVertex( direction1 * smallPos + direction2 * gridSize_);
286 for (
int i = 0 ; i < horizontal; ++i ) {
291 double big = gridSize_ / (vertical-1) * i;
292 double next = gridSize_ / (vertical-1) * (i+1);
294 glVertex( direction2 * gridSize_ / (horizontal-1) * i);
295 glVertex( direction1 * gridSize_ + direction2 * gridSize_ / (horizontal-1) * i);
298 for (
int j=1; j < 10; j++){
301 glColor3fv( &midLineColor_[0] );
303 double smallPos = big + (next - big) / 10.0 * j;
305 glVertex( direction1 * gridSize_ + direction2 * smallPos );
361 void GridNode::autoResize(
bool _auto)
double minRefinementDistance_
Namespace providing different geometric functions concerning angles.
static void enable(GLenum _cap)
replaces glEnable, but supports locking
GridNode(BaseNode *_parent=0, const std::string &_name="<GridNode>")
Default constructor.
PickTarget
What target to use for picking.
static void disable(GLenum _cap)
replaces glDisable, but supports locking
unsigned int orientation_
Contains all orientations to draw.
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
void setOrientation(unsigned int _orientation)
Set the plane orientation.
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
Vec3d bb_min_
bounding box
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
const GLMatrixd & modelview() const
get modelview matrix
int horizontalLines_
initial number of baseLines
void push_modelview_matrix()
push modelview matrix
VectorT< float, 3 > Vec3f
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
drawing the primitive
void pop_modelview_matrix()
pop modelview matrix
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const
return available draw modes
DrawMode WIREFRAME
draw wireframe
float gridSize_
dimensions of the grid
double minRefinementDistance()
returns the minimal refinement distance
float gridSize()
Get GridSize.
Vec3d eye() const
get eye point
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
void pick(GLState &_state, PickTarget _target)
don't pick me
Vec3f baseLineColor_
colors for the grid