FAQFAQ    Board RulesBoard Rules    SearchSearch    LotteryLottery    RouletteRoulette    UsergroupsUsergroups
     RegisterRegister  ProfileProfile    Log in to check your private messagesLog in to check your private messages    Shop    Log inLog in 
View posts since last visit View your posts View unanswered posts

Rotation via script

 
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding
View previous topic :: View next topic  
Author Message
pinkshit

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 06 Jun 2013
Posts: 68
Location: Hungary - Budapest
200 Bank Notes
Items

PostPosted: Sun Feb 01, 2015 1:52 pm    Post subject: Rotation via script Reply with quote

Hi!

I've opened this topic because we need some help. Thanks to DJBOZKOSZ we have a great script to rotate things in game like the cars in Carcyclopedia.
Here is the script, you have to insert it and invoked for your own frame:

dim_frm 4
dim_flt 5

findframe 0, "My frame"
findframe 1, "My frame2"
findframe 2, "My frame3"
findframe 3, "My frame4"

label PLEASE_ROT
commandblock 0
commandblock 1
if flt[0] > 360.0, RESET_CNT, -1
let flt[1] = flt[0]
math_cos 1
let flt[2] = 0.0
let flt[3] = flt[0]
math_sin 3
let flt[4] = 0.0
frm_setrot 0, 1
frm_setrot 1, 1
frm_setrot 2, 1
frm_setrot 3, 1

getticktime 1
let flt[1] = flt[1] / 100.0
let flt[0] = flt[0] + flt[1]
goto PLEASE_ROT

label RESET_CNT
let flt[0] = 0
goto PLEASE_ROT

This is fully working

Our question is:
We want to change the angle of the rotation cause this script is rotate the things like in caryclopedia but how can we change it to rotate like a clock. Everyone knows the analog clocks and their rotations. I don't know what angle is it (X, Y, Z)so if anybody knows something please post!

Regards
Back to top
View user's profile Send private message
rays

New Member
New Member


Joined: 24 Apr 2016
Posts: 10

29 Bank Notes
Items

PostPosted: Tue Mar 28, 2017 3:22 pm    Post subject: Re: Rotation via script Reply with quote

pinkshit wrote:
Hi!

I've opened this topic because we need some help. Thanks to DJBOZKOSZ we have a great script to rotate things in game like the cars in Carcyclopedia.
Here is the script, you have to insert it and invoked for your own frame:

dim_frm 4
dim_flt 5

findframe 0, "My frame"
findframe 1, "My frame2"
findframe 2, "My frame3"
findframe 3, "My frame4"

label PLEASE_ROT
commandblock 0
commandblock 1
if flt[0] > 360.0, RESET_CNT, -1
let flt[1] = flt[0]
math_cos 1
let flt[2] = 0.0
let flt[3] = flt[0]
math_sin 3
let flt[4] = 0.0
frm_setrot 0, 1
frm_setrot 1, 1
frm_setrot 2, 1
frm_setrot 3, 1

getticktime 1
let flt[1] = flt[1] / 100.0
let flt[0] = flt[0] + flt[1]
goto PLEASE_ROT

label RESET_CNT
let flt[0] = 0
goto PLEASE_ROT

This is fully working

Our question is:
We want to change the angle of the rotation cause this script is rotate the things like in caryclopedia but how can we change it to rotate like a clock. Everyone knows the analog clocks and their rotations. I don't know what angle is it (X, Y, Z)so if anybody knows something please post!

Regards


Hi,
Can anyone please help me with this script ? I want to rotate an object say a barrel. How can we do this ?
Thanks
Back to top
View user's profile Send private message
MatteoCapoletti

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 05 Mar 2013
Posts: 507

975 Bank Notes
Items

PostPosted: Mon Apr 17, 2017 5:12 pm    Post subject: Rotation via script Reply with quote

Geez I just saw how old the original post was....but oh well...Wink

Nothing in this script indicates rotation axis can be changed

Okay well this thing pissed me off because I couldn't make it work. But my philosophy with modding Mafia has always been, when the game shuts the door, I'll bust in through the window Wink





So I did it the classic animation way. Made a truck load of barrel models each one slightly more rotated than the last (36 barrels at 10 degree rotation to be exact) and turned them on and of in sequence to create the animation illusion. I Nested the on and offing of the models to prevent flickering If I was going to keep this I would spend more time tweaking it, its a little stodgy....but I just wanted to see if I could do it.

Script Below the pictures of all the models I added. You might notice there are few models missing, they were misplaced.


Code:

dim_flt 1
dim_frm 36

FindFrame 0,"barrel2"
FindFrame 1,"barrel3"
FindFrame 2,"barrel4"
FindFrame 3,"barrel5"
FindFrame 4,"barrel6"
FindFrame 5,"barrel7"
FindFrame 6,"barrel8"
FindFrame 7,"barrel9"
FindFrame 8,"barrel10"
FindFrame 9,"barrel11"
FindFrame 10,"barrel12"
FindFrame 11,"barrel13"
FindFrame 12,"barrel14"
FindFrame 13,"barrel15"
FindFrame 14,"barrel16"
FindFrame 15,"barrel17"
FindFrame 16,"barrel18"
FindFrame 18,"barrel20"
FindFrame 20,"barrel22"
FindFrame 21,"barrel23"
FindFrame 22,"barrel24"
FindFrame 23,"barrel25"
FindFrame 25,"barrel27"
FindFrame 26,"barrel28"
FindFrame 27,"barrel29"
FindFrame 28,"barrel30"
FindFrame 29,"barrel31"
FindFrame 30,"barrel32"
FindFrame 31,"barrel33"
FindFrame 33,"barrel35"
FindFrame 34,"barrel36"
FindFrame 35,"barrel37"

frm_seton 0,0
frm_seton 1,0
frm_seton 2,0
frm_seton 3,0
frm_seton 4,0
frm_seton 5,0
frm_seton 6,0
frm_seton 7,0
frm_seton 8,0
frm_seton 9,0
frm_seton 10,0
frm_seton 11,0
frm_seton 12,0
frm_seton 13,0
frm_seton 14,0
frm_seton 15,0
frm_seton 16,0
frm_seton 18,0
frm_seton 20,0
frm_seton 21,0
frm_seton 22,0
frm_seton 23,0
frm_seton 25,0
frm_seton 26,0
frm_seton 27,0
frm_seton 28,0
frm_seton 29,0
frm_seton 30,0
frm_seton 31,0
frm_seton 33,0
frm_seton 34,0
frm_seton 35,0




label 101
frm_seton 0,1
wait 100
frm_seton 1,1
frm_seton 0,0
wait 100
frm_seton 2,1
frm_seton 1,0
wait 100
frm_seton 3,1
frm_seton 2,0
wait 100
frm_seton 4,1
frm_seton 3,0
wait 100
frm_seton 5,1
frm_seton 4,0
wait 100
frm_seton 6,1
frm_seton 5,0
wait 100
frm_seton 7,1
frm_seton 6,0
wait 100
frm_seton 8,1
frm_seton 7,0
wait 100
frm_seton 9,1
frm_seton 8,0
wait 100
frm_seton 10,1
frm_seton 9,0
wait 100
frm_seton 11,1
frm_seton 10,0
wait 100
frm_seton 12,1
frm_seton 11,0
wait 100
frm_seton 13,1
frm_seton 12,0
wait 100
frm_seton 14,1
frm_seton 13,0
wait 100
frm_seton 15,1
frm_seton 14,0
wait 100
frm_seton 16,1
frm_seton 15,0
wait 100
frm_seton 18,1
frm_seton 16,0
wait 100
frm_seton 20,1
frm_seton 18,0
wait 100
frm_seton 21,1
frm_seton 20,0
wait 100
frm_seton 22,1
frm_seton 21,0
wait 100
frm_seton 23,1
frm_seton 22,0
wait 100
frm_seton 25,1
frm_seton 23,0
wait 100
frm_seton 27,1
frm_seton 25,0
wait 100
frm_seton 28,1
frm_seton 27,0
wait 100
frm_seton 29,1
frm_seton 28,0
wait 100
frm_seton 30,1
frm_seton 29,0
wait 100
frm_seton 31,1
frm_seton 30,0
wait 100
frm_seton 33,1
frm_seton 31,0
wait 100
frm_seton 34,1
frm_seton 33,0
wait 100
frm_seton 35,1
frm_seton 34,0
wait 100
frm_seton 0,1
frm_seton 35,0

goto 101




I know the possibility of a vertical spin exists because it works on the paddle wheel of the boat and the windmill at the motel. But in the half hour I played with this, I did not find it
Back to top
View user's profile Send private message
ASM.

Mafiascene Veteran Modder
Mafiascene Veteran Modder


Joined: 10 Jan 2014
Posts: 88

201 Bank Notes
Items

PostPosted: Wed Apr 19, 2017 12:03 am    Post subject: Rotation via script Reply with quote

MatteoCapoletti wrote:

Geez I just saw how old the original post was....but oh well...Wink

Yeah, we're a bit late to the party. Smirking

pinkshit wrote:

Our question is:
We want to change the angle of the rotation cause this script is rotate the things like in caryclopedia but how can we change it to rotate like a clock. Everyone knows the analog clocks and their rotations. I don't know what angle is it (X, Y, Z)so if anybody knows something please post!

If you want the object to rotate in clockwise direction, you just need to invert the angle. This could be done for example by replacing the lines
Code:

let flt[1] = flt[0]
let flt[3] = flt[0]

with
Code:

let flt[1] = -flt[0]
let flt[3] = -flt[0]

MatteoCapoletti wrote:

I know the possibility of a vertical spin exists because it works on the paddle wheel of the boat and the windmill at the motel. But in the half hour I played with this, I did not find it

You can change the rotation axis by changing the index literal 3 of the lines
Code:

let flt[3] = flt[0]
math_sin 3

to 2 (X-axis), 3 (Y-axis) or 4 (Z-axis).

A more generic approach however is to compute the quaternion via quat_make xx, yy, zz where

  • xx - The index of the start of the resulting quaternion (4 flts)
  • yy - The index of the start of the rotation axis (3 flts)
  • zz - The rotation angle (in radians)

Example:
Code:

dim_frm 1
dim_flt 9

findframe 0, "popel11"

// rotation axis
let flt[2] = 1.0
let flt[3] = 0.0
let flt[4] = 0.0

vect_normalize 2

label PLEASE_ROT
commandblock 0
commandblock 1
if flt[0] > 360.0, RESET_CNT, -1

// convert angle to radians and compute quaternion
let flt[1] = flt[0] * 3.1415
let flt[1] = flt[1] / 180.0
quat_make 5, 2, 1

frm_setrot 0, 5

getticktime 1
let flt[1] = flt[1] / 10.0
let flt[0] = flt[0] + flt[1]
goto PLEASE_ROT

label RESET_CNT
let flt[0] = 0
goto PLEASE_ROT

This code should rotate the frame popel11 around the X-axis. Doing
Code:

let flt[2] = 0.0
let flt[3] = 1.0
let flt[4] = 0.0

instead for example should make the object rotate around the Y-axis, just like the original script by pinkshit/DJBOZKOSZ does.

rays wrote:

Can anyone please help me with this script ? I want to rotate an object say a barrel. How can we do this ?

What specifically are you having problems with?
Back to top
View user's profile Send private message
GOLOD55

New Member
New Member


Joined: 26 Apr 2016
Posts: 5

13 Bank Notes
Items

PostPosted: Wed Apr 19, 2017 6:40 am    Post subject: Rotation via script Reply with quote

quat constructing (via sincos or quat_make) is good.
but one of the other ways has the most lil script seem - via quat_slerping:

dim_frm 1
dim_flt 20

findframe 0, "popel11"

vect_set 1,1,0,0
vect_set 4,0,0,0
vect_set 7,-1,0,0
//frm_getrot 0,1
//frm_setrot 0,1

label rot
let flt[9]=flt[9]+0.01
quat_slerp 10,1,5,9
frm_setrot 0,10
goto rot


PS:
quat1=start(0 rot)
quat5=target(180deg Y here)
+-0.01=direction&speed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Generation Time: 0.035 | Queries: 19