Convert b3d to GE spm
This commit is contained in:
parent
92accb352e
commit
1bdeffc7ed
@ -5,6 +5,7 @@
|
||||
#include "graphics/b3d_mesh_loader.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/stk_tex_manager.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/mesh_tools.hpp"
|
||||
#include "graphics/sp/sp_animation.hpp"
|
||||
@ -18,6 +19,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
#include <ge_main.hpp>
|
||||
#include <ge_spm_buffer.hpp>
|
||||
#include <ge_spm.hpp>
|
||||
#endif
|
||||
|
||||
int B3DMeshLoader::m_straight_frame = 0;
|
||||
|
||||
#undef _B3D_READER_DEBUG
|
||||
@ -76,7 +83,8 @@ scene::IAnimatedMesh* B3DMeshLoader::createMesh(io::IReadFile* f)
|
||||
}
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
if (CVS->isGLSL())
|
||||
bool convert_spm = CVS->isGLSL() || GE::getVKDriver() != NULL;
|
||||
if (convert_spm)
|
||||
{
|
||||
if (!AnimatedMesh)
|
||||
{
|
||||
@ -86,9 +94,31 @@ scene::IAnimatedMesh* B3DMeshLoader::createMesh(io::IReadFile* f)
|
||||
SP::SPMesh* spm = toSPM(static_cast<scene::CSkinnedMesh*>
|
||||
(AnimatedMesh->getMesh(m_straight_frame)));
|
||||
m_texture_string.clear();
|
||||
if (CVS->isGLSL())
|
||||
{
|
||||
spm->finalize();
|
||||
spm->setMinMax(min.toIrrVector(), max.toIrrVector());
|
||||
return spm;
|
||||
}
|
||||
GE::GESPM* ge_spm = new GE::GESPM();
|
||||
for (unsigned i = 0; i < spm->getMeshBufferCount(); i++)
|
||||
{
|
||||
SP::SPMeshBuffer* spbuf = spm->getSPMeshBuffer(i);
|
||||
GE::GESPMBuffer* gebuf = new GE::GESPMBuffer();
|
||||
ge_spm->m_buffer.push_back(gebuf);
|
||||
std::swap(gebuf->m_vertices, spbuf->getVerticesRef());
|
||||
std::swap(gebuf->m_indices, spbuf->getIndicesRef());
|
||||
Material* stk_material = spbuf->getSTKMaterial(0);
|
||||
stk_material->setMaterialProperties(&gebuf->getMaterial(), gebuf);
|
||||
gebuf->getMaterial().TextureLayer[0].Texture =
|
||||
stk_material->getTexture();
|
||||
gebuf->recalculateBoundingBox();
|
||||
}
|
||||
ge_spm->finalize();
|
||||
ge_spm->setMinMax(min.toIrrVector(), max.toIrrVector());
|
||||
spm->drop();
|
||||
return ge_spm;
|
||||
}
|
||||
#endif
|
||||
|
||||
return AnimatedMesh;
|
||||
@ -255,7 +285,6 @@ SP::SPMesh* B3DMeshLoader::toSPM(scene::CSkinnedMesh* mesh)
|
||||
}
|
||||
}
|
||||
|
||||
spm->finalize();
|
||||
mesh->drop();
|
||||
return spm;
|
||||
}
|
||||
@ -1311,7 +1340,8 @@ void B3DMeshLoader::loadTextures(SB3dMaterial& material, scene::IMeshBuffer* mb)
|
||||
full_path = fs->getFileBasename(B3dTexture->TextureName);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
if (CVS->isGLSL())
|
||||
bool convert_spm = CVS->isGLSL() || GE::getVKDriver() != NULL;
|
||||
if (convert_spm)
|
||||
{
|
||||
auto& ret = m_texture_string[mb];
|
||||
if (i == 0)
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <set>
|
||||
#ifndef SERVER_ONLY
|
||||
#include <ge_main.hpp>
|
||||
#endif
|
||||
|
||||
namespace SP
|
||||
{
|
||||
@ -471,6 +474,11 @@ void SPMeshBuffer::reloadTextureCompare()
|
||||
void SPMeshBuffer::setSTKMaterial(Material* m)
|
||||
{
|
||||
m_stk_material[0] = std::make_tuple(0u, getIndexCount(), m);
|
||||
#ifndef SERVER_ONLY
|
||||
// Used by b3d mesh loader, clean up later after SP is removed
|
||||
if (GE::getVKDriver() != NULL)
|
||||
return;
|
||||
#endif
|
||||
const std::string shader_name =
|
||||
std::get<2>(m_stk_material[0])->getShaderName();
|
||||
const std::string skinned_shader_name =
|
||||
|
@ -308,6 +308,11 @@ public:
|
||||
return m_vertices.data();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<video::S3DVertexSkinnedMesh>& getVerticesRef()
|
||||
{
|
||||
return m_vertices;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual u32 getVertexCount() const
|
||||
{
|
||||
return (unsigned)m_vertices.size();
|
||||
@ -318,6 +323,11 @@ public:
|
||||
return video::EIT_16BIT;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<u16>& getIndicesRef()
|
||||
{
|
||||
return m_indices;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return m_indices.data();
|
||||
|
@ -1245,13 +1245,18 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
"Main track model '%s' in '%s' not found, aborting.\n",
|
||||
track_node->getName().c_str(), model_name.c_str());
|
||||
}
|
||||
scene::IAnimatedMesh* an_mesh = dynamic_cast<scene::IAnimatedMesh*>(mesh);
|
||||
bool ge_spm = false;
|
||||
if (an_mesh && an_mesh->getMeshType() == scene::EAMT_SPM)
|
||||
ge_spm = true;
|
||||
|
||||
scene::ISceneNode* scene_node = NULL;
|
||||
scene::IMesh* tangent_mesh = NULL;
|
||||
#ifdef SERVER_ONLY
|
||||
if (false)
|
||||
#else
|
||||
if (m_version < 7 && !CVS->isGLSL() && !GUIEngine::isNoGraphics())
|
||||
if (m_version < 7 && !CVS->isGLSL() && !GUIEngine::isNoGraphics() &&
|
||||
!ge_spm)
|
||||
#endif
|
||||
{
|
||||
// The mesh as returned does not have all mesh buffers with the same
|
||||
|
Loading…
Reference in New Issue
Block a user