3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef UTIL_POINTEDTHING_HEADER
21 #define UTIL_POINTEDTHING_HEADER
23 #include "../irrlichttypes.h"
24 #include "../irr_v3d.h"
35 //! An active object or node which is selected by a ray on the map.
38 //! The type of the pointed object.
39 PointedThingType type;
41 * Only valid if type is POINTEDTHING_NODE.
42 * The coordinates of the node which owns the
43 * nodebox that the ray hits first.
44 * This may differ from node_real_undersurface if
45 * a nodebox exceeds the limits of its node.
47 v3s16 node_undersurface;
49 * Only valid if type is POINTEDTHING_NODE.
50 * The coordinates of the last node the ray intersects
51 * before node_undersurface. Same as node_undersurface
52 * if the ray starts in a nodebox.
54 v3s16 node_abovesurface;
56 * Only valid if type is POINTEDTHING_NODE.
57 * The coordinates of the node which contains the
58 * point of the collision and the nodebox of the node.
60 v3s16 node_real_undersurface;
62 * Only valid if type isn't POINTEDTHING_NONE.
63 * First intersection point of the ray and the nodebox.
65 v3f intersection_point;
67 * Only valid if type isn't POINTEDTHING_NONE.
68 * Normal vector of the intersection.
69 * This is perpendicular to the face the ray hits,
70 * points outside of the box and it's length is 1.
72 v3s16 intersection_normal;
74 * Only valid if type is POINTEDTHING_OBJECT.
75 * The ID of the object the ray hit.
80 std::string dump() const;
81 void serialize(std::ostream &os) const;
82 void deSerialize(std::istream &is);
84 * This function ignores the intersection point and normal.
86 bool operator==(const PointedThing &pt2) const;
87 bool operator!=(const PointedThing &pt2) const;