Smooth Model movement/rotation, ACS *.bin decompile

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Post Reply
User avatar
Cherno
Posts: 1309
Joined: Tue Dec 06, 2016 11:25 am

Smooth Model movement/rotation, ACS *.bin decompile

Post by Cherno »

Two related questions.

As we all know, when using models for actors, the monster movement code makes the whole thing look weird with all the teleporting and insta-snapping to new angles all the time. There has been talk about using invisible actors that are in turn followed (smoothly) by model-only actors, but no tutorial for this as I know of. The only thing I was able to find out is that Total Chaos uses a system like that.

Code: Select all

actor brute_ambush 30031
{

//...

        var int user_displayTid;
	var int user_status;
	var int user_hasTether;
	var int user_seenPlayer;
	
	States
	{
		Spawn:
			AITE A 1
			AITE A 1 A_JumpIf(user_hasTether == 1, "SpawnActive")
			AITE A 1 ACS_NamedExecuteAlways("TetherAi", 0, 0, 10, 0)
			AITE A 100
			AITE A 0 A_SetUserVar("user_hasTether", 1)
			AITE A 1 ACS_NamedExecuteAlways("AiSetStateFromTable", 0, user_displayTid, 1, 1)
		SpawnActive:
			0000 ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_Look
			0001 ABCD 1 A_Look
			loop
		See:
			AITE A 0
			AITE A 1 ACS_NamedExecuteAlways("AiSetStateFromTable", 0, user_displayTid, 1, 1)
			AITE A 0 A_SetUserVar("user_seenPlayer", 1)
			//AITE A 0 A_PlaySound("ai/brute/see", CHAN_AUTO)
                 //...
        }
}

So, the model-only actor is spawned in this actor's spawn state, and all further states somehow make the model-only actor change it's state, too (lookup table?). I assume that each actor that has a tether like this also has to havev a unique TID set when spawning.

Unfortunately, I wasn't able to find the model-only acto code, and the ACS file is a *.bin (as opposed to a *.o) so I couldn't decompile it to see the code.

So, does anyone have experience with smooth model movement and rotation? Can anyone make sense from the way Total Chaos did it? Is there a way to decompile *.bin ACS files?

(I desperately need it for my Alone in the Dark TC :) )
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: Smooth Model movement/rotation, ACS *.bin decompile

Post by gramps »

User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Smooth Model movement/rotation, ACS *.bin decompile

Post by Apeirogon »

Quaternions have one fatal flaw, they dont have much of a "how to turn things using quaternions for dummy" manuals in the internet.
gramps
Posts: 300
Joined: Thu Oct 18, 2018 2:16 pm

Re: Smooth Model movement/rotation, ACS *.bin decompile

Post by gramps »

This thing Gutawer wrote really has a pretty nice simple API... part of the issue here, with no "private" or "public" it might not be obvious which stuff you're supposed to be using and which stuff is internal.

I think in a case like this you'd want one quaternion representing the new angle, and one representing the old angle, and lerp between them; and then use the function that decomposes the thing back into yaw, pitch and roll.

If lerping doesn't feel smooth enough, you could rework that bit to put an easing function ahead of the lerp by manipulating the "time" value, something like a waveshaper. This is a little hard to describe properly, but look at the difference between the red and blue line here between 0,0 and 1,1; the red line represents a lerp and the blue line represents an eased lerp.

(demo)

You could also do this with sin or atan or a number of heavy things, or with the usual jerky cubic and co, but a low-order approximation of a sine like this should get you the most bang for your buck. I think. Unless regular sine is actually cheaper?
Guest

Re: Smooth Model movement/rotation, ACS *.bin decompile

Post by Guest »

I was just going to post a thread asking this very question, but a search led me here. Unfortunately, the solution seems inconclusive. Does Gutawer have an example mod or tutorial that shows how these so called Quaternions work?
Post Reply

Return to “Assets (and other stuff)”