Rotating a GUISprite

Started by Murdock, May 06, 2016, 05:26 AM

Previous topic - Next topic

Murdock

I have a sprite which represents a roulette wheel which I want to spin like a roulette wheel would do, but how can I achieve this?
I have tried passing different values to the Rotation3D parameter of Set3DTransform, for instance m_wheel.Set3DTransform(m_wheel.Position3D, Vector(2.0, 1.0, 1.0), m_wheel.Size3D); or m_wheel.Set3DTransform(m_wheel.Position3D, Vector(100.0, 0.0, 10.0), m_wheel.Size3D); but this does not have any effect.
The second thing I tried is adding a value to one of the rotation coordinates as follows:
local rot = m_wheel.Rotation3D;
rot.X += 10.0;
rot.Y += 10.0;
rot.Z += 10.0;
m_wheel.Set3DTransform(m_wheel.Position3D, rot, m_wheel.Size3D);

Again, this did not have any effect on the sprite's rotation.
I noticed there is a GUI_FLAG_3D_ENTITY flag for GUI elements which I am not sure what it is for. Hoping that it would enable setting the sprite rotation I did try to add it to my sprite, but this end up not showing the sprite at all.

Below you can find my clientside code along with a screenshot of how it looks like.
Any help on how to rotate the wheel is appreciated.

m_window <- null;
m_wheel <- null;
m_ball <- null;

// Window
m_window <- GUIWindow(VectorScreen(100, 100),
VectorScreen(450, 450),
Colour(0, 0, 0),
"Roulette Wheel",
GUI_FLAG_TEXT_TAGS );

m_window.AddFlags(GUI_FLAG_VISIBLE | GUI_FLAG_DRAGGABLE | GUI_FLAG_AUTO_RESIZE | GUI_FLAG_WINDOW_TITLEBAR);
m_window.RemoveFlags(GUI_FLAG_WINDOW_RESIZABLE);

// Wheel
m_wheel <- GUISprite("roulette-wheel.png", VectorScreen(0, 0));
m_wheel.Size = VectorScreen(450, 450);
m_wheel.AddFlags(GUI_FLAG_VISIBLE); // GUI_FLAG_3D_ENTITY
m_wheel.RemoveFlags(GUI_FLAG_MOUSECTRL | GUI_FLAG_DRAGGABLE | GUI_FLAG_AUTO_RESIZE);

// Ball

m_ball <- GUISprite("roulette-ball.png", VectorScreen(100, 0));
m_ball.Size = VectorScreen(16, 15);
m_ball.AddFlags(GUI_FLAG_VISIBLE);
m_ball.RemoveFlags(GUI_FLAG_MOUSECTRL | GUI_FLAG_DRAGGABLE | GUI_FLAG_AUTO_RESIZE);

// Attach
m_window.AddChild(m_wheel);
m_window.AddChild(m_ball);

m_wheel.Set3DTransform(m_wheel.Position3D, Vector(2.0, 1.0, 1.0), m_wheel.Size3D);


Mötley

I do not see where
rot.X += 10.0;
rot.Y += 10.0;
rot.Z += 10.0;
Is being used for.. But you know the script way better than I do..

You should play with

::m_wheel.Rotation3D = ( * PI / 180 );This should do something strange at least..

Sorry if wrong :D

Stormeus

3D rotation requires the 3D flag to be set, and 3D elements place the GUI into the game world instead of just flat on the screen. That's why rotation has no effect when unflagged and why it disappears when flagged.

I don't think client-side scripts can be rotated at the moment, though I think this is just an oversight that can be patched in pretty easily.

NicusorN5

Wait... @motley is pi defined in Squrrel . Also it is infinite , π = 3.141592...Resulting maybe in a error or a glitch. LOL
:edit:  Didn't see @stormeus post...

Mötley

It should either spin the wheel, or cause a crash(but should not). or disappear off the screen(but should not as I used a 180 rotation)

99.1 percent chance of rotating or doing something unknown.

I forget where I happened to see PI, But it is part of squirrel if i recall correctly,.

KAKAN

Quote from: Mötley on May 07, 2016, 08:35 PMI forget where I happened to see PI, But it is part of squirrel if i recall correctly,.
print( PI );It's still there.
oh no

Mötley

you forgot print("" + PI + "");

DizzasTeR

print( format( "%.2f", PI ) );

KAKAN

Quote from: Doom_Kill3R on May 08, 2016, 07:12 AMprint( format( "%.2f", PI ) );
Don't worry, the number is not that big :D

Quote from: Mötley on May 08, 2016, 06:06 AMyou forgot print("" + PI + "");
print functions accepts float, integers, strings etc
oh no

DizzasTeR

@KAKAN, You know nothing

Personal opinion on the topic is that, I also didn't notice any rotation functions for sprites, or am I confused with the function being available but not aware of it?

KAKAN

Quote from: Doom_Kill3R on May 08, 2016, 11:34 AM@KAKAN, You know nothing
I was talking within Squirrel.
Squirrel won't return so large number. The output of pie must not be more than: 3.141592653
you can use print( PI ); to see it :D
oh no

.

Quote from: KAKAN on May 08, 2016, 11:41 AMSquirrel won't return so large number. The output of pie must not be more than: 3.141592653
you can use print( PI ); to see it :D

You sure about that?

print(format("%.99f", PI));
[SCRIPT]  3.141592741012573200000000000000000000000000000000000000000000000000000000000000000000000000000000000
.

KAKAN

Quote from: . on May 08, 2016, 05:15 PM
Quote from: KAKAN on May 08, 2016, 11:41 AMSquirrel won't return so large number. The output of pie must not be more than: 3.141592653
you can use print( PI ); to see it :D

You sure about that?

print(format("%.99f", PI));
[SCRIPT]  3.141592741012573200000000000000000000000000000000000000000000000000000000000000000000000000000000000
off:
Pretty yes.
http://i.imgur.com/qpT0FKo.png
oh no

Thijn

Quote from: KAKAN on May 08, 2016, 05:49 PM
Quote from: . on May 08, 2016, 05:15 PM
Quote from: KAKAN on May 08, 2016, 11:41 AMSquirrel won't return so large number. The output of pie must not be more than: 3.141592653
you can use print( PI ); to see it :D

You sure about that?

print(format("%.99f", PI));
[SCRIPT]  3.141592741012573200000000000000000000000000000000000000000000000000000000000000000000000000000000000
off:
Pretty yes.
http://i.imgur.com/qpT0FKo.png
I'm unsure what you're trying to prove.

Murdock

Quote from: Stormeus on May 06, 2016, 02:29 PM3D rotation requires the 3D flag to be set, and 3D elements place the GUI into the game world instead of just flat on the screen. That's why rotation has no effect when unflagged and why it disappears when flagged.

I don't think client-side scripts can be rotated at the moment, though I think this is just an oversight that can be patched in pretty easily.

Hopefully rotation methods can be added in the next update, right now we can't port any sprites such as speedometers or this roulette wheel as example.

I've tried adding the 3D entity flag and setting the 3D position to the position of the player to see what it does, but nothing seems to appear besides a load of these messages in the debuglog:
"Warning in RpGeometryStreamReadOperation::fixTriangleMaterialIndices: Fixed 1635072 invalid material indices in mesh triangle list"

Do you have an example on how to create 3D entities?