Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Preloading models  (Read 410 times)
Canning
Community Member
*
Posts: 592


« on: September 21, 2011, 05:27:22 AM »

I am after a little advice on something.

In my game,I am using quite a few 3d models. Currently, when I create a new 'enemy', I load a new model for it. I am wanting to preload the required models at the start of my game. I am thinking that i will create an array of them (an array of meshes) and when I create a new enemy, I will point its model to one that I have preloaded.

What is the code to do this? Is it just a simple 'Player(x).mesh = PreloadedMesh(1)', or do I use the clone method?

I am after the fastest way, most efficient way to do this.

thanks
« Last Edit: September 21, 2011, 05:50:38 AM by Canning » Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
leghola
Customers
Community Member
*****
Posts: 45


« Reply #1 on: September 21, 2011, 09:22:06 AM »

In my project i have 2 class

First a MainMeshCollection without clone and all meshes with the enable status to false.
Secondly a InstanceMeshCollection that accept ALL mesh that could be viewed

When i load/update my scene, i search which mesh i must create. If i need to create a mesh then :
1. i search the mesh in the MainMeshCollection

1a. Search Ok : i create a new instance in the InstanceMeshCollection like this :
InstanceMeshCollection.mesh = MainMeshCollection.mesh.duplicate

1b. Search No Ok : i create this mesh in the MainMeshCollection and go to 1a.

Nico
Logged

i prefers live one day like a lion instead of one life like a dog...
Canning
Community Member
*
Posts: 592


« Reply #2 on: September 23, 2011, 01:07:39 AM »

So the .duplicate method creates a copy of the mesh and is assigned to another mesh?

How much faster is this than loading a mesh from scratch?
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
leghola
Customers
Community Member
*****
Posts: 45


« Reply #3 on: September 23, 2011, 04:50:59 AM »

Hi,

If you use load mesh, you create an access to the hard disk... It's bad.
If you use Duplicate, the mesh is loaded from HDD one time and after it's in memory, it's better, it's faster ! Smiley

Nico ! Smiley
Logged

i prefers live one day like a lion instead of one life like a dog...
Canning
Community Member
*
Posts: 592


« Reply #4 on: September 23, 2011, 07:16:28 AM »

K, cool. Smiley
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks