Load NiTriStrips/NiTriStripsData (don't do anything yet)

pull/541/head
capostrophic 5 years ago
parent e524771b40
commit 8efbdeaa57

@ -90,6 +90,25 @@ void NiTriShapeData::read(NIFStream *nif)
}
}
void NiTriStripsData::read(NIFStream *nif)
{
ShapeData::read(nif);
// Every strip with n points defines n-2 triangles, so this should be unnecessary.
/*int tris =*/ nif->getUShort();
// Number of triangle strips
int numStrips = nif->getUShort();
// Number of points in each strip
int lengths = nif->getUShort();
for (int i = 0; i < numStrips; i++)
{
std::vector<unsigned short> strip;
nif->getUShorts(strip, lengths);
strips.emplace_back(strip);
}
}
void NiAutoNormalParticlesData::read(NIFStream *nif)
{
ShapeData::read(nif);

@ -53,6 +53,15 @@ public:
void read(NIFStream *nif);
};
class NiTriStripsData : public ShapeData
{
public:
// Triangle strips, series of vertex indices.
std::vector<std::vector<unsigned short>> strips;
void read(NIFStream *nif);
};
class NiAutoNormalParticlesData : public ShapeData
{
public:

@ -54,6 +54,7 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
newFactory.insert(makeEntry("NiBSAnimationNode", &construct <NiNode> , RC_NiBSAnimationNode ));
newFactory.insert(makeEntry("NiBillboardNode", &construct <NiNode> , RC_NiBillboardNode ));
newFactory.insert(makeEntry("NiTriShape", &construct <NiTriShape> , RC_NiTriShape ));
newFactory.insert(makeEntry("NiTriStrips", &construct <NiTriStrips> , RC_NiTriStrips ));
newFactory.insert(makeEntry("NiRotatingParticles", &construct <NiRotatingParticles> , RC_NiRotatingParticles ));
newFactory.insert(makeEntry("NiAutoNormalParticles", &construct <NiAutoNormalParticles> , RC_NiAutoNormalParticles ));
newFactory.insert(makeEntry("NiCamera", &construct <NiCamera> , RC_NiCamera ));
@ -96,6 +97,7 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
newFactory.insert(makeEntry("NiParticleRotation", &construct <NiParticleRotation> , RC_NiParticleRotation ));
newFactory.insert(makeEntry("NiFloatData", &construct <NiFloatData> , RC_NiFloatData ));
newFactory.insert(makeEntry("NiTriShapeData", &construct <NiTriShapeData> , RC_NiTriShapeData ));
newFactory.insert(makeEntry("NiTriStripsData", &construct <NiTriStripsData> , RC_NiTriStripsData ));
newFactory.insert(makeEntry("NiVisData", &construct <NiVisData> , RC_NiVisData ));
newFactory.insert(makeEntry("NiColorData", &construct <NiColorData> , RC_NiColorData ));
newFactory.insert(makeEntry("NiPixelData", &construct <NiPixelData> , RC_NiPixelData ));

@ -156,6 +156,29 @@ struct NiTriShape : Node
}
};
struct NiTriStrips : Node
{
NiTriStripsDataPtr data;
NiSkinInstancePtr skin;
void read(NIFStream *nif)
{
Node::read(nif);
data.read(nif);
skin.read(nif);
}
void post(NIFFile *nif)
{
Node::post(nif);
data.post(nif);
skin.post(nif);
if (!skin.empty())
nif->setUseSkinning(true);
}
};
struct NiCamera : Node
{
struct Camera

@ -41,6 +41,7 @@ enum RecordType
RC_NiBillboardNode,
RC_AvoidNode,
RC_NiTriShape,
RC_NiTriStrips,
RC_NiRotatingParticles,
RC_NiAutoNormalParticles,
RC_NiBSParticleNode,
@ -80,6 +81,7 @@ enum RecordType
RC_NiParticleRotation,
RC_NiFloatData,
RC_NiTriShapeData,
RC_NiTriStripsData,
RC_NiVisData,
RC_NiColorData,
RC_NiPixelData,

@ -135,6 +135,7 @@ class NiPixelData;
class NiColorData;
struct NiKeyframeData;
class NiTriShapeData;
class NiTriStripsData;
class NiSkinInstance;
class NiSourceTexture;
class NiRotatingParticlesData;
@ -154,6 +155,7 @@ typedef RecordPtrT<NiFloatData> NiFloatDataPtr;
typedef RecordPtrT<NiColorData> NiColorDataPtr;
typedef RecordPtrT<NiKeyframeData> NiKeyframeDataPtr;
typedef RecordPtrT<NiTriShapeData> NiTriShapeDataPtr;
typedef RecordPtrT<NiTriStripsData> NiTriStripsDataPtr;
typedef RecordPtrT<NiSkinInstance> NiSkinInstancePtr;
typedef RecordPtrT<NiSourceTexture> NiSourceTexturePtr;
typedef RecordPtrT<NiRotatingParticlesData> NiRotatingParticlesDataPtr;

@ -248,6 +248,10 @@ void BulletNifLoader::handleNode(const std::string& fileName, const Nif::Node *n
{
handleNiTriShape(static_cast<const Nif::NiTriShape*>(node), flags, getWorldTransform(node), isAnimated, avoid);
}
if(!node->hasBounds && node->recType == Nif::RC_NiTriStrips)
{
handleNiTriStrips(static_cast<const Nif::NiTriStrips*>(node), flags, getWorldTransform(node), isAnimated, avoid);
}
}
// For NiNodes, loop through children
@ -330,4 +334,11 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiTriShape *shape, int flags,
}
}
void BulletNifLoader::handleNiTriStrips(const Nif::NiTriStrips *shape, int flags, const osg::Matrixf &transform,
bool isAnimated, bool avoid)
{
// do nothing for now
}
} // namespace NifBullet

@ -26,6 +26,7 @@ namespace Nif
class Node;
struct Transformation;
struct NiTriShape;
struct NiTriStrips;
}
namespace NifBullet
@ -59,6 +60,7 @@ private:
bool hasAutoGeneratedCollision(const Nif::Node *rootNode);
void handleNiTriShape(const Nif::NiTriShape *shape, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
void handleNiTriStrips(const Nif::NiTriStrips *shape, int flags, const osg::Matrixf& transform, bool isAnimated, bool avoid);
std::unique_ptr<btCompoundShape> mCompoundShape;

@ -452,6 +452,7 @@ namespace NifOsg
break;
}
case Nif::RC_NiTriShape:
case Nif::RC_NiTriStrips:
case Nif::RC_NiAutoNormalParticles:
case Nif::RC_NiRotatingParticles:
// Leaf nodes in the NIF hierarchy, so won't be able to dynamically attach children.
@ -580,6 +581,11 @@ namespace NifOsg
node->setDataVariance(osg::Object::DYNAMIC);
}
if (nifNode->recType == Nif::RC_NiTriStrips && isAnimated) // the same thing for animated NiTriStrips
{
node->setDataVariance(osg::Object::DYNAMIC);
}
osg::ref_ptr<SceneUtil::CompositeStateSetUpdater> composite = new SceneUtil::CompositeStateSetUpdater;
applyNodeProperties(nifNode, node, composite, imageManager, boundTextures, animflags);
@ -603,6 +609,25 @@ namespace NifOsg
handleMeshControllers(nifNode, node, composite, boundTextures, animflags);
}
}
if (nifNode->recType == Nif::RC_NiTriStrips && !skipMeshes)
{
const Nif::NiTriStrips* triStrips = static_cast<const Nif::NiTriStrips*>(nifNode);
const std::string nodeName = Misc::StringUtils::lowerCase(triStrips->name);
static const std::string markerName = "tri editormarker";
static const std::string shadowName = "shadow";
static const std::string shadowName2 = "tri shadow";
const bool isMarker = hasMarkers && !nodeName.compare(0, markerName.size(), markerName);
if (!isMarker && nodeName.compare(0, shadowName.size(), shadowName) && nodeName.compare(0, shadowName2.size(), shadowName2))
{
if (triStrips->skin.empty()) {}
/*handleTriShape(triShape, node, composite, boundTextures, animflags);*/
else {}
/*handleSkinnedTriShape(triShape, node, composite, boundTextures, animflags);*/
if (!nifNode->controller.empty()) {}
/*handleMeshControllers(nifNode, node, composite, boundTextures, animflags);*/
}
}
if(nifNode->recType == Nif::RC_NiAutoNormalParticles || nifNode->recType == Nif::RC_NiRotatingParticles)
handleParticleSystem(nifNode, node, composite, animflags, rootNode);
@ -612,7 +637,8 @@ namespace NifOsg
// Note: NiTriShapes are not allowed to have KeyframeControllers (the vanilla engine just crashes when there is one).
// We can take advantage of this constraint for optimizations later.
if (nifNode->recType != Nif::RC_NiTriShape && !nifNode->controller.empty() && node->getDataVariance() == osg::Object::DYNAMIC)
if (nifNode->recType != Nif::RC_NiTriShape && nifNode->recType != Nif::RC_NiTriStrips
&& !nifNode->controller.empty() && node->getDataVariance() == osg::Object::DYNAMIC)
handleNodeControllers(nifNode, static_cast<osg::MatrixTransform*>(node.get()), animflags);
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(nifNode);

Loading…
Cancel
Save