Preliminary npcs3

actorid
Jason Hooks 14 years ago
parent dfe20033ea
commit 467988455c

@ -41,7 +41,7 @@ namespace MWClass
std::string hairID = ref->base->hair;
std::string headID = ref->base->head;
std::string npcName = ref->base->name;
//std::cout << "NPC: " << npcName << "\n";
std::cout << "NPC: " << npcName << "\n";
//get the part of the bodypart id which describes the race and the gender
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
@ -64,18 +64,19 @@ namespace MWClass
Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1);
Ogre::Radian angle = Ogre::Radian(0);
std::string addresses[6] = {"", "", "", "",""};
std::string addresses2[6] = {"", "", "", "", ""};
std::string addresses[6] = {"", "", "", "","", ""};
std::string addresses2[6] = {"", "", "", "", "", ""};
std::string upperleft[5] = {"", "", "", "", ""};
std::string upperright[5] = {"", "", "", "", ""};
std::string neckandup[5] = {"", "", "","",""};
std::string empty[6] = {"", "", "", "","", ""};
int numbers = 0;
int uppernumbers = 0;
int neckNumbers = 0;
if (bodyPart){
cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers);
cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0
addresses2[numbers] = npcName + "chest";
addresses[numbers++] = npcName + "chest";
upperleft[uppernumbers] = npcName + "chest";
@ -92,11 +93,11 @@ namespace MWClass
const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee");
const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle");
const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot");
const ESM::BodyPart *foot2 = foot + 1;
const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist");
const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm");
const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st");
const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st");
const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st");
std::cout << "RACE" << bodyRaceID << "\n";
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"};
@ -109,10 +110,11 @@ namespace MWClass
//addresses[1] = npcName + "groin";
if(upperleg){
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -14), axis, Ogre::Radian(.7), npcName + "upper leg", addresses, numbers); //-18
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -14), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -14), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers);
addresses2[numbers] = npcName + "upper leg2";
addresses[numbers++] = npcName + "upper leg";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
}
if(knee)
{
@ -124,28 +126,42 @@ namespace MWClass
addresses[numbers++] = npcName + "knee";
}
if(ankle){
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -18), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers);
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -18), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers);
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, -1, -18), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1
cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, -1, -18), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1
addresses2[numbers] = npcName + "ankle2";
addresses[numbers++] = npcName + "ankle";
}
if(foot){
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -2, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers);
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -2, -16), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers);
//std::cout << "RACE" << bodyRaceID << "\n";
if(bodyRaceID.compare("b_n_khajiit_m_") == 0 || bodyRaceID.compare("b_n_khajiit_f_") == 0)
{
std::cout << "BEASTRACE\n";
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -24, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers);
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -24, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers);
}
else{
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers);
cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers);
}
addresses2[numbers] = npcName + "foot2";
addresses[numbers++] = npcName + "foot";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
}
if (arm){
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(1, 0, .75), Ogre::Radian(3.14), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //1, 0, 1
//010
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers);
upperleft[uppernumbers] = npcName + "upper arm";
upperright[uppernumbers++] = npcName + "upper arm2";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1
cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers);
}
if (forearm)
@ -168,8 +184,29 @@ namespace MWClass
if(hand)
cellRender.insertMesh("meshes\\" + hand->model, Ogre::Vector3(-50, 0, -120), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hands", addresses, 4); //0, 100, -100 0,0,120
{
//std::cout << "WE FOUND A HAND\n";
//-50, 0, -120
cellRender.insertMesh("meshes\\" + hand->model, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120
cellRender.insertMesh("meshes\\" + hand->model, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
upperleft[uppernumbers] = npcName + "hand";
upperright[uppernumbers++] = npcName + "hand2";
//cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
}
if(hands)
{
//std::cout << "WE FOUND HANDS\n";
//-50, 0, -120
cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
//cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
upperleft[uppernumbers] = npcName + "hand";
upperright[uppernumbers++] = npcName + "hand2";
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
}
if(neck)
{

@ -5,10 +5,12 @@
namespace MWClass
{
static bool isChest;
//static ;bool isChest = false;
class Npc : public MWWorld::Class
{
public:
virtual std::string getId (const MWWorld::Ptr& ptr) const;
///< Return ID of \a ptr

@ -39,6 +39,7 @@ namespace MWRender
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0;
/// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0;
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0;
virtual void insertMesh(const std::string &mesh) = 0;

@ -69,7 +69,7 @@ void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std
}
parent->rotate(axis, angle);
}
/*
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
assert (insert);
//insert->
@ -91,7 +91,35 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
//npcPart->
}
*/
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
{
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
}
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
assert (insert);
//insert->
Ogre::SceneNode *parent = insert;
for (int i = 0; i < elements; i++){
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
}
npcPart = parent->createChildSceneNode(sceneNodeName);
NIFLoader::load(mesh,0,0);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
//ent->extr
\
// MovableObject *ent2 = scene.getMgr()->createEntity(bounds
// );
//ent->
//std::cout << mesh << bounds << "\n";
npcPart->translate(vec);
npcPart->rotate(axis, angle);
npcPart->attachObject(ent);
}
// insert a mesh related to the most recent insertBegin call.
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)

@ -66,7 +66,9 @@ namespace MWRender
/// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
virtual void insertMesh(const std::string &mesh);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
virtual void insertMesh(const std::string &mesh);
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);

@ -83,7 +83,11 @@ void InteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeNam
}
parent->scale(axis);
}
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements)
{
insertMesh(mesh, vec, axis, angle, sceneNodeName, sceneParent, elements, true);
}
void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
assert (insert);
//insert->
@ -94,11 +98,26 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
}
npcPart = parent->createChildSceneNode(sceneNodeName);
NIFLoader::load(mesh);
MovableObject *ent = scene.getMgr()->createEntity(mesh);
//npcPart->showBoundingBox(true);
MeshPtr good = NIFLoader::load(mesh, 0, 0);
MovableObject *ent = scene.getMgr()->createEntity(good->getName());
//ent->extr
// MovableObject *ent2 = scene.getMgr()->createEntity(bounds
// );
//ent->
//std::cout << mesh << bounds << "\n";
if(translateFirst){
npcPart->translate(vec);
npcPart->rotate(axis, angle);
}
else{
npcPart->rotate(axis, angle);
npcPart->translate(vec);
}
npcPart->attachObject(ent);
}

@ -29,7 +29,7 @@ namespace MWRender
class InteriorCellRender : public CellRender, private CellRenderImp
{
//static bool isChest;
static bool lightConst;
static float lightConstValue;
@ -68,6 +68,7 @@ namespace MWRender
/// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
/// insert a light related to the most recent insertBegin call.
virtual void insertLight(float r, float g, float b, float radius);

@ -21,11 +21,14 @@
*/
//loadResource->handleNode->handleNiTriShape->createSubMesh
#include "ogre_nif_loader.hpp"
#include <Ogre.h>
#include <stdio.h>
#include <libs/mangle/vfs/servers/ogre_vfs.hpp>
#include "../../apps/openmw/mwclass/npc.hpp"
#include "../nif/nif_file.hpp"
#include "../nif/node.hpp"
#include "../nif/data.hpp"
@ -325,10 +328,15 @@ void NIFLoader::findRealTexture(String &texName)
texName[len-1] = 's';
}
//Handle node at top
// Convert Nif::NiTriShape to Ogre::SubMesh, attached to the given
// mesh.
void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std::list<VertexBoneAssignment> &vertexBoneAssignments)
{
// cout << "s:" << shape << "\n";
NiTriShapeData *data = shape->data.getPtr();
SubMesh *sub = mesh->createSubMesh(shape->name.toString());
@ -468,8 +476,11 @@ static void vectorMul(const Matrix &A, float *C)
C[i] = a*A.v[i].array[0] + b*A.v[i].array[1] + c*A.v[i].array[2];
}
void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bounds)
{
//if( MWClass::Npc.isChest)
//cout << "t:" << shape << "\n";
assert(shape != NULL);
// Interpret flags
@ -719,6 +730,9 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
void NIFLoader::handleNode(Nif::Node *node, int flags,
const Transformation *trafo, BoundsFinder &bounds, Bone *parentBone)
{
stack++;
//if( MWClass::isChest)
// cout << "u:" << node << "\n";
// Accumulate the flags from all the child nodes. This works for all
// the flags we currently use, at least.
flags |= node->flags;
@ -810,20 +824,156 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
{
NodeList &list = ((NiNode*)node)->children;
int n = list.length();
for (int i=0; i<n; i++)
int i = 0;
if(isHands){
//cout << "NumberOfNs: " << n << "Stack:" << stack << "\n";
//if(stack == 3)
//n=0;
}
for (; i<n; i++)
{
if (list.has(i))
handleNode(&list[i], flags, node->trafo, bounds, bone);
}
}
else if (node->recType == RC_NiTriShape)
{
// For shapes
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
if((isChest && stack < 10) || (isHands && counter < 3) || !(isChest || isHands)){ //less than 10
handleNiTriShape(dynamic_cast<NiTriShape*>(node), flags, bounds);
}
if(isHands){
//cout << "Handling Shape, Stack " << stack <<"\n";
counter++;
}
}
stack--;
}
void NIFLoader::loadResource(Resource *resource)
{
stack = 0;
counter = 0;
std::string name = resource->getName();
//std::cout <<"NAME:" << name;
//if(name.length() >= 20)
// {std::string split = name.substr(name.length() - 20, 20);
//if(name ==
//std::cout <<"NAME:" << name << "LEN: " << name.length() << "\n";
const std::string test ="meshes\\b\\B_N_Dark Elf_M_Skins.NIF";
const std::string test2 ="meshes\\b\\B_N_Dark Elf_M_Skins.nif";
const std::string test3 ="meshes\\b\\B_N_Redguard_F_Skins.NIF";
const std::string test4 ="meshes\\b\\B_N_Redguard_F_Skins.nif";
const std::string test5 ="meshes\\b\\B_N_Dark Elf_F_Skins.nif";
const std::string test6 ="meshes\\b\\B_N_Redguard_M_Skins.nif";
const std::string test7 ="meshes\\b\\B_N_Wood Elf_F_Skins.nif";
const std::string test8 ="meshes\\b\\B_N_Wood Elf_M_Skins.nif";
const std::string test9 ="meshes\\b\\B_N_Imperial_F_Skins.nif";
const std::string test10 ="meshes\\b\\B_N_Imperial_M_Skins.nif";
const std::string test11 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
const std::string test12 ="meshes\\b\\B_N_Khajiit_M_Skins.nif";
const std::string test13 ="meshes\\b\\B_N_Argonian_F_Skins.nif";
const std::string test14 ="meshes\\b\\B_N_Argonian_M_Skins.nif";
const std::string test15 ="meshes\\b\\B_N_Nord_F_Skins.nif";
const std::string test16 ="meshes\\b\\B_N_Nord_M_Skins.nif";
const std::string test17 ="meshes\\b\\B_N_Imperial_F_Skins.nif";
const std::string test18 ="meshes\\b\\B_N_Imperial_M_Skins.nif";
const std::string test19 ="meshes\\b\\B_N_Orc_F_Skins.nif";
const std::string test20 ="meshes\\b\\B_N_Orc_M_Skins.nif";
const std::string test21 ="meshes\\b\\B_N_Breton_F_Skins.nif";
const std::string test22 ="meshes\\b\\B_N_Breton_M_Skins.nif";
const std::string test23 ="meshes\\b\\B_N_High Elf_F_Skins.nif";
const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif";
//std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n";
if(name.compare(test) == 0 || name.compare(test2) == 0 || name.compare(test3) == 0 || name.compare(test4) == 0 ||
name.compare(test5) == 0 || name.compare(test6) == 0 || name.compare(test7) == 0 || name.compare(test8) == 0 || name.compare(test9) == 0 ||
name.compare(test10) == 0 || name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 ||
name.compare(test14) == 0 || name.compare(test15) == 0 || name.compare(test16) == 0 || name.compare(test17) == 0 ||
name.compare(test18) == 0 || name.compare(test19) == 0 || name.compare(test20) == 0 || name.compare(test21) == 0 ||
name.compare(test22) == 0 || name.compare(test23) == 0 || name.compare(test24)
){
//std::cout << "Welcome Chest\n";
isChest = true;
if(name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 || name.compare(test14) == 0)
{
isBeast = true;
std::cout << "Welcome Beast\n";
}
else
isBeast = false;
}
else
isChest = false;
const std::string hands ="meshes\\b\\B_N_Dark Elf_M_Hands.1st.NIF";
const std::string hands2 ="meshes\\b\\B_N_Dark Elf_F_Hands.1st.NIF";
const std::string hands3 ="meshes\\b\\B_N_Redguard_M_Hands.1st.nif";
const std::string hands4 ="meshes\\b\\B_N_Redguard_F_Hands.1st.nif";
const std::string hands5 ="meshes\\b\\b_n_argonian_m_hands.1st.nif";
const std::string hands6 ="meshes\\b\\b_n_argonian_f_hands.1st.nif";
const std::string hands7 ="meshes\\b\\B_N_Breton_M_Hand.1st.NIF";
const std::string hands8 ="meshes\\b\\B_N_Breton_F_Hands.1st.nif";
const std::string hands9 ="meshes\\b\\B_N_High Elf_M_Hands.1st.nif";
const std::string hands10 ="meshes\\b\\B_N_High Elf_F_Hands.1st.nif";
const std::string hands11 ="meshes\\b\\B_N_Nord_M_Hands.1st.nif";
const std::string hands12 ="meshes\\b\\B_N_Nord_F_Hands.1st.nif";
const std::string hands13 ="meshes\\b\\b_n_khajiit_m_hands.1st.nif";
const std::string hands14 ="meshes\\b\\b_n_khajiit_f_hands.1st.nif";
const std::string hands15 ="meshes\\b\\B_N_Orc_M_Hands.1st.nif";
const std::string hands16 ="meshes\\b\\B_N_Orc_F_Hands.1st.nif";
const std::string hands17 ="meshes\\b\\B_N_Wood Elf_M_Hands.1st.nif";
const std::string hands18 ="meshes\\b\\B_N_Wood Elf_F_Hands.1st.nif";
const std::string hands19 ="meshes\\b\\B_N_Imperial_M_Hands.1st.nif";
const std::string hands20 ="meshes\\b\\B_N_Imperial_F_Hands.1st.nif";
if(name.compare(hands) == 0 || name.compare(hands2) == 0 || name.compare(hands3) == 0 || name.compare(hands4) == 0 ||
name.compare(hands5) == 0 || name.compare(hands6) == 0 || name.compare(hands7) == 0 || name.compare(hands8) == 0 ||
name.compare(hands9) == 0 || name.compare(hands10) == 0 || name.compare(hands11) == 0 || name.compare(hands12) == 0 ||
name.compare(hands13) == 0 || name.compare(hands14) == 0 || name.compare(hands15) == 0 || name.compare(hands16) == 0 ||
name.compare(hands17) == 0 || name.compare(hands18) == 0 || name.compare(hands19) == 0 || name.compare(hands20) == 0)
{
std::cout << "Welcome Hands1st\n";
isHands = true;
isChest = false;
}
else
isHands = false;
/*
else if(name.compare(test3) == 0 || name.compare(test4) == 0)
{
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true;
}
else if(name.compare(test5) == 0 || name.compare(test6) == 0)
{
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true;
}
else if(name.compare(test7) == 0 || name.compare(test8) == 0)
{
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true;
}
else if(name.compare(test9) == 0 || name.compare(test10) == 0)
{
std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n";
isChest = true;
}*/
//if(split== "Skins.NIF")
// std::cout << "\nSPECIAL PROPS\n";
resourceName = "";
MeshManager *m = MeshManager::getSingletonPtr();
// Check if the resource already exists
//MeshPtr ptr = m->load(name, "custom");
//cout << "THISNAME: " << ptr->getName() << "\n";
//cout << "RESOURCE:"<< resource->getName();
mesh = 0;
skel.setNull();
@ -836,6 +986,7 @@ void NIFLoader::loadResource(Resource *resource)
// Look it up
resourceName = mesh->getName();
//std::cout << resourceName << "\n";
if (!vfs->isFile(resourceName))
{
@ -887,18 +1038,48 @@ void NIFLoader::loadResource(Resource *resource)
// mesh->setSkeletonName(getSkeletonName());
}
MeshPtr NIFLoader::load(const std::string &name,
const std::string &group)
MeshPtr NIFLoader::load(const std::string &name,
int pieces, int pieceIndex,const std::string &group)
{
MeshManager *m = MeshManager::getSingletonPtr();
// Check if the resource already exists
ResourcePtr ptr = m->getByName(name, group);
if (!ptr.isNull())
return MeshPtr(ptr);
MeshPtr resize;
if (!ptr.isNull()){
//if(pieces > 1)
//cout << "It exists\n";
resize = MeshPtr(ptr);
//resize->load();
//resize->reload();
}
else // Nope, create a new one.
{
//if(pieces > 1)
//cout << "Creating it\n";
resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr());
//resize->load();
//resize->reload();
//return 0;
ResourcePtr ptr = m->getByName(name, group);
resize = MeshPtr(ptr);
//NIFLoader::getSingletonPtr()->
/*ResourcePtr ptr = m->getByName(name, group);
if (!ptr.isNull()){
if(pieces > 1)
cout << "It exists\n";
resize = MeshPtr(ptr);*/
//return resize;
}
return resize;
}
// Nope, create a new one.
return MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr());
MeshPtr NIFLoader::load(const std::string &name,
const std::string &group)
{
return load(name, 1, 0, group);
}
/* More code currently not in use, from the old D source. This was

@ -67,14 +67,19 @@ namespace Mangle
class NIFLoader : Ogre::ManualResourceLoader
{
public:
static int numberOfMeshes;
static NIFLoader& getSingleton();
static NIFLoader* getSingletonPtr();
virtual void loadResource(Ogre::Resource *resource);
static Ogre::MeshPtr load(const std::string &name,
const std::string &group="General");
static Ogre::MeshPtr load(const std::string &name,
const std::string &group="General");
static Ogre::MeshPtr load(const std::string &name,
int pieces, int pieceIndex, const std::string &group="General");
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
Ogre::Quaternion convertRotation(const Nif::Matrix& rot);
@ -120,6 +125,13 @@ class NIFLoader : Ogre::ManualResourceLoader
std::string resourceName;
std::string resourceGroup;
bool isChest;
bool isBeast;
bool isHands;
int counter;
int numbers;
int stack;
// pointer to the ogre mesh which is currently build
Ogre::Mesh *mesh;

@ -0,0 +1,256 @@
/* //This is old
if (pieces > 1){ //pieces > 1
MeshPtr justChest = MeshManager::getSingleton().createManual("justchest", group, NIFLoader::getSingletonPtr());
Ogre::AxisAlignedBox bounds = resize->getBounds();
Ogre::Vector3 width2 = bounds.getCorner(bounds.NEAR_RIGHT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM);
Ogre::Vector3 depth2 = (bounds.getCorner(bounds.FAR_LEFT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM));
Ogre::Vector3 height2 = bounds.getCorner(bounds.NEAR_LEFT_TOP) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM);
cout << "Width:" << width2; cout << "Height:" << height2; cout << "Depth:" << depth2;
/*int width = bounds.getMaximum().x - bounds.getMinimum().x;
int height = bounds.getMaximum().y - bounds.getMinimum().y;
int depth = bounds.getMaximum().z - bounds.getMinimum().z;
int xinc = width / pieces;
int yinc = height / pieces;
int zinc = depth / pieces;
int xmincorner = bounds.getMinimum().x + xinc*pieceIndex;
int ymincorner = bounds.getMinimum().y + yinc*pieceIndex;
int zmincorner = bounds.getMinimum().z + xinc*pieceIndex;*/
//Ogre::Vector3 bottom_left = bounds.getCorner(bounds.NEAR_LEFT_BOTTOM) + (width2 / pieces) * pieceIndex; //width2
//Ogre::Vector3 top_right = bottom_left + (width2 / pieces) + height2 + depth2;
//Ogre::AxisAlignedBox set = AxisAlignedBox ( Ogre::Vector3(xmincorner, bounds.getMinimum().y, bounds.getMinimum().z), Ogre::Vector3(xmincorner + xinc, bounds.getMaximum().y, bounds.getMaximum().z));
//Ogre::AxisAlignedBox set = bounds;//AxisAlignedBox(bottom_left, top_right);
//bounds.setMinimumX(xmincorner);
//bounds.setMaximumX(xmincorner + xinc);
//bounds.setMinimumY(ymincorner);
//bounds.setMaximumY(ymincorner + yinc);
//bounds.setMinimumZ(zmincorner);
//bounds.setMaximumZ(zmincorner + zinc);
//bounds.setMinimumY(bounds.getMinimum().y);
//bounds.setMaximumY( bounds.getMaximum().y;
//resize->_setBounds(set, true);
//resize->reload();
//Ogre::Mesh::SubMeshIterator subMeshIterator = resize->getSubMeshIterator();
/*Ogre::Vector3* point;
Ogre::SubMesh* subMesh;
size_t vertex_count = 0;
Vector3* vertices;
size_t index_count = 0;
unsigned* indices;
Vector3 position = Vector3::ZERO;
Quaternion orient = Quaternion::IDENTITY;
Vector3 scale = Vector3::UNIT_SCALE;
// int vertex_count = 0;
//int index_count = 0;
bool added_shared = false;
size_t current_offset = vertex_count;
size_t shared_offset = vertex_count;
size_t next_offset = vertex_count;
size_t index_offset = index_count;
size_t prev_vert = vertex_count;
size_t prev_ind = index_count;
// Calculate how many vertices and indices we're going to need
/*
std::cout <<"FIRST CYCLE\n";
for(int i = 0;i < resize->getNumSubMeshes();i++)
{
std::cout<< "WEHAVEMESHES\n";
SubMesh* submesh = resize->getSubMesh(i);
// We only need to add the shared vertices once
if(submesh->useSharedVertices)
{
if(!added_shared)
{
VertexData* vertex_data = resize->sharedVertexData;
vertex_count += vertex_data->vertexCount;
added_shared = true;
}
}
else
{
VertexData* vertex_data = submesh->vertexData;
vertex_count += vertex_data->vertexCount;
}
// Add the indices
Ogre::IndexData* index_data = submesh->indexData;
index_count += index_data->indexCount;
}
*/
// Vector3* vertices;
// Allocate space for the vertices and indices
/*vertices = new Vector3[vertex_count];
indices = new unsigned[index_count];
int meshcounter = 0;
added_shared = false;
std::cout <<"SECOND CYCLE: " << resize->getNumSubMeshes() << "\n";
// Run through the submeshes again, adding the data into the arrays
int i;
for(i = 0;i < resize->getNumSubMeshes();i++)
{
SubMesh* submesh = resize->getSubMesh(i);
Ogre::VertexData* vertex_data = submesh->useSharedVertices ? resize->sharedVertexData : submesh->vertexData;
/*
if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared))
{
if(submesh->useSharedVertices)
{
added_shared = true;
shared_offset = current_offset;
}
const Ogre::VertexElement* posElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(posElem->getSource());
unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
Ogre::Real* pReal;
bool onepointexists = true;
Vector3 lastpoint;
for(size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize())
{
posElem->baseVertexPointerToElement(vertex, &pReal);
Vector3 pt;
pt.x = (*(pReal++));
pt.y = (*(pReal++));
pt.z = (*(pReal++));
//cout << "X:" << pt.x << "Y:" <<pt.y << "Z:" <<pt.z << "\n";
//cout << "Boxmin:" << set.getMinimum() <<" Boxmax:" <<set.getMaximum() <<"\n";
//if(set.intersects(pt))
//onepointexists = true;
if(!set.intersects(pt))
{
pt = lastpoint;
//*pReal = pt.x;
//*(pReal+1) = pt.y;
//*(pReal+2) = pt.z;
//vertex
}
else
lastpoint = pt;
pt = (orient * (pt * scale)) + position;
if(!set.intersects(pt))
onepointexists = false;
vertices[current_offset + j].x = pt.x;
vertices[current_offset + j].y = pt.y;
vertices[current_offset + j].z = pt.z;
}
/*if(true)
{
std::cout<< "Wearegoingtodelete"<< submesh->getMaterialName() << "\n";
if(meshcounter <= 2)
resize->destroySubMesh(i);
else if(meshcounter > 3 && meshcounter < 7)
resize->destroySubMesh(i);
//submesh->setMaterialName("BaseWhiteNoLighting"); //red
//submesh->updateMaterialUsingTextureAliases();
//resize->
meshcounter++;
//delete submesh;
//reakb;
}*/
/*
vbuf->unlock();
next_offset += vertex_data->vertexCount;
}
Ogre::IndexData* index_data = submesh->indexData;
size_t numTris = index_data->indexCount / 3;
unsigned short* pShort;
unsigned int* pInt;
Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
if (use32bitindexes) pInt = static_cast<unsigned int*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
else pShort = static_cast<unsigned short*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
for(size_t k = 0; k < numTris; ++k)
{
size_t offset = (submesh->useSharedVertices)?shared_offset:current_offset;
unsigned int vindex = use32bitindexes? *pInt++ : *pShort++;
indices[index_offset + 0] = vindex + offset;
vindex = use32bitindexes? *pInt++ : *pShort++;
indices[index_offset + 1] = vindex + offset;
vindex = use32bitindexes? *pInt++ : *pShort++;
indices[index_offset + 2] = vindex + offset;
index_offset += 3;
}
ibuf->unlock();
current_offset = next_offset;*/
//if (i == 3) //i!=3 i!=5
//{
//cout << "RETURNINGJUST\n";
//SubMesh* test =
//test = resize->getSubMesh(i);
// cout << "s:" << shape << "\n";
//NiTriShapeData *data = shape->data.getPtr();
// SubMesh *sub = justChest->createSubMesh(name + "2");
//sub = resize->getSubMesh(i);
// int nextBuf = 0;
// This function is just one long stream of Ogre-barf, but it works
// great.
// Add vertices
//int numVerts = data->vertices.length / 3;
//sub->vertexData = new VertexData();
//sub->vertexData->vertexCount = numVerts;
//justChest->load();
//return resize;
//}
// 0 hand thumb
// 1 hand thumb no chest on dunmer
//}
//resize->destroySubMesh(1);
/* while (subMeshIterator.hasMoreElements())
{
resize->getNum
//resize->d
std::cout << "CHEST";
subMesh = subMeshIterator.getNext();*/
//std::vector<Vector3>::type test =
//std::vector<Ogre::Vector3>::iterator fileIter = subMesh->extremityPoints.begin();
//std::vector<Ogre::Vector3>::type test = subMesh->extremityPoints;
//void* pData = subMesh->vertexData->vertexBufferBinding->getBuffer(1)->lock(0, 1000, HardwareBuffer::HBL_DISCARD);
// if(set.contains( subMesh->vertexData->vertexStart))
//delete subMesh;
//subMeshIterator.getNext();
//delete[] subMesh;
//subMesh->extremityPoints.clear();
//subMesh->mLodFaceList.clear();
//resize->destroySubMesh(subMesh->indexData->indexStart);
//resize->destroySubMesh(subMesh->indexData->);
//subMesh->
//std::cout << "THIS" << subMesh;
///}
//subMesh->vertexData->vertexBufferBinding->getBuffer(0)->readData(subMesh->vertexData->vertexStart, sizeof Ogre::Vector3, point);
//boost::filesystem::directory_iterator dir_iter(dir), dir_end;
//return resize;
Loading…
Cancel
Save