Cleanup; warnings

actorid
Jason Hooks 13 years ago
parent c2fa82326d
commit 595d0b1192

@ -77,7 +77,7 @@ namespace MWRender{
}
if(time >= copy.morph.getStartTime() && time <= copy.morph.getStopTime()){
float x;
for (int i = 0; i < copy.morph.getAdditionalVertices().size(); i++){
for (unsigned int i = 0; i < copy.morph.getAdditionalVertices().size(); i++){
int j = 0;
if(shapeIndexI[shapeNumber].size() <= i)
shapeIndexI[shapeNumber].push_back(0);
@ -93,7 +93,7 @@ namespace MWRender{
if ( t > 1 ) t = 1;
if( t != 0 && initialVertices.size() == copy.morph.getAdditionalVertices()[i].size())
{
for (int v = 0; v < initialVertices.size(); v++){
for (unsigned int v = 0; v < initialVertices.size(); v++){
initialVertices[v] += ((copy.morph.getAdditionalVertices()[i])[v]) * t;
}
}
@ -103,17 +103,7 @@ namespace MWRender{
}
//After everything, write everything out
/*
for(int i = 0; i < initialVertices.size(); i++){
Ogre::Vector3 current = initialVertices[i];
Ogre::Real* addr = pReal + i * 3;
*addr = current.x;
*(addr+1) = current.y;
*(addr + 2) = current.z;
}*/
allvertices = initialVertices;
}
shapeNumber++;
@ -124,14 +114,14 @@ namespace MWRender{
if(boneinfovector.size() > 0){
for (int i = 0; i < boneinfovector.size(); i++)
for (unsigned int i = 0; i < boneinfovector.size(); i++)
{
Nif::NiSkinData::BoneInfoCopy boneinfo = boneinfovector[i];
if(skel->hasBone(boneinfo.bonename)){
Ogre::Bone *bonePtr = skel->getBone(boneinfo.bonename);
Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfo.trafo.trans;
Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfo.trafo.rotation;
//std::cout << "Bone" << bonePtr->getName() << "\n";
for (unsigned int j=0; j < boneinfo.weights.size(); j++)
{
unsigned int verIndex = boneinfo.weights[j].vertex;
@ -146,7 +136,6 @@ namespace MWRender{
*(addr+2) = absVertPos.z;
//std::cout << "Vertex" << vertices[verIndex] << "\n";
}
else
{
@ -247,7 +236,7 @@ namespace MWRender{
// Computes C = B + AxC*scale
// final_vector = old_vector + old_rotation*new_vector*old_scale/
for(int i = 0; i < allvertices.size(); i++){
for(unsigned int i = 0; i < allvertices.size(); i++){
Ogre::Vector3 current = transmult + rotmult * allvertices[i];
Ogre::Real* addr = pReal + i * 3;
*addr = current.x;
@ -332,7 +321,7 @@ namespace MWRender{
Ogre::Bone* b = skel->getRootBone();
b->setOrientation(.3,.3,.3,.3); //This is a trick
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3)); //This is a trick
skel->getManualBonesDirty();
skel->_updateTransforms();
skel->_notifyManualBonesDirty();
@ -341,11 +330,11 @@ namespace MWRender{
base->_updateAnimation();
base->_notifyMoved();
for(int i = 0; i < entityparts.size(); i++){
for(unsigned int i = 0; i < entityparts.size(); i++){
Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
Ogre::Bone* b = skel->getRootBone();
b->setOrientation(.3,.3,.3,.3); //This is a trick
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
skel->getManualBonesDirty();
skel->_updateTransforms();
skel->_notifyManualBonesDirty();

@ -15,32 +15,29 @@ namespace MWRender{
class Animation{
protected:
OEngine::Physic::PhysicEngine* engine;
Ogre::SceneNode* insert;
OEngine::Render::OgreRenderer &mRend;
MWWorld::Environment& mEnvironment;
static std::map<std::string, int> mUniqueIDs;
Ogre::Vector3 originalpos;
Ogre::Vector3 originalscenenode;
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating an npc
float time;
float startTime;
float stopTime;
bool loop;
int animate;
//Represents a rotation index for each bone
std::vector<int>rindexI;
//Represents a translation index for each bone
std::vector<int>tindexI;
//Only shapes with morphing data will need a shape number
//Only shapes with morphing data will use a shape number
int shapeNumber;
std::vector<std::vector<int> > shapeIndexI;
//Ogre::SkeletonInstance* skel;
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for this creature
std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for a creature
std::vector<Ogre::Entity*> entityparts;
@ -53,7 +50,7 @@ class Animation{
std::string getUniqueID(std::string mesh);
public:
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), loop(false), animate(0){};
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0){};
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();

@ -10,8 +10,7 @@ CreatureAnimation::~CreatureAnimation(){
}
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
assert(insert);
insert = ptr.getRefData().getBaseNode();
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
@ -27,14 +26,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
for(int init = 0; init < transformations->size(); init++){
rindexI.push_back(0);
//a.rindexJ.push_back(0);
tindexI.push_back(0);
//a.tindexJ.push_back(0);
}
loop = false;
stopTime = transformations->begin()->getStopTime();
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
startTime = transformations->begin()->getStartTime();
startTime = transformations->begin()->getStartTime();
shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
}
insert->attachObject(base);

@ -13,9 +13,6 @@ NpcAnimation::~NpcAnimation(){
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
//assert (ref->base != NULL);
//insertBegin(ptr, true, true);
//Part selection on last character of the file string
// " Tri Chest
@ -46,13 +43,13 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
bool female = tolower(secondtolast) == 'f';
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
std::cout << "Race: " << ref->base->race ;
/*std::cout << "Race: " << ref->base->race ;
if(female){
std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n";
}
else{
std::cout << " Sex: Male" << " Height: " << race->data.height.male << "\n";
}
}*/
@ -72,17 +69,13 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){
for(int init = 0; init < transformations->size(); init++){
for(unsigned int init = 0; init < transformations->size(); init++){
rindexI.push_back(0);
//a.rindexJ.push_back(0);
tindexI.push_back(0);
//a.tindexJ.push_back(0);
}
loop = false;
stopTime = transformations->begin()->getStopTime();
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
startTime = transformations->begin()->getStartTime();
startTime = transformations->begin()->getStartTime();
}
insert->attachObject(base);
@ -114,7 +107,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
forearml = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two
if(!handl)
handl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands");
//const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle");
//const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle");
//const ESM::BodyPart* clavicler = claviclel;
const ESM::BodyPart* handr = handl;
const ESM::BodyPart* forearmr = forearml;
@ -214,8 +207,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
insertFreePart("meshes\\" + feet->model,"><", insert);
insertFreePart("meshes\\" + feet->model,">:", insert);
}
originalpos = insert->_getWorldAABB().getCenter();
originalscenenode = insert->getPosition();
//originalpos = insert->_getWorldAABB().getCenter();
//originalscenenode = insert->getPosition();
}
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
@ -243,17 +236,17 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf
void NpcAnimation::runAnimation(float timepassed){
//Add the amount of time passed to time
//1. Add the amount of time passed to time
//Handle the animation transforms dependent on time
//2. Handle the animation transforms dependent on time
//Handle the shapes dependent on animation transforms
//3. Handle the shapes dependent on animation transforms
if(animate > 0){
time += timepassed;
if(time > stopTime){
animate--;
//std::cout << "Stopping the animation\n";
if(animate == 0)
time = stopTime;
else
@ -277,17 +270,12 @@ void NpcAnimation::runAnimation(float timepassed){
//mEnvironment.mWorld->setObjectPhysicsRotation(insert->getName(), boneQuat * insert->getOrientation());
}*/
// handleAnimationTransforms(base);
//handleAnimationTransforms(hand);
//
std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
//int i = 0;
while(shapepartsiter != shapeparts.end())
{
std::vector<Nif::NiTriShapeCopy>* shapes = *shapepartsiter;
//insert->
//insert->detachObject(hand->getName());
Ogre::Entity* theentity = *entitypartsiter;
/*
Pass* pass = theentity->getSubEntity(0)->getMaterial()->getBestTechnique()->getPass(0);
@ -295,16 +283,8 @@ void NpcAnimation::runAnimation(float timepassed){
std::cout << "It's hardware\n";
else
std::cout << "It's software\n";*/
//std::cout << "Techniques:" << theentity->getSubEntity(0)->getMaterial()->getNumTechniques() << "\n";
/*if (pass->hasVertexProgram())// && pass->getVertexProgram()->isSkeletalAnimationIncluded()) value = "Hardware"
std::cout << "Its hardware\n";
else
std::cout << "Its software\n";*/
// handleAnimationTransforms(theentity);
handleShapes(shapes, theentity, theentity->getSkeleton());
//insert->attachObject(hand);
//std::cout << "Shape part size" << shapes->size() << "\n";
shapepartsiter++;
entitypartsiter++;
}

@ -16,7 +16,7 @@ namespace MWRender{
class NpcAnimation: public Animation{
Ogre::SceneNode* insert;
public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);

@ -212,13 +212,9 @@ void NIFLoader::createMaterial(const String &name,
{
MaterialPtr material = MaterialManager::getSingleton().create(name, resourceGroup);
// This assigns the texture to this material. If the texture name is
// a file name, and this file exists (in a resource directory), it
// will automatically be loaded when needed. If not (such as for
// internal NIF textures that we might support later), we should
// already have inserted a manual loader for the texture.
/*
if(!mSkel.isNull()){
//Hardware Skinning code, textures may be the wrong color if enabled
/*if(!mSkel.isNull()){
material->removeAllTechniques();
Ogre::Technique* tech = material->createTechnique();
@ -226,6 +222,14 @@ void NIFLoader::createMaterial(const String &name,
Pass* pass = tech->createPass();
pass->setVertexProgram("Ogre/HardwareSkinningFourWeights");
}*/
// This assigns the texture to this material. If the texture name is
// a file name, and this file exists (in a resource directory), it
// will automatically be loaded when needed. If not (such as for
// internal NIF textures that we might support later), we should
// already have inserted a manual loader for the texture.
if (!texName.empty())
{
Pass *pass = material->getTechnique(0)->getPass(0);
@ -359,22 +363,16 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
int index = i * 3;
const float *pos = data->vertices.ptr + index;
Ogre::Vector3 original = Ogre::Vector3(*pos ,*(pos+1), *(pos+2));
//std::cout << "Original: " << original;
//rstd::cout << "vectorfirst" << original << "\n";
original = mTransform * original;
mBoundingBox.merge(original);
//std::cout <<" New: " << original << "\n";
datamod[index] = original.x;
datamod[index+1] = original.y;
datamod[index+2] = original.z;
//std::cout << "vector " << original << "\n";
//std::cout << "datamod: " << datamod[index+1] << "datamod2: " << *(pos+1) << "\n";
}
vbuf->writeData(0, vbuf->getSizeInBytes(), datamod, false);
}
else
{
//std::cout << "X " << data->vertices.ptr[0] << "Y " << data->vertices.ptr[1] << "Z " << data->vertices.ptr[2] << "NIFLOADER" << "\n";
vbuf->writeData(0, vbuf->getSizeInBytes(), data->vertices.ptr, false);
}
@ -382,7 +380,6 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
VertexBufferBinding* bind = sub->vertexData->vertexBufferBinding;
bind->setBinding(nextBuf++, vbuf);
// Vertex normals
if (data->normals.length)
{
decl->addElement(nextBuf, 0, VET_FLOAT3, VES_NORMAL);
@ -398,14 +395,14 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
float *datamod = new float[data->normals.length];
for(int i = 0; i < numVerts; i++)
{
int index = i * 3;
const float *pos = data->normals.ptr + index;
int index = i * 3;
const float *pos = data->normals.ptr + index;
Ogre::Vector3 original = Ogre::Vector3(*pos ,*(pos+1), *(pos+2));
original = rotation * original;
if (mNormaliseNormals)
{
original.normalise();
}
if (mNormaliseNormals)
{
original.normalise();
}
datamod[index] = original.x;
@ -445,8 +442,6 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
if (data->uvlist.length)
{
decl->addElement(nextBuf, 0, VET_FLOAT2, VES_TEXTURE_COORDINATES);
vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT2),
@ -456,7 +451,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
{
float *datamod = new float[data->uvlist.length];
for(int i = 0; i < data->uvlist.length; i+=2){
for(unsigned int i = 0; i < data->uvlist.length; i+=2){
float x = *(data->uvlist.ptr + i);
float y = *(data->uvlist.ptr + i + 1);
@ -739,7 +734,6 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
Nif::NiTriShapeCopy copy = shape->clone();
if(!shape->controller.empty())
{
//Nif::NiGeomMorpherController* cont = dynamic_cast<Nif::NiGeomMorpherController*> (shape->controller.getPtr());
Nif::Controller* cont = shape->controller.getPtr();
if(cont->recType == RC_NiGeomMorpherController)
{
@ -747,25 +741,17 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
copy.morph = morph->data.get();
copy.morph.setStartTime(morph->timeStart);
copy.morph.setStopTime(morph->timeStop);
//std::cout << "Size" << morph->data->getInitialVertices().size() << "\n";
}
//std::cout << "We have a controller";
}
//use niskindata for the position of vertices.
if (!shape->skin.empty())
{
//std::cout << "Skin is not empty\n";
//Bone assignments are stored in submeshes, so we don't need to copy them
//std::string triname
//std::vector<Ogre::Vector3> vertices;
//std::vector<Ogre::Vector3> normals;
//std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfo;
// vector that stores if the position if a vertex is absolute
// vector that stores if the position of a vertex is absolute
std::vector<bool> vertexPosAbsolut(numVerts,false);
std::vector<Ogre::Vector3> vertexPosOriginal(numVerts, Ogre::Vector3::ZERO);
std::vector<Ogre::Vector3> vertexNormalOriginal(numVerts, Ogre::Vector3::ZERO);
@ -967,8 +953,6 @@ void NIFLoader::calculateTransform()
void NIFLoader::handleNode(Nif::Node *node, int flags,
const Transformation *trafo, BoundsFinder &bounds, Ogre::Bone *parentBone, std::vector<std::string> boneSequence)
{
//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;
@ -1000,33 +984,23 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
if (e->recType == RC_NiTextKeyExtraData){
Nif::NiTextKeyExtraData* extra = dynamic_cast<Nif::NiTextKeyExtraData*> (e);
std::vector<Nif::NiTextKeyExtraData::TextKey>::iterator textiter = extra->list.begin();
//std::ofstream File("Indices" + name + ".txt");
//std::string sample = "uy";
std::string cut = "";
for(int i = 0; i < name.length(); i++)
for(unsigned int i = 0; i < name.length(); i++)
{
if(!(name.at(i) == '\\' || name.at(i) == '/' || name.at(i) == '>' || name.at(i) == '<' || name.at(i) == '?' || name.at(i) == '*' || name.at(i) == '|' || name.at(i) == ':' || name.at(i) == '"'))
{
cut += name.at(i);
}
}
//std::cout << "End" << end;
std::cout << "Outputting " << cut << "\n";
std::ofstream file(("Indices" + cut + ".txt").c_str());
/*if(File.is_open())
std::cout << "We could open\n";
else
std::cout << "We could not\n";*/
for(; textiter != extra->list.end(); textiter++)
for(std::vector<Nif::NiTextKeyExtraData::TextKey>::iterator textiter = extra->list.begin(); textiter != extra->list.end(); textiter++)
{
//if(textiter->text.toString().find("Torch") < textiter->text.toString().length())
//std::cout << "Time: " << textiter->time << " " << textiter->text.toString() << "\n";
std::string text = textiter->text.toString();
replace(text.begin(), text.end(), '\n', '/');
@ -1050,20 +1024,13 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
{
mSkel = SkeletonManager::getSingleton().create(getSkeletonName(), resourceGroup, true);
/*if (node->extra->recType == RC_NiTextKeyExtraData )
{
//TODO: Get animation names
std::cout << node->name.toString() << " is root bone and has textkeyextradata!\n";
}*/
}
if (!mSkel.isNull()) //if there is a skeleton
{
std::string name = node->name.toString();
boneSequence.push_back(name);
//if (isBeast && isChest)
// std::cout << "NAME: " << name << "\n";
// Quick-n-dirty workaround for the fact that several
// bones may have the same name.
if(!mSkel->hasBone(name))
@ -1281,8 +1248,6 @@ void NIFLoader::loadResource(Resource *resource)
mesh->_setBoundingSphereRadius(bounds.getRadius());
}
if(hasAnim && addAnim){
//std::cout << "Lower" << lowername << "\n";
//std::cout << "Adding the animations\n";
allanimmap[name] = allanim;
alltextmappings[name] = textmappings;
}
@ -1300,7 +1265,6 @@ void NIFLoader::loadResource(Resource *resource)
{
mesh->_notifySkeleton(mSkel);
}
flip = false;
}
void NIFLoader::addInMesh(Ogre::Mesh* input){
@ -1364,242 +1328,7 @@ float NIFLoader::getTime(std::string filename, std::string text){
return -10000000.0;
}
/*
void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input)
{
/*if(addin)
{
std::cout << "InsideBase:" << addin->getName() << "\n";
}*/
/*
if(input)
{
std::vector<Nif::NiTriShapeCopy> shapes = NIFLoader::getSingletonPtr()->getShapes(input->getName());
for(int i = 0; i < shapes.size(); i++){
//std::cout << "Shapes" << shapes[i].sname;
Ogre::SubMesh* sub = input->getSubMesh(shapes[i].sname);
Ogre::SubMesh* subNew = mesh->createSubMesh(shapes[i].sname);
int nextBuf = 0;
//----------------------------------------VERTICES----------------------------------------
int numVerts = shapes[i].vertices.size();
subNew->vertexData = new VertexData();
subNew->vertexData->vertexCount = numVerts;
subNew->useSharedVertices = false;
//-----------------------------------------POSITIONS---------------------------------------
VertexDeclaration *decl = subNew->vertexData->vertexDeclaration;
const VertexElement* position =
sub->vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf;
HardwareVertexBufferSharedPtr newvbuf;
float* pRealNormal = new float[numVerts * 3];
VertexBufferBinding* bind;
//std::cout << "X " << pReal[0] << "Y " << pReal[1] << "Z" << pReal[2] << "\n";
float* pReal = new float[numVerts * 3];
std::map<unsigned int, bool> vertices;
std::map<unsigned int, bool> normals;
std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfovector = shapes[i].boneinfo;
//std::cout << "Name " << copy.sname << "\n";
if(boneinfovector.size() > 0){
for (int j = 0; j < boneinfovector.size(); j++)
{
Nif::NiSkinData::BoneInfoCopy boneinfo = boneinfovector[j];
Ogre::Bone *bonePtr = mSkel->getBone(boneinfo.bonename);
Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfo.trafo.trans;
Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfo.trafo.rotation;
//std::cout << "Bone" << bonePtr->getName() << "\n";
for (unsigned int k=0; k< boneinfo.weights.size(); k++)
{
unsigned int verIndex = boneinfo.weights[k].vertex;
if(vertices.find(verIndex) == vertices.end())
{
Ogre::Vector3 absVertPos = vecPos + vecRot * shapes[i].vertices[verIndex];
vertices[verIndex] = true;
absVertPos = absVertPos * boneinfo.weights[k].weight;
Ogre::Real* addr = (pReal + 3 * verIndex);
*addr = absVertPos.x;
*(addr+1) = absVertPos.y;
*(addr+2) = absVertPos.z;
//std::cout << "Vertex" << vertices[verIndex] << "\n";
}
else
{
Ogre::Vector3 absVertPos = vecPos + vecRot * shapes[i].vertices[verIndex];
absVertPos = absVertPos * boneinfo.weights[k].weight;
Ogre::Vector3 old = Ogre::Vector3(pReal + 3 * verIndex);
absVertPos = absVertPos + old;
Ogre::Real* addr = (pReal + 3 * verIndex);
*addr = absVertPos.x;
*(addr+1) = absVertPos.y;
*(addr+2) = absVertPos.z;
}
if(normals.find(verIndex) == normals.end())
{
Ogre::Vector3 absNormalsPos = vecRot * shapes[i].normals[verIndex];
absNormalsPos = absNormalsPos * boneinfo.weights[k].weight;
normals[verIndex] = true;
Ogre::Real* addr = (pRealNormal + 3 * verIndex);
*addr = absNormalsPos.x;
*(addr+1) = absNormalsPos.y;
*(addr+2) = absNormalsPos.z;
}
else{
Ogre::Vector3 absNormalsPos = vecRot * shapes[i].normals[verIndex];
absNormalsPos = absNormalsPos * boneinfo.weights[k].weight;
Ogre::Vector3 old = Ogre::Vector3(pRealNormal + 3 * verIndex);
absNormalsPos = absNormalsPos + old;
Ogre::Real* addr = (pRealNormal + 3 * verIndex);
*addr = absNormalsPos.x;
*(addr+1) = absNormalsPos.y;
*(addr+2) = absNormalsPos.z;
}
}
/*
std::cout << "TransformRot:" << boneinfo.trafo.rotation << "TransformTrans:" << boneinfo.trafo.trans << "\n";
std::vector<Nif::NiSkinData::VertWeight> weights = boneinfo.weights;
for (int j = 0; j < weights.size(); j++){
std::cout << "Vertex: " << weights[j].vertex << " Weight: " << weights[j].weight << "\n";
}*/
/*}
}
if(position){
decl->addElement(nextBuf, 0, VET_FLOAT3, VES_POSITION);
newvbuf =
HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT3),
numVerts, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
newvbuf->writeData(0, newvbuf->getSizeInBytes(), pReal, false);
bind = subNew->vertexData->vertexBufferBinding;
bind->setBinding(nextBuf++, newvbuf);
}
//----------------------------------------NORMALS-------------------------------------------
const VertexElement* normal =
sub->vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_NORMAL);
if(normal)
{
decl->addElement(nextBuf, 0, VET_FLOAT3, VES_NORMAL);
newvbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT3),
numVerts, HardwareBuffer::HBU_DYNAMIC);
newvbuf->writeData(0, newvbuf->getSizeInBytes(), pRealNormal, false);
bind->setBinding(nextBuf++, newvbuf);
}
//--------------------------------------COLORS--------------------------------------------
const VertexElement* color =
sub->vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_DIFFUSE);
if(color)
{
decl->addElement(nextBuf, 0, VET_COLOUR, VES_DIFFUSE);
vbuf = sub->vertexData->vertexBufferBinding->getBuffer(color->getSource());
newvbuf = vbuf;
//RGBA* pReal2 = static_cast<RGBA*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
//newvbuf->writeData(0, vbuf->getSizeInBytes(), pReal2, false);
//vbuf->unlock();
bind->setBinding(nextBuf++, newvbuf);
}
//-------------------------------------TEXTURES-------------------------------------------
const VertexElement* text =
sub->vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_TEXTURE_COORDINATES);
if(text){
vbuf = sub->vertexData->vertexBufferBinding->getBuffer(text->getSource());
decl->addElement(nextBuf, 0, VET_FLOAT2, VES_TEXTURE_COORDINATES);
newvbuf = vbuf;
//float* pRealf = static_cast<float*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
//std::cout << "SIze" << vbuf->getSizeInBytes();
// newvbuf->writeData(0, vbuf->getSizeInBytes(), pRealf, false);
//vbuf->unlock();
bind->setBinding(nextBuf++, newvbuf);
}
//----------------------------------INDEX DATA--------------------------------------
int numFaces = sub->indexData->indexCount;
subNew->indexData->indexCount = numFaces;
subNew->indexData->indexStart = 0;
HardwareIndexBufferSharedPtr ibuf = sub->indexData->indexBuffer;
HardwareIndexBufferSharedPtr ibufNew = ibuf;
//uint16* tri = static_cast<uint16*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
//ibufNew->writeData(0, ibuf->getSizeInBytes(), tri, false);
subNew->indexData->indexBuffer = ibufNew;
//ibuf->unlock();
if (!sub->getMaterialName().empty()){
subNew->setMaterialName(sub->getMaterialName());
}
//Ogre::SubMesh::VertexBoneAssignmentList bonelist = sub->getBoneAssignments();
/*
Ogre::VertexBoneAssignment assign;
assign.boneIndex = 0;
assign.vertexIndex = 0;
assign.weight = 1.0;
subNew->addBoneAssignment(assign);*/
/*
Ogre::SubMesh::BoneAssignmentIterator boneiter = sub->getBoneAssignmentIterator();
while(boneiter.hasMoreElements())
{
subNew->addBoneAssignment(boneiter.current()->second);
boneiter.getNext();
}
subNew->addBoneAssignment(boneiter.current()->second);
}
}
}*/
/* More code currently not in use, from the old D source. This was

@ -45,8 +45,7 @@
#include <vector>
#include <list>
// For warning messages
#include <iostream>5
// float infinity
#include <iostream>
#include <limits>
using namespace boost::algorithm;

Loading…
Cancel
Save