SpawnModel
Moderator: Moderators
SpawnModel
Currently, we can use Repeat/SpawnModel and using a model identity, place multiple instances differentiated by position alone - not rotation or scale.
As SpawnModel is the final set for position, rotation, scale, in that it's settings tend to overrule Model sets, it would be desirable that rotation and scale of SpawnModel could also be affected by scripting.
Yes, Kjell, I hope you can prove me wrong.
As SpawnModel is the final set for position, rotation, scale, in that it's settings tend to overrule Model sets, it would be desirable that rotation and scale of SpawnModel could also be affected by scripting.
Yes, Kjell, I hope you can prove me wrong.
"great expectations"
See attached .. but perhaps I'm missing something. What are you trying to do exactly?
K
- Attachments
-
- Spawn.zgeproj
- (886 Bytes) Downloaded 615 times
OK, I give up trying to explain. On this, I've made individual models of the pieces because that way I get the collision working right. So I can double my instances via position, but I can't figure how to rotate an instance.
- Attachments
-
- animSprite_7.zip
- (31.9 KiB) Downloaded 545 times
"great expectations"
OK - I learned something here so I won't say sorry.
In the previous - base:model / OnSpawn / make_cell:repeat - there are two script lines besides the default //this.iteration ...
Even though they are commented out, they prevent the iterations! By removing them, the models are spawned. I consider this a bug.
@VilleK - your call - I can make note of this in the Docs, or you can fix it.
Now, in Group cell / Cell:Model / OnSpawn / ZExpression - I create the second instance by moving the position, however I cannot affect the rotation or scale. Why not?
In the previous - base:model / OnSpawn / make_cell:repeat - there are two script lines besides the default //this.iteration ...
Even though they are commented out, they prevent the iterations! By removing them, the models are spawned. I consider this a bug.
@VilleK - your call - I can make note of this in the Docs, or you can fix it.
Now, in Group cell / Cell:Model / OnSpawn / ZExpression - I create the second instance by moving the position, however I cannot affect the rotation or scale. Why not?
- Attachments
-
- animSprite_7.zip
- (31.81 KiB) Downloaded 526 times
"great expectations"
@Villek - About the WhileExp in the Repeat Component - It seems any kind of entry other than the default line activates it and nullifies the Count. This can't be right. It's a noob tripper ( it tripped me )
@Kjell -
@Kjell -
You're right - literal translation. If it did everything it could be called UseSpawnerAttributes. Thanks for those methods. I'll see what I can come up either with a ZExpression or using the hyper sensitive WhileExp box.( otherwise it would be called UseSpawnerTransformation )
"great expectations"
Just a follow up - it appears that by having the individual parts being SpawnModel (ed) in the OnSpawn list of Cell, they overrule any method of rotating the model via Cell.rotation, so I'll have to find another way.As SpawnModel is the final set for position, rotation, scale, in that it's settings tend to overrule Model sets, it would be desirable that rotation and scale of SpawnModel could also be affected by scripting.
Just another example that SpawnModel is the final, overruling set on anything.
"great expectations"
Strange .. both methods work just fine from me ( regardless of context ).
K
- Attachments
-
- Spawn.zgeproj
- (1.53 KiB) Downloaded 607 times
I'll rebuild my project and get back to you.
As an aside, I noticed in your last spawn example you declared variable Count in Content and then called it immediately in OnLoaded. That says to me that Content must be loaded before OnLoaded and calls into question the accuracy of
As an aside, I noticed in your last spawn example you declared variable Count in Content and then called it immediately in OnLoaded. That says to me that Content must be loaded before OnLoaded and calls into question the accuracy of
Any comment on this?OnLoaded
This list is executed once at program start. Put your application initialization components here.
"great expectations"
OK, here's another problem.
The black is the parent model and blues are child models.
As I change parent position the children follow, we can do that.
As I rotate parent, the children rotate also, You showed a way to do that.
But their position relative to the internal layout does not transform.
I haven't been able to dream up a simple way to do this, other than a one piece .3ds model. Pascal, being OOP, I thought could have a solution.
Why do I torture myself this way?
EDIT - I'm thinking the only way is having 4, or whatever, complete parents with the internals oriented as desired, and transform them where desired. I'm also starting to mumble while thumbing my lips and rolling my eyes, and am thinking about pointy hats. We don't seem to have an Emoticon to portray that.
The black is the parent model and blues are child models.
As I change parent position the children follow, we can do that.
As I rotate parent, the children rotate also, You showed a way to do that.
But their position relative to the internal layout does not transform.
I haven't been able to dream up a simple way to do this, other than a one piece .3ds model. Pascal, being OOP, I thought could have a solution.
Why do I torture myself this way?
EDIT - I'm thinking the only way is having 4, or whatever, complete parents with the internals oriented as desired, and transform them where desired. I'm also starting to mumble while thumbing my lips and rolling my eyes, and am thinking about pointy hats. We don't seem to have an Emoticon to portray that.
- Attachments
-
- no_transform.gif (1.33 KiB) Viewed 13258 times
"great expectations"
Yea .. those kinds of things would be allot easier if ZGE supported hierarchies.
Anyway, you need to rotate around the center / pivot of the parent ( which influences the position ), instead of just rotating the individual children themselves. So, calculate the distance of the child position to the parent, and multiply those coordinates with the following formula ( when rotating over the y axis ).
Code: Select all
X = DistanceX*cos(Angle)-DistanceZ*sin(Angle);
Z = DistanceX*sin(Angle)+DistanceZ*cos(Angle);
K
You are right, that was a bug but it will be fixed in the next beta updatey offs et wrote:In the previous - base:model / OnSpawn / make_cell:repeat - there are two script lines besides the default //this.iteration ...
Even though they are commented out, they prevent the iterations! By removing them, the models are spawned. I consider this a bug.