Page 1 of 2
SpawnModel
Posted: Sat May 29, 2010 5:02 pm
by y offs et
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.

Posted: Sat May 29, 2010 6:52 pm
by Kjell
See attached .. but perhaps I'm missing something. What are you trying to do exactly?
K
Posted: Sat May 29, 2010 7:28 pm
by y offs et
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.
Posted: Sat May 29, 2010 7:59 pm
by Kjell
Going out on a limb here .. but I'm guessing that the collision doesn't work the way you want it anymore when you spawn a rotated model? If so, this is because Box3D != Box3D_OBB .. you'll need to update the Bound properties to match the instance.
K
Posted: Sun May 30, 2010 3:57 am
by y offs et
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?
Posted: Sun May 30, 2010 10:34 am
by Kjell
Ah, now I get it. The UseSpawnerPosition checkbox only assigns the CurrentModel's Position to the Spawned model, not the Rotation or Scale ( otherwise it would be called UseSpawnerTransformation ). Check my example for the two methods you can use to do just that.
K
Posted: Sun May 30, 2010 3:10 pm
by y offs et
@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 -
( otherwise it would be called UseSpawnerTransformation )
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.
Posted: Sun May 30, 2010 4:12 pm
by y offs et
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 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.
Just another example that SpawnModel is the final, overruling set on anything.
Posted: Sun May 30, 2010 4:52 pm
by Kjell
Strange .. both methods work just fine from me ( regardless of context ).
K
Posted: Sun May 30, 2010 8:40 pm
by y offs et
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
OnLoaded
This list is executed once at program start. Put your application initialization components here.
Any comment on this?
Posted: Sun May 30, 2010 9:02 pm
by Kjell
Both the OnLoaded description and your assessment are correct.
Technically it doesn't matter where you put your DefineVariable Components .. you can even put them all in a OnCollision event of a ModelState
K
Posted: Mon May 31, 2010 1:24 am
by y offs et
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.
Posted: Mon May 31, 2010 10:50 am
by Kjell
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);
In case you need to rotate over more then 1 axis, use the matrix library.
K
Posted: Mon May 31, 2010 6:40 pm
by y offs et
I knew you'd come up with something.
I've got real life interfering with hobby right now, but I'll put this all together somehow in the future.
Posted: Mon May 31, 2010 6:49 pm
by VilleK
y 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.
You are right, that was a bug but it will be fixed in the next beta update
