Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Delay bei vec_for_bone und ang_for_bone #405481
07/31/12 19:55
07/31/12 19:55
Joined: Oct 2011
Posts: 3
F
FFH Offline OP
Guest
FFH  Offline OP
Guest
F

Joined: Oct 2011
Posts: 3
Hallo,

ich möchte einen Sprite an ein bewegtes Modell heften. Das Modell ist mit Bones versehen, so dass mir die Routinen vec_for_bone und ang_for_bone geeignet scheinen. Das Modell ist als Entity "wheel" deklariert. Es handelt sich um ein Rad mit Speichen an deren Ende der Sprite angebracht werden soll.

In der action-Routine des Sprites habe ich als Code folgendes fabriziert:

if (my.skill10 == 1.0)
{
vec_for_bone(_pos, wheel, "Bone2");
_pos.y += 20;
vec_set(my.x, _pos.x);

ang_for_bone(_angle, wheel, "Bone2");
vec_set(my.pan, _angle);
}


... und tatsächlich foltg Position und Ausrichtung dem Modell,... allerdings mit einem unschönen DELAY.

Der Sprite klebt also nicht an seinem Platz, sondern entfernt sich von diesem, wenn das Modell beschleunigt und setzt sich erst nach dem "abbremsen" wieder an die gewünschte Position.

Hat jemand eine Idee, wodurch ein solches Delay verursacht werden könnte und wie mnan es verhindern kann?
Die Szene insgesamt ist recht einfach und läuft soft und ohne Ruckeln. Eine Überlastung während des Renderns halte ich daher für ausgeschlossen.

Re: Delay bei vec_for_bone und ang_for_bone [Re: FFH] #405485
07/31/12 20:24
07/31/12 20:24
Joined: Jul 2002
Posts: 3,208
Germany
Error014 Offline
Expert
Error014  Offline
Expert

Joined: Jul 2002
Posts: 3,208
Germany
Die klassische Erklärung für dieses Problem ist die Folgende (steht auch im Handbuch, ist aber zugegebenermaßen fast unmöglich zu finden, wenn man das nicht weiß):

Funktionen laufen nicht wirklich gleichzeitig. Je nachdem, in welcher Reihenfolge du deine Entities erzeugst, kann es sein, dass deine Sprite-Funktion VOR der anderen läuft. In dem Fall würde sie sich auf die Position der Bones setzen, und DANACH würde sich das Objekt selbst bewegen (und damit wären dann die Bones auch an einer anderen Stelle).

Du kannst Abhilfe schaffen, indem du

Code:
proc_mode = PROC_LATE;



setzt.




Oder, wie es das Handbuch sagt:

Quote:

Bad timing, again
Q. We have a model entity with a bright red light at it's very centre. For improving the light effect, we've attached a TGA sprite to that model:
Code:
action attach_sprite()
{
  set(my,BRIGHT); // make light more brilliant
  my.roll = 1;    // always face the camera
  while (1)
  {
    vec_set(my.x,you.x); // place the sprite at the xyz position of the entity that created it
    wait(1);
  }
}

action red_model()	
{
  ent_create("light.tga", my.x, attach_sprite); // attach light sprite
  ...
  patrol() // some movement action
}



We expected that the light sprite is fixed to the center of the model, and moves together with it. However it always seems to lag behind by one frame. And even worse, the model now does not move anymore! What's happening?
A. The second problem is easy to fix: We've forgotten to make the light passable. So the model permanently collides with it's own light. Entities attached to other ones should be PASSABLE:

Code:
action attach_sprite()
{
  set(my,BRIGHT|PASSABLE); // make light more brilliant and passable
	... // etc.



But what produces the strange time lag? If two entities influence each other, it's important to keep in mind the order of their two simultaneously running actions. They won't run really at the same time. In the example, during one frame the function scheduler runs first the attach_sprite action, and then the red_model's movement action. Functions that are started first will run first. So the sprite is always placed to the position the red_model had in the frame before. The solution is simple: By changing the order of the actions ...

Code:
action red_model()
{
  patrol(); // perform move behavior first
  ent_create ("light.pcx", my.x, flare_light); // attach light sprite and start it's action after that
}



...the light stays perfectly at the entities' center. We could alternatively use PROC_LATE for changing the order of actions:

Code:
action attach_sprite()
{
  set(my,BRIGHT|PASSABLE); // make light more brilliant and passable
  my.roll = 1;    // always face the camera
  while (1)
  {
    proc_mode = PROC_LATE;
    vec_set(my.x,you.x); // place the sprite at the xyz position of the entity that created it
 	  wait(1);
  }
}




(Hervorhebung von mir)

Last edited by Error014; 07/31/12 20:26. Reason: Zitat korrigiert

Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
Re: Delay bei vec_for_bone und ang_for_bone [Re: Error014] #405502
08/01/12 06:15
08/01/12 06:15
Joined: Oct 2011
Posts: 3
F
FFH Offline OP
Guest
FFH  Offline OP
Guest
F

Joined: Oct 2011
Posts: 3
VIELEN VIELEN DANK!!!!

Es arbeitet jetzt perfekt!


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