Page 1 of 1

More flexible model rotating

Posted: Sun Dec 23, 2007 15:17
by Enjay
The rotating command for modeldefs is cool. It can be used for far more than just making a pickup spin. eg The electrical ball thing from Strife with the green ball rotating inside 3 columns can be done far more smoothly with a rotating model for the ball and a second static one for the columns than with an animated model - even with additional frames and interpolation.

So I'd like to see more rotation options if possible. It's be nice to be able to specify rotation speed and direction. Perhaps both could be achieved with a single parameter. A number for speed or rotation (or time taken for 1 rotation if that's better). If the number is +ve, the current default direction is used. If it's -ve then it rotates in the reverse direction.

Any chance?

Posted: Wed Dec 26, 2007 16:05
by ChupaReaper
What about a speed value for each direction (rotate x,y,z)? 255 being max, 0 not at all and -255 reverse?

Posted: Wed Dec 26, 2007 21:21
by TheDarkArchon
Or maybe something like this: (rotate,x,y,z), rotate being the angle in degrees and x, y and z being multipliers of the angle.

(This is in no way inspired by glRotate. Nu-uh)

Posted: Thu Dec 27, 2007 14:41
by Torr Samaho
I like the idea and I already partially implemented it :). But I think you also need to be able to specify the center of the rotation, otherwise the model can be rotated into the ground. Opinions?

Posted: Thu Dec 27, 2007 15:17
by Enjay
Hmmm... yes I see what you mean by that. A common position for the origin of a model that stands on the ground is in the middle of the object, viewed from above, but at ground level. Rotating that anything other than horizontally would push it into the ground. But placing the origin higher in the model would mean the object sits in the ground anyway.

For a simple, static decoration, I would make the decoration have the +nogravity flag and then place the thing itself a suitable number of units above the floor. However, that would mean that it couldn't be used on a moving floor, for example. And then what if I wanted to have something apparently rolling along the ground...

So, yes, I think some sort of Z offset built into the model definition would be good. I think it would work best to have a number that specified a Z offset relative to the model's origin purely for rotating purposes. It would need to be possible to enter the number as either +ve ore -ve (takes care of hanging objects and other odd situations). A system like that would leave all the normal model creation and placing stuff as it is at present but allow things to be tailored for rotating via the modeldef lump.

Posted: Thu Dec 27, 2007 15:26
by Torr Samaho
I added zoffset support to MODELDEF some time ago, it's definitely in GZDoom 1.0.29. Just add a "zoffset float" line to your MODELDEF.

And I just finished a first implementation of the customizable rotation:

Code: Select all

- Made the model rotation customizable:
	rotation-speed  float: Specify the speed of the rotation
	rotation-vector float float float: Specify the x, y and z component of the vector of the rotation
	rotation-center float float float: Specify the x, y and z coordinate of the center of the rotation
	(Defining rotation initializes the speed to 1, the vector to (0,1,0) and the center to (0,0,0))
With this, you should be able to achieve the rotation you described.

Posted: Mon Dec 31, 2007 10:28
by ZardoZ
My small suggestion :
Displace the object over the ground or object origin cords. This will allow to fix some problems like half model are under the floor, etc...

Posted: Mon Dec 31, 2007 10:45
by Torr Samaho
This is already possible with zoffset.