|
Getting view entities...
#338857
08/22/10 09:11
08/22/10 09:11
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Hi folks, I didn't work with view entities a long time, maybe I am doing something terribly wrong. I have a static mesh level and one static view entity which is my sky entity. What I want to do is to get this entity after loading the level:
ENTITY* entSkycube =
{
type = "skycube+6.tga";
flags = UNLIT;
flags2 = SKY | CUBE | SHOW;
}
int main ()
{
//...
level_load("test_0001.wmb");
//...
int ents = 0;
ENTITY* ent = ptr_first(level_ent);
while (ent)
{
ents++;
ent = ent.link.next;
}
printf("ents = %d", ents);
//out: "ents = 0"
}
But all I get are 0 entities... how do I access the list of static entities here? Bye, -Chris
|
|
|
Re: Getting view entities...
[Re: HeelX]
#338859
08/22/10 09:23
08/22/10 09:23
|
Joined: Mar 2010
Posts: 57 Germany, Niedersachsen
LemmyTheSlayer
Junior Member
|
Junior Member
Joined: Mar 2010
Posts: 57
Germany, Niedersachsen
|
try the ent_next function.
ENTITY* ent = ent_next(NULL); while (ent) { ents++; ent = ent_next(ent); }
SCHLEIFE SCHLEIFE SCHLEIFE SCHLEIFE SCHLEIFE SCHLEIFE
|
|
|
Re: Getting view entities...
[Re: HeelX]
#338914
08/22/10 17:53
08/22/10 17:53
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
i gues its removed because of level_load
just try to create a entity by ent_createlayer after te level_load
(maby even a wait(1); after it)
"empty"
|
|
|
Re: Getting view entities...
[Re: flits]
#338920
08/22/10 18:52
08/22/10 18:52
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
HeelX, ptr_first is not for ALL entities, it is for ALL objects OF THE SAME TYPE... Take a look in the manual at the "handle" entry, and you'll see there are three 'different' types of entity. 'lobal', 'local', and 'layer'. So if you wantr to find all "layer" entities (a view-entity), then you will need to 'prime' the ptr-first function with another view-entiy. You aren't, you are priming it with the "level_ent" whis is not a view-entity. Try this instead (untested)....
...
int ents = 0;
ENTITY* seed = ent_createlocal(CUBE_MDL, nullvector, NULL);
ENTITY* ent = ptr_first(seed);
while (ent)
{
if(ent != seed) //dont count the seed-entity
{ ents++; }
ent = ent.link.next;
}
ent_remove(seed);
printf("ents = %d", ents);
//out: "ents = 0"
...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Getting view entities...
[Re: EvilSOB]
#338960
08/23/10 08:18
08/23/10 08:18
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Ha, that shall be the trick? Thanks! Unfortunately the manual says Returns a pointer to the first object for a given engine object. Parameters: object - ENTITY*, STRING*, BMAP*, VIEW*, PANEL*, TEXT*, FONT*, SOUND*, or MATERIAL* pointer. So I expected that if I pass an entity, I get all entities. Didn't knew that the function differentiates between global, local and view entities... :-( I test it out today and give feedback here! I hope it works
|
|
|
Re: Getting view entities...
[Re: HeelX]
#338963
08/23/10 09:36
08/23/10 09:36
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I hope it helps, as it is only an educated guess that ptr_first DOES differentiate.
It my conclusion it will because your flow is like so... A> ptr_first is retrieves the first object of a given type. B> then you step through using ent.link.next
Now, seeing as the "link" data in any object is primarily its handle, then anything else in the link data will "most likely" recognise the same types.
So ... if you are stepping through the "handles", and the handle function sees a difference between the three entity types, then ptr_first PROBABLY does too.
That the logic I followed anyways...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Getting view entities...
[Re: EvilSOB]
#339007
08/23/10 18:30
08/23/10 18:30
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Ha, it works!!! Here is how you iterate through all sky entities:
int ents = 0;
ENTITY* seed = ent_createlayer("", SKY, 0);
ENTITY* ent = ptr_first(seed);
while (ent)
{
if (ent != seed)
{
error(ent->type); // "skycube+6.tga"
ents++;
}
ent = ent.link.next;
}
if (seed)
ptr_remove(seed);
printf("sky entities = %d", ents);
Many thanks to you, EvilSOB!
|
|
|
Re: Getting view entities...
[Re: HeelX]
#339013
08/23/10 19:38
08/23/10 19:38
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
No problem dude. Glad to be of service.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|