Looping through entities

Blitz3D Forums/Blitz3D Programming/Looping through entities

Mr Snidesmin(Posted 2006) [#1]
1. What's the easiest way to cycle through all blitz 3d entities?

2. Do I have to create my own entity management system to do this?

3. If I need to create an entity management system would I be better off using types or arrays?


OJay(Posted 2006) [#2]
1. see 2.
2. yes
3. types

any questions left? =)


Ross C(Posted 2006) [#3]
Yea, i think it's essential in a game, to manage the entities within some sort of system. Types are probably easiest, but array's have there use too :o)


Mr Snidesmin(Posted 2006) [#4]
As I figured i spose ah well.

As for types vs arrays. . . The environment is likely to be quite dynamic (lots of entity creation and deletion)

With this in mind would it be faster to use arrays or types?

Types would be good for convience (ie i wouldn't have to search for a free space in an array if i need to create something)

Also if i needed to i could add extra info in the types.

If the difference in the speed of using either was negligable then i would probably go with types.


Beaker(Posted 2006) [#5]
You can avoid all the data structures like this:
Graphics3D 640,480
SetBuffer BackBuffer()

world = CreatePivot()
For f = 1 To 20
	temp = CreateCube(world)
	NameEntity temp,"Cube"+f
Next

If CountChildren(world)>0
	For childcnt = 1 To CountChildren(world)
		DebugLog EntityName(GetChild(world,childcnt))
	Next
EndIf

Stop
End

But sometimes you will need a type/array.


Mr Snidesmin(Posted 2006) [#6]
Ah of course. That's a nice simple way of doing things. It will actually fit in quite nicely with the way I'm doing things. . .


caff_(Posted 2006) [#7]
I prefer types for their clarity, and they fit in nicely with Blitz3d's hierarchical entity-based concept thingy.


bytecode77(Posted 2006) [#8]
parenting is extra coding...
at best would be that marksibly would do this one.

cnt_ent = CountWorldEntities() - 1
For i = 0 To cnt_ent
    ent = GetWorldEntity(i)
    HideEntity(ent)
Next


i have this problem too, because my shadow lib needs to hide/show ALL entities...
so the user has to define each one of them, which is very crapy; if you are using particles, you have to create and delete shadow receivers(the particles) each loop. this is so boooooring!
everytime, somebody makes such suggestions to mark like this or commands like EntityRed(), he just ignores them...
why?


Stevie G(Posted 2006) [#9]
Devils Child,

I'm not sure this 'countworldentities' idea would work. What about entities you hide simply because you're using the mesh for instancing .. how would you differentiate between this and others?

Personally, I don't see you're issue with users defining meshes which should be used as shadow receivers. It wouldn't be a very versatile system if it assumed every world mesh should be a receiver.

Simply creating a shadow pivot and adding each shadow mesh to this at the receiver creation stage means you can hide the shadow pivot to hide the lot.

Is that such a chore?

Stevie


Beaker(Posted 2006) [#10]
There is actually a DLL (or two) out there that does CountWorldEntities(), EntityRed() and EntityHiddent() type commands. Don't think they are necessary for most things tho.


Mr Snidesmin(Posted 2006) [#11]
If all you needed to do was hide all entities then parenting would be good because HideEntity applies to all children. . .

You would only need to hide the parent world pivot then.


There is actually a DLL (or two) out there that does CountWorldEntities(),


Any idea on how these would actually work? Or where they can be found?


Beaker(Posted 2006) [#12]
Get started here: (no DLL to download tho)
http://www.blitzbasic.com/Community/posts.php?topic=34366


bytecode77(Posted 2006) [#13]
404...

but tom made a similar, very useful dll!
(included to the devilshadowsystem; you know where to get it!)


Ricky Smith(Posted 2006) [#14]
Blitz arrays are very useful, the arrays with the square brackets as they can be used as type fields. I generally use a combination of types containing Blitz arrays for entity management. You can also store the type handles in a standard array to create a list of types for fast access.
The undocumented Object and Handle commands are also very useful for type management.
A combination of both types and arrays is the best way