Panda3D
|
00001 // Filename: aiNode.cxx 00002 // Created by: Deepak, John, Navin (19Nov2009) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "aiNode.h" 00016 00017 AINode::AINode(int grid_x, int grid_y, LVecBase3f pos, float w, float l, float h) { 00018 for (int i = 0; i < 8; ++i) { 00019 _neighbours[i] = NULL; 00020 } 00021 00022 _position = pos; 00023 _width = w; 00024 _length = l; 00025 _height = h; 00026 _grid_x = grid_x; 00027 _grid_y = grid_y; 00028 _status = ST_neutral; 00029 _type = true; 00030 _score = 0; 00031 _cost = 0; 00032 _heuristic = 0; 00033 _next = NULL; 00034 _prv_node = NULL; 00035 } 00036 00037 AINode::~AINode() { 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: contains 00042 // Description: This is a handy function which returns true if the 00043 // passed position is within the node's dimensions. 00044 //////////////////////////////////////////////////////////////////// 00045 bool AINode::contains(float x, float y) { 00046 if (_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x && 00047 _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) { 00048 return true; 00049 } 00050 else { 00051 return false; 00052 } 00053 }