2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to randomly modify many entities that have the same model?
#423911
06/07/13 20:01
06/07/13 20:01
|
Joined: Mar 2013
Posts: 30 Portugal
joao13pt
OP
Newbie
|
OP
Newbie
Joined: Mar 2013
Posts: 30
Portugal
|
Hello! So, i have, for example, 5 entities, all of them using the same model.mdl When i modify one of them via a Contact* struct, by randomly modifying each of the vertex's, ALL of the 5 entities are affected. Why? Obviously because they all share the same model.mdl How do i avoid this? I remember, in The Elder Scrolls Oblivion, there was this "Base" entity of a sword, for example, and all of the other same 100 swords used in the game, that could be modified (they'd break, or get stronger, or weaker, ...) were called "references" and each had a specific "Unique ID" I've tried creating an algorithm that mimics this, using ent_clone, but this won't work, because, the only result i saw was the original being deleted, and the cloned one replacing the original...which made no sense How do i make this work? Thank you!
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: joao13pt]
#423912
06/07/13 20:12
06/07/13 20:12
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
ent_clone is the right approach for you. Post your code an we will see why it won't work out for you.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: joao13pt]
#423916
06/07/13 22:57
06/07/13 22:57
|
Malice
Unregistered
|
Malice
Unregistered
|
EDIT* Sorry I misunderstood.
Last edited by Malice; 06/07/13 23:11.
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: ]
#423917
06/07/13 23:09
06/07/13 23:09
|
Joined: Mar 2013
Posts: 30 Portugal
joao13pt
OP
Newbie
|
OP
Newbie
Joined: Mar 2013
Posts: 30
Portugal
|
Yes, i know that I understand how ent_clone works and what it does, the thing is: using the simple example code i posted earlier, the result is the original entity being deleted, and being replaced by the clone entity. So, i only end up with 1 entity after all, so something isn't right I hope you understand my point. I know how ent_clone works, i understand it perfectly, i just don't understand why it has this effect with my code.
------------------ EDIT ----------------- I'll explain with a solid example: I have this Planet And around it i want to place an asteroid field The asteroids are inicially cubes but are later randomly deformed, vertex by vertex the whole algorithm for deforming randomly and placing randomly around the planet is very easy for me. The problem i'm having is that, the second asteroid i place, and the third, and fourth and so on, they will ALWAYS be exaclty like the first one, because they are ALL sharing the same model my goal is to avoid this, basically i want each new entity(asteroid) to be a clone of the initial one (base asteroid -> initial undeformed cube) so i can deform it later and perhaps give it a diferent texture too, this way i could have thousands of diferent possibilities But the thing is, using ent_clone will only make the original entity to be eliminated, and the final clone, will replace the original entity. So, instead of having as many asteroids as i want, i ALWAYS end up with 1 single asteroid how do i avoid this situation?
Last edited by joao13pt; 06/07/13 23:14.
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: joao13pt]
#423918
06/07/13 23:27
06/07/13 23:27
|
Malice
Unregistered
|
Malice
Unregistered
|
100 asteroids 100 ent_create(s) and 100 ent_clone(s) = 1 entity at the end? Just wondering and hope someone who knows answers. I did the testing and ent_clone is not a ent_duplicate it shifts the entity from a shared mdl to cloned mdl that is not shared . It doesn't seem to duplicate the entity so you would have to create all you asteroids then clone them to unshared virtual(created in memory only) mdls and lastly modify them individually.
ENITY* astroids[100];
for(I=0; I < 100; I++)
{
astroid[I] = ent_create(.......);
astroid[I] = ent_clone(astriod[I]);
}
Last edited by Malice; 06/08/13 00:35.
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: joao13pt]
#423922
06/08/13 01:16
06/08/13 01:16
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Basically this only removed the first entity and replaced it with the clone, which makes absolutelly no sense tell me, please, how should i use ent_clone? You misunderstood the concept. ent_clone does not make a copy of the entity itself but of its mesh and skin. There is no entity removed and no new one created in your example. Instead you have just moved the original entity. The proper usage is to first call ent_clone on an entity and then modify the mesh / skin as you see fits. The return value if ent_clone is the original entity, or NULL in case it failed. So in summry:calling ent_clone let's you change an entities skin and mesh without changing the skin and mesh of the other entities sharing the corresponding model. ent_clone does not copy entities. You still have to create them with ent_create or place them via WED. http://www.conitec.net/beta/ent_clone.htm
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: Uhrwerk]
#423924
06/08/13 04:31
06/08/13 04:31
|
Malice
Unregistered
|
Malice
Unregistered
|
It is another example of the manual not being clear. And the name of the instruction is misleading I would rename it to ent_make_individual or something like that. Maybe ent_unshare. The example code doesn't even show ent_clone. I would have believe is way if I hadn't read long ago the exact same kinda post.
|
|
|
Re: How to randomly modify many entities that have the same model?
[Re: ]
#423942
06/08/13 14:04
06/08/13 14:04
|
Joined: Mar 2013
Posts: 30 Portugal
joao13pt
OP
Newbie
|
OP
Newbie
Joined: Mar 2013
Posts: 30
Portugal
|
Thank you! I now have a better picture of what ent_clone does, something the manual should explain a bit better I've already tried it with 2 asteroids, doing exactly like you guys explained to me: first ent_create then ent_clone and since the objects are randomly deformed, their diferences were obvious, which means its the correct way to use ent_clone Thank you all! By the way, did you just create an array of Entities? Why did i never think of this!?
|
|
|
|