Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
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
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

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 Offline
Expert
Uhrwerk  Offline
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: Uhrwerk] #423915
06/07/13 22:38
06/07/13 22:38
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
I just do this simple process:
(just an example)

ENTITY* ent1 = ent_create("model.mdl", vector(0,0,0), NULL)
ENTITY* ent2 = ent_clone(ent1);
(then i place it at a diferent position from ent1)
ent2.x = 50

The result is ent1 disapearing and ent2 showing up
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?

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

M
Malice
Unregistered
Malice
Unregistered
M



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
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

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

M
Malice
Unregistered
Malice
Unregistered
M



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.

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

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: joao13pt
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

M
Malice
Unregistered
Malice
Unregistered
M



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: ] #423927
06/08/13 06:30
06/08/13 06:30
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
yes, cloning means something different in lite-c and in biotechnology.


Free world editor for 3D Gamestudio: MapBuilder Editor
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
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

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?

Originally Posted By: Malice

Code:
ENITY* astroids[100];



Why did i never think of this!?

Page 1 of 3 1 2 3

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