2011-01-14 07:36:50 -08:00
|
|
|
// Copyright (C) 2002-2011 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_TRIANGLE_SELECTOR_H_INCLUDED__
|
|
|
|
#define __C_TRIANGLE_SELECTOR_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "ITriangleSelector.h"
|
|
|
|
#include "IMesh.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
class ISceneNode;
|
2009-05-04 17:09:53 -07:00
|
|
|
class IAnimatedMeshSceneNode;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Stupid triangle selector without optimization
|
|
|
|
class CTriangleSelector : public ITriangleSelector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Constructs a selector based on a mesh
|
2011-01-14 07:36:50 -08:00
|
|
|
CTriangleSelector(ISceneNode* node);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Constructs a selector based on a mesh
|
2011-01-14 07:36:50 -08:00
|
|
|
CTriangleSelector(const IMesh* mesh, ISceneNode* node);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2009-05-04 17:09:53 -07:00
|
|
|
//! Constructs a selector based on an animated mesh scene node
|
|
|
|
//!\param node An animated mesh scene node, which must have a valid mesh
|
|
|
|
CTriangleSelector(IAnimatedMeshSceneNode* node);
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Constructs a selector based on a bounding box
|
2011-01-14 07:36:50 -08:00
|
|
|
CTriangleSelector(const core::aabbox3d<f32>& box, ISceneNode* node);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Gets all triangles.
|
2011-01-14 07:36:50 -08:00
|
|
|
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
2007-09-17 09:09:50 -07:00
|
|
|
const core::matrix4* transform=0) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Gets all triangles which lie within a specific bounding box.
|
2011-01-14 07:36:50 -08:00
|
|
|
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
2007-09-17 09:09:50 -07:00
|
|
|
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Gets all triangles which have or may have contact with a 3d line.
|
|
|
|
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
2011-01-14 07:36:50 -08:00
|
|
|
s32& outTriangleCount, const core::line3d<f32>& line,
|
2007-09-17 09:09:50 -07:00
|
|
|
const core::matrix4* transform=0) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Returns amount of all available triangles in this selector
|
|
|
|
virtual s32 getTriangleCount() const;
|
|
|
|
|
2009-01-27 05:23:36 -08:00
|
|
|
//! Return the scene node associated with a given triangle.
|
2011-01-14 07:36:50 -08:00
|
|
|
virtual ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const { return SceneNode; }
|
2009-01-27 05:23:36 -08:00
|
|
|
|
2011-05-18 15:21:50 -07:00
|
|
|
// Get the number of TriangleSelectors that are part of this one
|
|
|
|
virtual u32 getSelectorCount() const;
|
|
|
|
|
|
|
|
// Get the TriangleSelector based on index based on getSelectorCount
|
|
|
|
virtual ITriangleSelector* getSelector(u32 index);
|
|
|
|
|
|
|
|
// Get the TriangleSelector based on index based on getSelectorCount
|
|
|
|
virtual const ITriangleSelector* getSelector(u32 index) const;
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
protected:
|
2009-05-04 17:09:53 -07:00
|
|
|
//! Create from a mesh
|
2011-01-14 07:36:50 -08:00
|
|
|
virtual void createFromMesh(const IMesh* mesh);
|
2009-05-04 17:09:53 -07:00
|
|
|
|
|
|
|
//! Update when the mesh has changed
|
2011-01-14 07:36:50 -08:00
|
|
|
virtual void updateFromMesh(const IMesh* mesh) const;
|
2009-05-04 17:09:53 -07:00
|
|
|
|
|
|
|
//! Update the triangle selector, which will only have an effect if it
|
2011-01-14 07:36:50 -08:00
|
|
|
//! was built from an animated mesh and that mesh's frame has changed
|
2009-05-04 17:09:53 -07:00
|
|
|
//! since the last time it was updated.
|
|
|
|
virtual void update(void) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2011-01-14 07:36:50 -08:00
|
|
|
ISceneNode* SceneNode;
|
|
|
|
mutable core::array<core::triangle3df> Triangles; // (mutable for CTriangleBBSelector)
|
2009-05-04 17:09:53 -07:00
|
|
|
|
|
|
|
IAnimatedMeshSceneNode* AnimatedNode;
|
|
|
|
mutable s32 LastMeshFrame;
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|