setWorldRotationAnglesWithOrder [solved]

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: setWorldRotationAnglesWithOrder

Post by Granamir »

JohnWordsworth wrote:I don't know if we have the facility to create our own matrix objects (I've tried the obvious calls, such as mat(), mat44(), mat4() to no avail).

HOWEVER, I have figured out one useful thing with regards to using matrices for setWorldRotation().

Code: Select all

local m = entity.go:getWorldRotation();
print(m);
m.x = vec(1,0,0,0)
entity.go:setWorldRotation(m)
This allows you to get the matrix object from the object, change the values (the matrix information looks to be stored where x, y, z, w are each a vector of length 4 - ie. it's a 4x4 matrix).

Haven't really had much chance to play with this otherwise, but that's the foundation of it.
Made some esperiment with matrix but seems not a good idea to use them because tend to distort object shape.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: setWorldRotationAnglesWithOrder

Post by minmay »

Granamir wrote:Made some esperiment with matrix but seems not a good idea to use them because tend to distort object shape.
That only happens if you compute them incorrectly. See:
http://en.wikipedia.org/wiki/Transformation_matrix
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: setWorldRotationAnglesWithOrder

Post by Granamir »

minmay wrote:
Granamir wrote:Made some esperiment with matrix but seems not a good idea to use them because tend to distort object shape.
That only happens if you compute them incorrectly. See:
http://en.wikipedia.org/wiki/Transformation_matrix
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Again thank you minmay,
unfortunatelly my math skills are too low to handle matrix, even if i understood general concept porting it in game is another matter, as for most of people using the editor i guess.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: setWorldRotationAnglesWithOrder [solved]

Post by Granamir »

ok i got it
after some days thinking on it i finally understood why euler angles are not so intuitive (except for small angles) and have gimbal lock problem
it depends on differences on how our mind works and euler angles do
in euler angles the object reference system is solida with object so at change on 1 axis the whole sistem change
in our mind after changing 1 angle we reset the object (bringing his reference system back parallel to world system) and then make second change on another axis
so now i'm wondering how difficult and unefficient may be to do the same in a software?
Post Reply