Panda3D
|
00001 00002 #include "meshNode.h" 00003 00004 Node::Node(int grid_x, int grid_y, LVecBase3f pos, float w, float l, float h) { 00005 for(int i = 0; i < 8; ++i) { 00006 _neighbours[i] = NULL; 00007 } 00008 00009 _position = pos; 00010 _width = w; 00011 _length = l; 00012 _height = h; 00013 _grid_x = grid_x; 00014 _grid_y = grid_y; 00015 _status = neutral; 00016 _type = true; 00017 _score = 0; 00018 _cost = 0; 00019 _heuristic = 0; 00020 _next = NULL; 00021 _prv_node = NULL; 00022 } 00023 00024 Node::~Node() { 00025 } 00026 00027 ///////////////////////////////////////////////////////////////////////////////////////// 00028 // 00029 // Function : contains 00030 // Description : This is a handy function which returns true if the passed position is 00031 // within the node's dimensions. 00032 00033 ///////////////////////////////////////////////////////////////////////////////////////// 00034 00035 bool Node::contains(float x, float y) { 00036 if(_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x && 00037 _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) { 00038 return true; 00039 } 00040 else { 00041 return false; 00042 } 00043 }