Jump to content

Model Animation - rotate Head part ?


Marcousik
 Share

Recommended Posts

Hello,

I was searching for this but could not find really something,

Is it possible to rotate the Head while playing an "classic" animation like out of mixamo ?

As for example if NPCs should look /turn head focusing/pointing on the player (or something else) while they are animated with a classic "Stand" animation ?

Here there is something with Blendtime and rotation, but not sure if this is for specific Bones rotation...

https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_PlayAnimation

 

 

Link to comment
Share on other sites

I have not ever been successful to get individual bones to manually move while using the "new" PlayAnimation() command, but if you use the older, original command for animation, SetAnimationFrame(), you can rotate individual bones while playing animations.

example:

window = Window:Create("Example", 0, 0, 800, 600, Window.Titlebar+Window.Center)
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:SetPosition(0,.8,-1.8)
light = DirectionalLight:Create()
light:SetRotation(35,35,0)

player = Model:Load("Models/characters/crawler/crawler.mdl")
frame = 0
blend = 1
sequence = "Run"

Head = player:FindChild("Bip01 Head")
Rot = Head:GetRotation(false)

while not window:KeyHit(Key.Escape) do
	if window:Closed() then return false end

	player:SetAnimationFrame(frame,blend,sequence,true)
	frame = frame + Time:GetSpeed()/2.5

	 if window:KeyDown(Key.Left) then Rot.y = Rot.y - 1 end
	 if window:KeyDown(Key.Right) then Rot.y = Rot.y + 1 end
	 if window:KeyDown(Key.Up) then Rot.z = Rot.z - 1 end
	 if window:KeyDown(Key.Down) then Rot.z = Rot.z + 1 end
	 Rot.y = math.max(Rot.y, -45)
	 Rot.y = math.min(Rot.y, 45)
	 Rot.z = math.max(Rot.z, -120)
	 Rot.z = math.min(Rot.z, -40)
	 Head:SetRotation(Rot.x, Rot.y, Rot.z, false)

	 Time:Update()
	 world:Update()
	 world:Render()
	 context:SetBlendMode(Blend.Alpha)
	 context:DrawText("Press Arrow Keys to Move Head",2,2)
	 context:DrawText("Rot: "..Rot:ToString(),2,22)
	 context:SetBlendMode(Blend.Solid)
	 context:Sync(true)
end

rotatebone.jpg.6cb8ed9a7ae639ceba4ec8eb0ec46356.jpg

  • Like 2
  • Thanks 1
  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...