PDA

View Full Version : reset rotated object to original position



Lionheart008
18-11-2010, 14:01
hello all. I wanted only to know what's possible to reset a rotated object (here axisfork or torus) to zero or original position ? I have made to rotate some objects (push move/stop button). I can reset the pushed objects to zero or original position, but not my axis fork or the rotated torus. my idea was to reset all objects in their original (TBGL_EntitySetPos) Position that works for pushed objects only. See second picture with this problem


If StartStop 0 Then TBGL_EntityTurn(%sScene, %eBox, 0, 40/FrameRate, 0) TBGL_EntityPush(%sScene, %eFloor, 0.02, 0, 0) TBGL_EntityTurn(%sScene, %eTorus, 10/FrameRate, 0, 0 ) 'TBGL_EntityTurn(%sScene, %eMyAxislist, 0, 20/FrameRate, 0) TBGL_EntityPush(%sScene, %eSphere1, 0, 0.02, 0.01) TBGL_EntityPush(%sScene, %eBox, 0, 0.025, -0.01) EndIf '------------------------------> reset for position If resetall 0 Then '... TBGL_EntitySetPos(%sScene, %eBox, 0.8, 1.1, 0.8) TBGL_EntitySetPos(%sScene, %eMyAxislist, 0, -0.5, 0) TBGL_EntitySetPos(%sScene, %eMyAxislist, 0, 0, 0) TBGL_EntitySetPos(%sScene, %eFloor, 0, -4, 0) TBGL_EntitySetPos(%sScene, %eSphere1, 4, 0.55, 1) 'TBGL_EntityPush(%sScene, %eTorus, 0, 0.5, 0 ) TBGL_EntitySetPos(%sScene, %eTorus, -4, -1, -1 ) End If any help would be nice, best regards, frank
ps: project attached as zipfile

pps: I have problems to show code tags (in editpost) correctly here at the forum ;(
the second line below fonts, size, A(textcolor), smileys... didn't work at all for me

Michael Clease
18-11-2010, 18:04
You could just store the original information for each entity in the userdata area when you create the Entity that would be valid until the entity is destroyed or just use a UDT array.


TYPE tTitties
ID AS LONG 'Entity number
X AS SINGLE
X AS SINGLE
Z AS SINGLE
END TYPE

DIM myTitties(1024) AS tTitties

mytitties(1).ID = 1
mytitties(1).X = 1
mytitties(1).Y = 1
mytitties(1).Z = 1


TBGL_EntitySetPos( SceneID, mytitties(1).ID, mytitties(1).X, mytitties(1).Y, mytitties(1).Z )

Petr Schreiber
18-11-2010, 20:43
Frank - to cancel all rotations, just use:


TBGL_EntitySetRot( sScene, eEntity, 0, 0, 0)



Petr

Lionheart008
18-11-2010, 21:48
hi mike and petr :) thanks for help. and mike for making me laughing (Type Ttitties..!).
yes, petr, I have tried this way too with setposition to 0,0,0. But I found my little mistake some minutes before. => I've just forgotten to rotate also the entity for axisfork and torus! only to set the position to 0,0,0 didn't work alone ;) correct way must be:

a) TBGL_EntitySetPos(%sScene, %eMyAxislist, 0, 0, 0)
aa) TBGL_EntitySetRot(%sScene, %eMyAxislist, 0, 0, 0 )

b) TBGL_EntitySetPos(%sScene, %eTorus, -4, -1, -1 )
TBGL_EntitySetRot(%sScene, %eTorus, 0, 0, 90 )

'------------------------------> start-stop If StartStop 0 Then TBGL_EntityTurn(%sScene, %eBox, 0, 40/FrameRate, 0) TBGL_EntityPush(%sScene, %eFloor, 0.02, 0, 0) TBGL_EntityTurn(%sScene, %eTorus, 10/FrameRate, 0, 0 ) TBGL_EntityTurn(%sScene, %eMyAxislist, 0, 20/FrameRate, 0) TBGL_EntityPush(%sScene, %eSphere1, 0, 0.02, 0.01) TBGL_EntityPush(%sScene, %eBox, 0, 0.025, -0.01) EndIf '------------------------------> reset for position If resetall 0 Then '... TBGL_EntitySetPos(%sScene, %eBox, 0.8, 1.1, 0.8) TBGL_EntitySetPos(%sScene, %eMyAxislist, 0, 0, 0) TBGL_EntitySetRot(%sScene, %eMyAxislist, 0, 0, 0 ) TBGL_EntitySetPos(%sScene, %eFloor, 0, -4, 0) TBGL_EntitySetPos(%sScene, %eSphere1, 4, 0.55, 1) TBGL_EntitySetPos(%sScene, %eTorus, -4, -1, -1 ) TBGL_EntitySetRot(%sScene, %eTorus, 0, 0, 90 ) End If '------------------------------> thanks both guys, correct example I add as zip file (*.tbasic version). frank

ps: all infos about handling this tbgl example you can find via infobox button!