Does CopyEntity create additional geometry?
Blitz3D Forums/Blitz3D Beginners Area/Does CopyEntity create additional geometry?
| ||
I'm trying to figure out if I'm doing the right thing for my 3D puzzle game at the moment. I start off by loading all the different objects and using 'Hideentity' on them as soon as they load, so they're not visible. Then I have an array of entities that I use CopyEntity to depending upon the classification of the tile. For example: For x = 0 To 10 For y = 0 To 10 Select level(x,y)\tileinfo Case 0 mytile(x,y) = CopyEntity(globe) Case 1 mytile(x,y) = CopyEntity(figure) Case 2 mytile(x,y) = CopyEntity(statue) End Select Next Next My question is whether or not my CopyEntity is creating a lot of extra geometry, or is it an instance of the same data? Am I taking the right approach to this? |
| ||
I do everything like this also so AFAIK it's the right approach. This method produced instances of the original mesh. |
| ||
When you create or load new meshes, you get something like this.mesh entity pawn.b3d <--blackpawn1 pawn.b3d <--blackpawn2 pawn.b3d <--blackpawn3 ... pawn.b3d <--whitepawn7 pawn.b3d <--whitepawn8 As you can see, the mesh "Pawn.b3d" is stored in memory several times with each entity pointing to a seperate one. This takes up extra memory as well as slow things down. Using CopyEntity, you get this mesh entity pawn.b3d <--blackpawn1 ^ |-------blackpawn2 |-------blackpawn3 |-------blackpawn4 ... All entities point to the same mesh. You can call Entity commands on each entity just like before, ScaleEntity, RotateEntity, EntityColor, etc... However, anything that happens to the mesh itself occurs to all the entities pointing to it, ScaleMesh, RotateMesh, VetexColor, etc... |
| ||
Ah - excellent explanation, that's great to know what I'm doing is correct. Okay, another question then! ^_^ Is there any way to make a CopyEntity Entity 'unique' without loading in the B3D file again? |
| ||
Copymesh will do this - but as Tom says you'll be using additional memory to hold the new mesh. |
| ||
Ah perfect. Yep, don't worry I'll avoid using copymesh, but it's good to know how I can do that. Thanks! |
| ||
I'd like to check my understanding of the above. As I understand it entities are instances of meshes (or of whatever they're instances of) and don't have to store all the information the original mesh stores. Is that correct? |