56 #include "GridNode.hh" 76 minRefinementDistance_(10),
79 orientation_(XZ_PLANE)
82 midLineColor_ =
Vec3f(0.3f, 0.3f, 0.3f);
136 glPushAttrib( GL_LIGHTING_BIT );
139 glPushAttrib( GL_DEPTH_TEST );
147 for (
unsigned int i = 0 ; i < 3 ; ++i ) {
149 Vec3d viewDirection(0.0, 1.0, 0.0);
156 double distance = 0.0;
161 distance = fabs( eye |
ACG::Vec3d(0.0,1.0,0.0 ) );
165 distance = fabs( eye |
ACG::Vec3d(0.0,0.0,1.0 ) );
169 distance = fabs( eye |
ACG::Vec3d(1.0,0.0,0.0 ) );
183 int vertical = verticalLines_;
187 vertical = maxRefinement_;
188 horizontal = maxRefinement_;
190 }
else if (factor > 0){
194 for (
int i=0; i < factor; i++)
195 rest -= floor( pow(
double(2.0), i));
197 vertical = vertical * floor( pow(
double(2.0),factor)) + rest;
198 horizontal = horizontal * floor( pow(
double(2.0),factor)) + rest;
200 vertical = std::min(vertical, maxRefinement_ );
201 horizontal = std::min(vertical, maxRefinement_ );
246 glColor3f( 0.7f, 0.0f, 0.0f );
248 glVertex( direction1 * gridSize_ + direction2 * gridSize_ * 0.5 );
251 glColor3f( 0.0f, 0.0f, 0.7f );
252 glVertex( direction1 * gridSize_ * 0.5 );
253 glVertex( direction1 * 0.5 * gridSize_ + direction2 * gridSize_);
256 for (
int i = 0 ; i < vertical ; ++i ) {
261 double big = gridSize_ / (vertical-1) * i;
262 double next = gridSize_ / (vertical-1) * (i+1);
265 glVertex( direction1 * big + direction2 * gridSize_ );
268 for (
int j=1; j < 10; j++){
271 glColor3fv( &midLineColor_[0] );
273 double smallPos = big + (next - big) / 10.0 * j;
275 glVertex( direction1 * smallPos + direction2 * gridSize_);
280 for (
int i = 0 ; i < horizontal; ++i ) {
285 double big = gridSize_ / (vertical-1) * i;
286 double next = gridSize_ / (vertical-1) * (i+1);
288 glVertex( direction2 * gridSize_ / (horizontal-1) * i);
289 glVertex( direction1 * gridSize_ + direction2 * gridSize_ / (horizontal-1) * i);
292 for (
int j=1; j < 10; j++){
295 glColor3fv( &midLineColor_[0] );
297 double smallPos = big + (next - big) / 10.0 * j;
299 glVertex( direction1 * gridSize_ + direction2 * smallPos );
355 void GridNode::autoResize(
bool _auto)
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
DrawMode WIREFRAME
draw wireframe
Namespace providing different geometric functions concerning angles.
void setOrientation(unsigned int _orientation)
Set the plane orientation.
unsigned int orientation_
Contains all orientations to draw.
void push_modelview_matrix()
push modelview matrix
VectorT< float, 3 > Vec3f
void pick(GLState &_state, PickTarget _target)
don't pick me
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
Vec3d bb_min_
bounding box
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
int horizontalLines_
initial number of baseLines
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
drawing the primitive
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const
return available draw modes
float gridSize()
Get GridSize.
double minRefinementDistance()
returns the minimal refinement distance
Vec3d eye() const
get eye point
const GLMatrixd & modelview() const
get modelview matrix
PickTarget
What target to use for picking.
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
void pop_modelview_matrix()
pop modelview matrix
Vec3f baseLineColor_
colors for the grid
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
GridNode(BaseNode *_parent=0, const std::string &_name="<GridNode>")
Default constructor.
float gridSize_
dimensions of the grid
double minRefinementDistance_