[AGK2] Matrix aus Objektrotation herstellen *GELÖST
Übersicht

![]() |
hecticSieger des IS Talentwettbewerb 2006Betreff: [AGK2] Matrix aus Objektrotation herstellen *GELÖST |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich spiele gerade mit Matrizen rum und benötige die Orientierungsmatrix berechnet aus den Winkeln eines Objektes.
In umgekehrter Reihenfolge habe ich bereits ein Erfolg geschafft, nun benötige ich es aber wieder zurück. Ich habe eine Matrix: Code: [AUSKLAPPEN] dim x3gmatrix[12] as float
// 00 = x-position // 01 = y-position // 02 = z-position // 03 = x-vector as x // 04 = x-vector as y // 05 = x-vector as z // 06 = y-vector as x // 07 = y-vector as y // 08 = y-vector as z // 09 = z-vector as x // 10 = z-vector as y // 11 = z-vector as z und wenn ich diese setze, werden alle gezeichneten Befehle anhand dieser ausgerichtet. Jetzt möchte ich aber die Matrix nicht immer selber setzen, sondern auch mal aus einem Objekt übernehmen. Leider habe ich keinen Befehl dafür in den Commands gefunden. Was ich aber auslesen kann sind: GetObjectAngleX(Object) // entspricht EntityPitch ![]() GetObjectAngleY(Object) // entspricht EntityYaw ![]() GetObjectAngleZ(Object) // entspricht EntityRoll ![]() Das Ergebnis aus SetObjectRotation(Object,0,0,0) sollte sein: 1,0,0, x 0,1,0, y 0,0,1, z Hat da einer einen Lösungsvorschlag oder einen Tipp, wonach ich am besten suchen kann? Edit: Nachdem ich im Internet immer nur Matrixrotationen gefunden hatte und meine Lösung in bestimmten Winkeln fehlerhaft war, habe ich mich mit einem Workaround begnügt. Fehlerhaft Code: [AUSKLAPPEN] local x3ioax as float
local x3ioay as float local x3ioaz as float x3ioax=getobjectanglex(object) x3ioay=getobjectangley(object) x3ioaz=getobjectanglez(object) local sx as float local cx as float local sy as float local cy as float local sz as float local cz as float sx=sin(x3ioax) cx=cos(x3ioax) sy=sin(x3ioay) cy=cos(x3ioay) sz=sin(x3ioaz) cz=cos(x3ioaz) x3gmatrix[04]=cy*cz x3gmatrix[05]=sz x3gmatrix[06]=-sy x3gmatrix[08]=-sz x3gmatrix[09]=cx*cz x3gmatrix[10]=sx x3gmatrix[12]=sy x3gmatrix[13]=-sx x3gmatrix[14]=cx*cy Workaround Code: [AUSKLAPPEN] local xt as float
local yt as float local zt as float xt=getobjectworldx(object) yt=getobjectworldy(object) zt=getobjectworldz(object) moveobjectlocalx(object,1.0) x3gmatrix[04]=getobjectworldx(object)-xt x3gmatrix[05]=getobjectworldy(object)-yt x3gmatrix[06]=getobjectworldz(object)-zt setobjectposition(object,xt,yt,zt) moveobjectlocaly(object,1.0) x3gmatrix[08]=getobjectworldx(object)-xt x3gmatrix[09]=getobjectworldy(object)-yt x3gmatrix[10]=getobjectworldz(object)-zt setobjectposition(object,xt,yt,zt) moveobjectlocalz(object,1.0) x3gmatrix[12]=getobjectworldx(object)-xt x3gmatrix[13]=getobjectworldy(object)-yt x3gmatrix[14]=getobjectworldz(object)-zt setobjectposition(object,xt,yt,zt) |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group