96 tempBuffer <<
_ID(
"BufferEntryPoint");
97 tempBuffer << _modelName;
98 tempBuffer << _modelPath;
106 if (!subMesh.serialize(tempBuffer))
129 tempBuffer >> tempVer;
133 tempBuffer >> signature;
134 if (signature !=
_ID(
"BufferEntryPoint"))
139 tempBuffer >> _modelName;
140 tempBuffer >> _modelPath;
144 vbDescriptor.
_name = _modelName;
145 vbDescriptor._allowDynamicUpdates =
false;
146 vbDescriptor._keepCPUData =
true;
147 vbDescriptor._largeIndices =
true;
152 U32 subMeshCount = 0;
153 tempBuffer >> subMeshCount;
157 if (!subMesh.deserialize(tempBuffer))
170 _loadedFromFile =
true;
183 dataOut << _boneCount;
184 dataOut << _lodCount;
188 dataOut << _worldOffset;
201 dataIn >> _boneCount;
206 dataIn >> _worldOffset;
217 dataOut << _ignoreTexDiffuseAlpha;
218 dataOut << _doubleSided;
220 dataOut <<
to_U32(_shadingMode);
221 dataOut <<
to_U32(_bumpMethod);
222 dataOut << baseColour();
223 dataOut << emissive();
224 dataOut << ambient();
225 dataOut << specular();
226 dataOut << specGloss();
232 if (!texture.serialize(dataOut))
250 dataIn >> _ignoreTexDiffuseAlpha;
251 dataIn >> _doubleSided;
253 dataIn >> temp; _shadingMode =
static_cast<ShadingMode>(temp);
254 dataIn >> temp; _bumpMethod =
static_cast<BumpMethod>(temp);
255 dataIn >> tempColourRGBA; baseColour(tempColourRGBA);
256 dataIn >> tempColourRGB; emissive(tempColourRGB);
257 dataIn >> tempColourRGB; ambient(tempColourRGB);
258 dataIn >> tempColourRGBA; specular(tempColourRGBA);
259 dataIn >> tempSG; specGloss(tempSG);
260 dataIn >> temp2; metallic(temp2);
261 dataIn >> temp2; roughness(temp2);
262 dataIn >> temp2; parallaxFactor(temp2);
265 if (!texture.deserialize(dataIn))
277 dataOut << _textureName;
278 dataOut << _texturePath;
280 dataOut << _useDDSCache;
281 dataOut << _isNormalMap;
282 dataOut << _alphaForTransparency;
283 dataOut <<
to_U32(_wrapU);
284 dataOut <<
to_U32(_wrapV);
285 dataOut <<
to_U32(_wrapW);
286 dataOut <<
to_U32(_operation);
293 dataIn >> _textureName;
294 dataIn >> _texturePath;
296 dataIn >> _useDDSCache;
297 dataIn >> _isNormalMap;
298 dataIn >> _alphaForTransparency;
299 dataIn >> data; _wrapU =
static_cast<TextureWrap>(data);
300 dataIn >> data; _wrapV =
static_cast<TextureWrap>(data);
301 dataIn >> data; _wrapW =
static_cast<TextureWrap>(data);
311 bool success =
false;
314 !dataOut.
loadFromFile( context, Paths::g_geometryCacheLocation, dataOut.modelName() ) )
320 if (dataOut.
saveToFile(context, Paths::g_geometryCacheLocation, dataOut.modelName()))
334 dataOut.fromFile(
true);
341 Time::MicrosecondsToMilliseconds<F32>(importTimer.
get()));
356 mesh->renderState().drawState(
true);
360 std::atomic_uint taskCounter(0u);
364 const size_t boneCount = tempMeshData.
_animationCount > 0u ? subMeshData.boneCount() : 0u;
368 subMeshDescriptor.data(
377 SubMesh* tempSubMesh =
Get(tempSubMeshHandle);
379 if (!tempSubMesh->parentMesh())
384 for (
U8 lod = 0u, j = 0u; lod < subMeshData.lodCount(); ++lod)
388 tempSubMesh->setGeometryPartitionID(j, subMeshData.
_partitionIDs[j]);
396 if (tempSubMesh->getMaterialTpl() != INVALID_HANDLE<Material>)
413 const string saveFileName =
Util::StringFormat(
"{}.{}", tempMeshData.modelName(), g_parsedAssetAnimationExt );
414 if (tempBuffer.
loadFromFile(Paths::g_geometryCacheLocation, saveFileName ))
416 animator->
load(context, tempBuffer);
420 if (!tempMeshData.loadedFromFile())
426 animator->
save(context, tempBuffer);
427 if (!tempBuffer.
dumpToFile(Paths::g_geometryCacheLocation, saveFileName ))
445 tempMeshData.modelName(),
446 Time::MicrosecondsToMilliseconds<F32>(importTimer.
get()));
448 return mesh->load( context );
454 bool wasInCache =
false;
458 return tempMaterialHandle;
463 if (!loadedFromCache)
465 tempMaterial->ignoreXMLData(
true);
468 tempMaterial->properties().hardwareSkinning(skinned);
469 tempMaterial->properties().emissive(importData.emissive());
470 tempMaterial->properties().ambient(importData.ambient());
471 tempMaterial->properties().specular(importData.specular().rgb);
472 tempMaterial->properties().shininess(importData.specular().a);
473 tempMaterial->properties().specGloss(importData.specGloss());
474 tempMaterial->properties().metallic(importData.metallic());
475 tempMaterial->properties().roughness(importData.roughness());
476 tempMaterial->properties().parallaxFactor(importData.parallaxFactor());
478 tempMaterial->properties().baseColour(importData.baseColour());
479 tempMaterial->properties().ignoreTexDiffuseAlpha(importData.ignoreTexDiffuseAlpha());
480 tempMaterial->properties().shadingMode(importData.shadingMode());
481 tempMaterial->properties().bumpMethod(importData.bumpMethod());
482 tempMaterial->properties().doubleSided(importData.doubleSided());
494 if (!tex.textureName().empty())
496 textureSampler.
_wrapU = tex.wrapU();
497 textureSampler.
_wrapV = tex.wrapV();
498 textureSampler.
_wrapW = tex.wrapW();
505 textureDescriptor._textureOptions._useDDSCache = tex.useDDSCache();
506 textureDescriptor._textureOptions._isNormalMap = tex.isNormalMap();
507 textureDescriptor._textureOptions._alphaChannelTransparency = tex.alphaForTransparency();
510 texture.assetName(tex.textureName());
511 texture.assetLocation(tex.texturePath());
513 texture.waitForReady(
true);
515 tempMaterial->setTexture(
static_cast<TextureSlot>(i),
522 return tempMaterialHandle;
#define WAIT_FOR_CONDITION(...)
static void addSubMesh(Mesh &parentMesh, const Handle< SubMesh > subMesh, const U32 index)
static void setNodeData(Mesh &parentMesh, const MeshNodeData &nodeStructure)
static void registerAnimations(SceneAnimator &animator, const vector< AnimEvaluator * > &animations)
PASS OWNERSHIP OF ANIMATIONS TO THE ANIMATOR!!!
static void setParentMesh(SubMesh &subMesh, ResourcePtr< Mesh > parentMesh)
static void setBoundingBox(SubMesh &subMesh, const vec3< F32 > &min, const vec3< F32 > &max, const vec3< F32 > &worldOffset) noexcept
bool loadFromFile(const ResourcePath &path, std::string_view fileName, const U8 version=BUFFER_FORMAT_VERSION)
bool dumpToFile(const ResourcePath &path, std::string_view fileName, const U8 version=BUFFER_FORMAT_VERSION)
Saves the entire buffer contents to file. Always appends the version at the end of the file.
VertexBuffer_ptr newVB(const VertexBuffer::Descriptor &descriptor)
Create and return a new vertex array (VAO + VB + IB).
static bool loadMesh(PlatformContext &context, ResourcePtr< Mesh > mesh)
static Handle< Material > loadSubMeshMaterial(const Import::MaterialData &importData, bool loadedFromCache, bool skinned, std::atomic_uint &taskCounter)
Load the material for the current SubMesh.
static bool loadMeshDataFromFile(PlatformContext &context, Import::ImportData &dataOut)
GFXDevice & gfx() noexcept
Configuration & config() noexcept
bool init(PlatformContext &context, Bone *skeleton, const vector< Bone * > &bones)
This will build the skeleton based on the scene passed to it and CLEAR EVERYTHING.
void save(PlatformContext &context, ByteBuffer &dataOut) const
void load(PlatformContext &context, ByteBuffer &dataIn)
bool Load(PlatformContext &context, Import::ImportData &target)
Str StringFormat(const char *fmt, Args &&...args)
bool CompareIgnoreCase(const char *a, const char *b) noexcept
const char * g_parsedAssetAnimationExt
const char * g_parsedAssetGeometryExt
Handle console commands that start with a forward slash.
constexpr U32 to_U32(const T value)
GeometryFormat GetGeometryFormatForExtension(const char *extension) noexcept
constexpr U16 BYTE_BUFFER_VERSION
TextureOperation
How should each texture be added.
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
FORCE_INLINE T * Get(const Handle< T > handle)
::value constexpr T CLAMPED_01(T n) noexcept
constexpr auto to_base(const Type value) -> Type
struct Divide::Configuration::Debug::Cache cache
struct Divide::Configuration::Debug debug
static NO_INLINE void d_printfn(const char *format, T &&... args)
static NO_INLINE void printfn(const char *format, T &&... args)
VertexBuffer_ptr _vertexBuffer
vector< SubMeshData > _subMeshData
Divide::MeshNodeData _nodeData
bool loadFromFile(PlatformContext &context, const ResourcePath &path, std::string_view fileName)
vector< AnimEvaluator * > _animations
bool saveToFile(PlatformContext &context, const ResourcePath &path, std::string_view fileName)
bool deserialize(ByteBuffer &dataIn)
bool serialize(ByteBuffer &dataOut) const
std::array< TextureEntry, to_base(TextureSlot::COUNT)> _textures
vector< vec3< U32 > > _triangles[MAX_LOD_LEVELS]
std::array< U16, MAX_LOD_LEVELS > _partitionIDs
bool serialize(ByteBuffer &dataOut) const
bool deserialize(ByteBuffer &dataIn)
bool serialize(ByteBuffer &dataOut) const
bool deserialize(ByteBuffer &dataIn)
bool deserialize(ByteBuffer &dataIn)
bool serialize(ByteBuffer &dataOut) const
TextureWrap _wrapU
Texture wrap mode (Or S-R-T)