multiply with small value (in cob script)

multiply with small value (in cob script)

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Squall815
Posts: 9
Joined: 23 Jan 2009, 16:26

multiply with small value (in cob script)

Post by Squall815 »

hello

here is my problem :
I want to make the bos/cob script to animate my unit and I would like to use the values give by blender.
unfortunately the values from blender doesn't works (they 're too big) so I need to multiply them by a coefficient. (approximatively 0.5)
So I try this code :

Code: Select all

#define COEFFBLENDER	  0.5
move t2_barrel to z-axis ([-2]*COEFFBLENDER) speed [5.00];
-2 is the value from blender but -1 looks better in spring.
but when I lunch spring ans test my unit it's like the line doesn't exist
(the piece "t2_barrel") I try lots of thing and I found this :
It works only if COEFFBLENDER > 1.

I finally find a way but I would to know if it's a bug or if it's because I don't use the right syntax.

By the way this works :

Code: Select all

#define COEFFBLENDER	  5
move t2_barrel to z-axis ([-2]*COEFFBLENDER)/10 speed [5.00];
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: multiply with small value (in cob script)

Post by imbaczek »

stupid scriptor truncates float constants. try dividing by 2.
User avatar
Squall815
Posts: 9
Joined: 23 Jan 2009, 16:26

Re: multiply with small value (in cob script)

Post by Squall815 »

yes divide by 2 works, thanks

Actually the coefficient is 0.357 I also find a solution with multiplication (I prefer multiplication it's make your life easier ).

I just find strange that you can't multiply by a number smaller than 1 but perhaps for some reason it's ease spring code.

In any case multiply by 5 and divide by 10 works but it's two operations so do you think it's more efficient to divide by 2.8.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: multiply with small value (in cob script)

Post by imbaczek »

*357/1000 should work fine, but can easily overflow. suggest 375/1000 == 3/8.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: multiply with small value (in cob script)

Post by lurker »

Squall815 wrote:I just find strange that you can't multiply by a number smaller than 1 but perhaps for some reason it's ease spring code.
No, it's entirely scriptor.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: multiply with small value (in cob script)

Post by KDR_11k »

Squall815 wrote:Actually the coefficient is 0.357
Is that perchance the difference between one unit in your 3d app and [1] in your BOS? You can adjust the value of [1] in your compiler settings, set it to 65536 to make it match the size of the units in the 3d apps.
Post Reply

Return to “Engine”