It is currently Sun May 28, 2017 8:53 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 4 posts ] 
Author Message
 Post subject: Shader VMK 37 - Asset Storage Class
PostPosted: Thu Jan 30, 2014 8:25 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In this VMK I introduce a new singleton class called AssetStorage that is used to manage all the game assets that are loaded by the engine.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 37 - Asset Storage Class
PostPosted: Wed Feb 05, 2014 5:45 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
I completed this a couple of days ago, very simple class.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 37 - Asset Storage Class
PostPosted: Tue Oct 21, 2014 9:11 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Hey Everyone,

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
ShaderManager->Enable(STATIC_MESH);
FONEFileReader* File = ONE_NEW FONEFileReader(TEXT("Assets/suzanne.one"));
Meshes.push_back(File->GetONE<FStaticMesh>(TEXT("Suzzane")));

// 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"));
Meshes.push_back(File->GetONE<FStaticMesh>());

// 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")));
Meshes.push_back(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")));
Meshes.push_back(Suzzane);


Thanks in advance for any help.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 37 - Asset Storage Class
PostPosted: Thu Oct 23, 2014 10:00 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
if you want to share the loaded vertices, then what you need to do is abstract out your transformation matrix so that you can have two instances that use different transformation, but they both use the same set of vertices.

I'm uploading my solution to challenge #4 right now, so you can follow the same sort of thing that is done there.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron