#ifndef OPENMW_COMPONENTS_NIFOSG_LOADER #define OPENMW_COMPONENTS_NIFOSG_LOADER #include #include // NIFFilePtr #include #include "controller.hpp" namespace osg { class Geometry; } namespace osgAnimation { class Bone; } namespace Nif { class Node; class NiTriShape; class Property; } namespace Bsa { class BSAFile; } namespace NifOsg { /// The main class responsible for loading NIF files into an OSG-Scenegraph. class Loader { public: /// @param node The parent of the root node for the created NIF file. void load(Nif::NIFFilePtr file, osg::Group* parentNode); void loadAsSkeleton(Nif::NIFFilePtr file, osg::Group* parentNode); // FIXME replace with resource system Bsa::BSAFile* resourceManager; // FIXME move std::vector mControllers; private: /// @param createSkeleton If true, use an osgAnimation::Bone for NIF nodes, otherwise an osg::MatrixTransform. void handleNode(const Nif::Node* nifNode, osg::Group* parentNode, bool createSkeleton, std::map boundTextures); void handleMeshControllers(const Nif::Node* nifNode, osg::MatrixTransform* transformNode, const std::map& boundTextures); void handleNodeControllers(const Nif::Node* nifNode, osg::MatrixTransform* transformNode); void handleProperty (const Nif::Property* property, const Nif::Node* nifNode, osg::Node* node, std::map& boundTextures); // Creates an osg::Geometry object for the given TriShape, populates it, and attaches it to the given node. void handleTriShape(const Nif::NiTriShape* triShape, osg::Group* parentNode, const std::map& boundTextures); // Fills the vertex data for the given TriShape into the given Geometry. void triShapeToGeometry(const Nif::NiTriShape* triShape, osg::Geometry* geom, const std::map& boundTextures); // Creates a skinned osg::Geometry object for the given TriShape, populates it, and attaches it to the given node. void handleSkinnedTriShape(const Nif::NiTriShape* triShape, osg::Group* parentNode, const std::map& boundTextures); // Applies the Properties of the given nifNode onto the StateSet of the given OSG node. void applyNodeProperties(const Nif::Node* nifNode, osg::Node* applyTo, std::map& boundTextures); void createController(const Nif::Controller* ctrl, boost::shared_ptr value, int animflags); Nif::NIFFilePtr mNif; osg::Group* mRootNode; osg::Group* mSkeleton; }; } #endif