Slastraf Posted April 15, 2021 Share Posted April 15, 2021 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 Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 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. 1 Quote 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 More sharing options...
Slastraf Posted April 15, 2021 Author Share Posted April 15, 2021 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 Quote Link to comment Share on other sites More sharing options...
Slastraf Posted April 15, 2021 Author Share Posted April 15, 2021 Here is the quat test file. I am pretty confident it would work normally on any other thing than a bone. But have not tried it there yet. quatTest.lua Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 I am 98% sure you are feeding in nonsense quaternions into the command. I don't think they are axis / angle values. 1 Quote 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 More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 Maybe it should be like this? local slerp = a:Slerp(Quat(Vec3(0,0,Time:GetCurrent()*0.05))),self.speed) Quote 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 More sharing options...
Slastraf Posted April 15, 2021 Author Share Posted April 15, 2021 Yeah that pointed me in the right direction, but still not the desired outcome. i will not get a $70 textbook on that so I need to rely on utube now. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 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. Quote 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 More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 3 minutes ago, Slastraf said: pointed me in the right direction 1 Quote 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 More sharing options...
Slastraf Posted April 15, 2021 Author Share Posted April 15, 2021 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 Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 The engine already does this. I believe you can just call Quat(Vec3(90,0,0)) Quote 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 More sharing options...
Slastraf Posted April 15, 2021 Author Share Posted April 15, 2021 2 minutes ago, Josh said: The engine already does this. I believe you can just call Quat(Vec3(90,0,0)) Oh, I thought you needed a W also but it does work like that. This needs to be in the documentation Quote Link to comment Share on other sites More sharing options...
Josh Posted April 15, 2021 Share Posted April 15, 2021 The Vec3 constructor takes pitch, yaw, and roll and then the quaternion accepts that in the constructor. Quote 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 More sharing options...
Slastraf Posted April 16, 2021 Author Share Posted April 16, 2021 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 Quote Link to comment Share on other sites More sharing options...
Josh Posted April 16, 2021 Share Posted April 16, 2021 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. Quote 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 More sharing options...
Slastraf Posted April 16, 2021 Author Share Posted April 16, 2021 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 16, 2021 Share Posted April 16, 2021 If you can upload the files to run the example I am happy to examine it. Quote 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 More sharing options...
Slastraf Posted April 16, 2021 Author Share Posted April 16, 2021 6 minutes ago, Josh said: If you can upload the files to run the example I am happy to examine it. Yes I hope it was everything. spiderLegFiles.zip Quote Link to comment Share on other sites More sharing options...
Slastraf Posted April 17, 2021 Author Share Posted April 17, 2021 Thanks for trying. Is there any fix ? Quote Link to comment Share on other sites More sharing options...
Josh Posted April 17, 2021 Share Posted April 17, 2021 I tried extracting your zip archive into a new blank project and running the map but I just get a black screen. Quote 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 More sharing options...
Slastraf Posted April 17, 2021 Author Share Posted April 17, 2021 Try it in the fps template, it has the fps player in there Quote Link to comment Share on other sites More sharing options...
Josh Posted April 17, 2021 Share Posted April 17, 2021 How do I make it run? Nothing is moving. Quote 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 More sharing options...
Slastraf Posted April 17, 2021 Author Share Posted April 17, 2021 Can you set it up like this ? Quote Link to comment Share on other sites More sharing options...
Josh Posted April 17, 2021 Share Posted April 17, 2021 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. Quote 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 More sharing options...
Josh Posted April 17, 2021 Share Posted April 17, 2021 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. Quote 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 More sharing options...
Recommended Posts
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.