View Full Version : tbgl_entitygetaxis help needed
Hi Petr, I spent about 2 hours trying to figure out how to get the rotation value of an entity, but not getting ahead to well.
First, there are 3 commands, where as in tbgl_entitygetpos there is only one. It seems like a command, tbgl_entitygetrot (scene, entity, x, y, z) would exist.
I used tbgl_entitygetaxisX
tbgl_entitygetaxisy
tbgl_entitygetaxisz
but I get a 1 or 0 and it doesn't update with current rotation numbers.
Thanks for any help and clarification, sorry to bother you when you are busy for school, but if I wasn't so stuck, wouldn' have asked.
Thanks.
Oh-- also, I can't seem to find dr aerix game of forums? I was going to look in there to see if we used any rotation get commands, I can't remember :)
Petr Schreiber
29-05-2008, 09:45
Hi Kent,
in Dr.Aeraix we used TBGL_EntitySyncAxes - which simply served to synchronize axes of two existing entities (rocket inherited rotation from camera).
The demo is still here (http://community.thinbasic.com/index.php?topic=1380.msg9713#msg9713).
Are you sure about TBGL_EntityGet{X|Y|Z}Axis not working? Did you had passed x, y, z defined as floating point?
See this example, seems to work:
Uses "TBGL"
' -- Create and show window
Dim hWnd As Dword = TBGL_CreateWindowEx("Mad rotations", 640, 480, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' -- Create scene
%SCENE1 = 1
TBGL_SceneCreate(%SCENE1)
' -- Create basic entities
%eBox = 20
' -- Create something to look at
TBGL_EntityCreateBox(%SCENE1, %eBox, 0, 1, 1, 1, 0, 255, 128, 0)
TBGL_EntitySetPos(%SCENE1, %eBox, 0, 0, 0)
dim x, y, z as double
dim AxesString as string= "Original axes:"+$CRLF+$CRLF
TBGL_EntityGetXAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "X:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetYAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Y:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetZAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Z:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
tbgl_entitySetRot(%SCENE1, %eBox, 10, 20, 30)
AxesString+= REPEAT$(60, "-")+$CRLF+"After tbgl_entitySetRot(%SCENE1, %eBox, 10, 20, 30):"+$CRLF+$CRLF
TBGL_EntityGetXAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "X:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetYAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Y:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetZAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Z:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
msgbox hwnd, AxesString
TBGL_DestroyWindow
Hope it will work for you too :)
Petr
Thanks Petr, your script works, getting too sleepy to figure mine out. Will look with fresh eyes tomorrow, well later today :)
Tonight is when I release my new project, so by Friday sometime it should appear for everyone.
If I waited till I finished except for sound, it would still be a couple of weeks. As I progress in it, more and more ideas come, so it is exciting.
Sorry for the suspense, but need to make some excitement for it, he he he he.
Petr Schreiber
29-05-2008, 12:22
Hi Kent,
I am really curious!
When in trouble, just send me even part of code ( to not spoil surprise ) and I will try to help you.
Petr
Petr, believe me there were many times when I wanted to send you scripts for help, but 2 things...
First I know you are busy with school work.
Second, I want this to be a total surprise to you and everyone... anyways back to work if I am to release tonight :)
Petr, it is not working for me... here is how I am trying to use it:
Why is there 3 different commands, when it seems it returns, xyz and in all cases when it works?
Uses "TBGL"
' -- Create and show window
Dim hWnd As Dword = TBGL_CreateWindowEx("Mad rotations", 640, 480, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' -- Create scene
%SCENE1 = 1
TBGL_SceneCreate(%SCENE1)
' -- Create basic entities
%eBox = 20
' -- Create something to look at
TBGL_EntityCreateBox(%SCENE1, %eBox, 0, 1, 1, 1, 0, 255, 128, 0)
TBGL_EntitySetPos(%SCENE1, %eBox, 0, 0, 0)
dim x, y, z as double
dim AxesString as string= "Original axes:"+$CRLF+$CRLF
TBGL_EntityGetXAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "X:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetYAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Y:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetZAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Z:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
'tbgl_entitySetRot(%SCENE1, %eBox, 10, 20, 30)
tbgl_entityturn (%SCENE1, %eBox, 0, 10, 0)
'AxesString+= REPEAT$(60, "-")+$CRLF+"After tbgl_entitySetRot(%SCENE1, %eBox, 10, 20, 30):"+$CRLF+$CRLF
AxesString+= REPEAT$(60, "-")+$CRLF+"After tbgl_entityturn(%SCENE1, %eBox, 0, 10,0):"+$CRLF+$CRLF
TBGL_EntityGetXAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "X:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetYAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Y:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
TBGL_EntityGetZAxis(%SCENE1, %eBox, x, y, z)
AxesString+= "Z:"+$TAB+using$("#.## #.## #.##", x, y, z)+$CRLF
msgbox hwnd, AxesString
TBGL_DestroyWindow
Petr Schreiber
30-05-2008, 09:35
Hi Kent,
maybe you think that TBGL_EntityGetXAxis returns something else?
I prepaired a short rendered tutorial for you, just click on attachement and hit open ( works only on PCs with thinBASIC installed ).
Petr
That is just very very cool answer and only can come from such a talented and nice guy, thanks!
You know me always looking for easy way... how about a command that tells in degrees.
tbgl_entitygetrot(sceneid, entityid, rotx, roty, rotz, flag degrees or radians) default degrees
and actually it will be nice to just send type xyz to get the values assigned too.
so it would be like the opposite of entityturn, that you give the degrees, in the new command you get the degrees?
Will think about things while sleep, almost 5:30am again... :)
Thanks for help!
Petr Schreiber
30-05-2008, 13:12
Hi Kent,
we discussed this with Mike some time ago - the matrix / axes is something clear, without possibility of "wrong" interpretation.
Express rotation in angles after few transformations is a bit of hell - it depends on order the angles were applied. So I need to think about it more.
Thanks,
Petr
Petr, when I saw your latest version, you put in the feature I couldn't figure out, which is the rotating tank icon in the radar.
I will examine that code this weekend and that will give me the answers I need.
I understand now what you are talking about rotation horror in angles, you are right, we want rock solid effect and control, this is the way to go. I just need help in understanding it. I will get this I promise!!