Jump to content

Bone rotation impossible


Slastraf
 Share

Recommended Posts

Here is a private video that shows different ways of rotating in Leadwerks and how they all do not work on bones from models.

Moreover, I tried using quaternions to rotate the spider leg around the x axis, which worked but scaled the model up in the process for no reason.
The red, green and blue are rotated on the x , y and z but none of them actually rotate around the x axis. If you set rotation to global, the outcom eis worse.

I am running out of ideas. i have uploaded the spider leg mdl and fbx so you can try yourself.

spider leg.zip

Link to comment
Share on other sites

You are constructing a quaternion with 1,0,0, and then using the current time as the w parameter? I actually have no idea what that would do. There is an entire book on the subject of visualizing quaternions. It's called Visualizing Quaternions. I have not read the book yet.

If your angle only involves rotation on one axis then I think you are safe making a Euler rotation and converting that to a quaternion for your target.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

As far as I understand an quatof xyz = 100 is the "lookAt" vektor of the model and "W" the rotation on that axis (global euler x in that case). if it goes from 0-180 it should turn on that x axis ( It is doing just that, but it should never scale itself up. It is a bug.)

The point is,  neither setQuat or setRot work as they both have inpredictable outcomes.
I am 99% sure that the scaling up issue is a bug so that makes quats unusable in LE currently. Can you confirm that ?

2021-04-15 18-40-56.mkv

Link to comment
Share on other sites

Well, try changing the axis that is being modified and I think you will get it.

I don't suggest trying to understand quats. Just use them and know what they are, an unambiguous rotation.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Here a minimally tested lua funciton to convert from Euler to Quat in LE
source http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm

function eulerToQuat(x,y,z)
    --Assuming the angles are in radians.
    local c1 = Math:Cos(x*0.5);
    local s1 = Math:Sin(x*0.5);
    local c2 = Math:Cos(y*0.5);
    local s2 = Math:Sin(y*0.5);
    local c3 = Math:Cos(z*0.5);
    local s3 = Math:Sin(z*0.5);
    local c1c2 = c1*c2;
    local s1s2 = s1*s2;
	return Quat(c1c2*s3 + s1s2*c3, s1*c2*c3 + c1*s2*s3, c1*s2*c3 - s1*c2*s3, c1c2*c3 - s1s2*s3)
	--[[
    w =c1c2*c3 - s1s2*s3;
  	x =c1c2*s3 + s1s2*c3;
	y =s1*c2*c3 + c1*s2*s3;
	z =c1*s2*c3 - s1*c2*s3;
	--]]
end

 

Link to comment
Share on other sites

I have converted the script and tried to make a lot of adjustments, but so far have not been able to accurately replicate rotation of an already working model without bones.

The script is uploaded here, but I don't know why the model with bone (not the green +yellow one) is still acting strangely.
It seems to not track the target blue sphere accurately. 
I have uploaded the bone model before.
Really would like to proceed with normal development speed but I sit on this sole issue for two days now and really don't know any fix.

//edit In the video the model with bone has 3 "parts" of the leg but the rock box should be on the same position as the blue sphere

oldSpiderLeg.lua

Link to comment
Share on other sites

You don't actually need to use SetQuaternion in this situation. You could just call SetRotation. You are constructing a quaternion from a Euler with rotation only on one axis, so you aren't going to lose any precision by calling SetRotation with the Euler.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

1 minute ago, Josh said:

You don't actually need to use SetQuaternion in this situation. You could just call SetRotation. You are constructing a quaternion from a Euler with rotation only on one axis, so you aren't going to lose any precision by calling SetRotation with the Euler.

Yes I have used both now and they have the same result. I thought SetQuaternion was going to fix it but it didn't.

Link to comment
Share on other sites

If you upload a project that is ready to run I am happy to look at it. I can't guess what your problem is, try to recreate it, and then solve it with any accuracy.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I ran the project and it look like it is running a terrain generation program?

If I run in release I mode I get this error:

index field 'targetPoint' (a nil value)

In spiderleg.lua, line 50, when running the "start" map.

My job is to make tools you love, with the features you want, and performance you can't live without.

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...