|
|
|
@ -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
|
|
|
|
|