Need some help with something I always struggle with... object creation, copying, independence.
Say I need multiple meshes displayed on the screen of the same object I've already loaded in to AssetManager with an Id of "Suzzane". If I want to push back onto a vector of static meshes, the following code works, but I run into a problem. The second "Suzzane" is just a pointer to the first Suzzane so if I say send a transform only to the second Suzzane, both objects get the transform.
How would you correctly make an independent copy of a object stored in the AssetManager without reading in an .Obj file again.
Here is what I have that I've been messing around with for a couple hours now and I have a feeling the answer is something extremely easy and elegant... just stumped. Additionally it was wierd being forced to dynamic_cast the return from AssetStorage->GetAsset. GetAsset returns a base object, but it wouldn't let me store that in a vector of derived class without the dynamic cast.
// Meshes is a std::vector<FStaticMesh*>
// Testing obj file reader and rendering a 3d model
FONEFileReader* File = ONE_NEW FONEFileReader(TEXT("Assets/suzanne.one"));
// Second mesh is a box model (Seperate the creation of the two Suzzanne objects in the Mesh vector for testing)
File = ONE_NEW FONEFileReader(TEXT("Assets/box.one"));
// Second suzzane should go into same Batch3D as first Suzanne and utilize same loaded model data
FStaticMesh* Suzzane = dynamic_cast<FStaticMesh*>(AssetStorage->GetAsset(TEXT("Suzzane")));
I also tried the following, but I didn't have a FStaticMesh constructor that accepts a base object, is that what I need to create?
FStaticMesh* Suzzane = ONE_NEW FStaticMesh(AssetStorage->GetAsset(TEXT("Suzzane")));
Thanks in advance for any help.