Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 959 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Getting view entities... #338857
08/22/10 09:11
08/22/10 09:11
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

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:

Code:
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 Offline
Junior Member
LemmyTheSlayer  Offline
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: LemmyTheSlayer] #338871
08/22/10 10:27
08/22/10 10:27
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Doesn't work either, because ent_next is for level entities only and ptr_first is for all entities... or should be.

Re: Getting view entities... [Re: HeelX] #338914
08/22/10 17:53
08/22/10 17:53
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

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 Offline
Expert
EvilSOB  Offline
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)....
Code:
...
   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
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Ha, that shall be the trick? Thanks!

Unfortunately the manual says

Quote:
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 grin

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 Offline
Expert
EvilSOB  Offline
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
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Ha, it works!!!

Here is how you iterate through all sky entities:

Code:
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 Offline
Expert
EvilSOB  Offline
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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1