Jump to content
Ranwer135

Dialog - Returning Mouse Drag?

Recommended Posts

Hey guys,

This is going to be one hell of a question, but here we go. I have a Picture Box that is going to be interact-able. Now I would like to be able to rotate a 3D object the more you drag the mouse on the X axis. If your mouse is moving right, the 3D object will rotate right on the Y axis and vice versa.

Any ideas on this?

Thanks,

Rawner135

Edited by Ranwer135

Share this post


Link to post
Share on other sites

I pretty sure it is not possible to rotate controls. Vote for ctrlAngle commands.

 

Only two ways I can think of, and i presuming rotating an image..

1. Have a collections of images you can replace dependant on your value.

2. Use an invisible map control except for markers. Have a marker that is your image and rotate the marker.

Share this post


Link to post
Share on other sites

Hi again,

Sorry, I should have explained properly. :p (silly me...)

I want to rotate a 3D object from a dialog using the mouse' X axis. (Map Builder for Arma 3 has done this technique before)

Share this post


Link to post
Share on other sites

I have a Picture Box that is going to be interact-able. Now I would like to be able to rotate a 3D object the more you drag the mouse on the X axis. If your mouse is moving right, the 3D object will rotate right on the Y axis and vice versa.

 

 

I want to rotate a 3D object from a dialog using the mouse' X axis. (Map Builder for Arma 3 has done this technique before)

 

I am also puzzled what you want to do to be honest. If what you want is supposed to happen within your displayed dialog, then go for (almighty) Larrow's solution.

 

However, maybe you're trying to rotate an actual object in actual 3d space, like putting down fortifications for example and setting their direction. In that case, there's lot's of ways to go about it. Not sure if it's the best solution but I have used combinations of MouseButtonDown, MouseMoving and MouseButtonUp to achieve something similar. Check the list of UI-Eventhandlers but I'm pretty sure you already know those.

Share this post


Link to post
Share on other sites

Hi again,

Thanks for the reply. Yeah what I mean by Object is a dialog 3D object. But no worries! I have fixed the issue by implementing a slider bar. Now I can smoothly rotate my character projected on the screen. (You'll see it at the very last page in my mod found in signature. Page 7-8 to be precise ;) )

Thanks guys, you have just made Arma with new DayZ SA-like features for me. :p (not really, but being sarcastic yeah)

Share this post


Link to post
Share on other sites

I'm not sure if it's possible to rotate the character using setDirAndUp in your dialog but if you can, this is the code you'd want to use.

 

Add this to your picture box control definition:

onMouseDown = "isMouseDown == true";
onMouseUp = "isMouseDown == false";
onMouseMoving = "[myObject, _this select 1, _this select 2] call rotate";

rotate function:

rotate =
{
	if (isMouseDown) then
	{
		_objectDir = _objectDir - (_this select 1);
					
		(_this select 0) setDir _objectDir;

		_objectPitch = (_objectPitch - (_this select 2)) max -90 min +90;
		[
			(_this select 0),
			_objectPitch,
			0
		] call bis_fnc_setpitchbank;
		objectDirPitchBank =
		[
			_objectDir,
			_objectPitch,
			_objectBank
		];
	};
};

Note that it is not possible to set bank with this function, I haven't figured out the code to make that work yet, nor do I see any use for it in what you need it for.

 

Also, make sure you define 2 global variables, "isMouseDown" and "objectDirPitchBank", with default values of false and [0,0,0], respectively. "myObject" should also be a global variable and refers to the actual man object you are rotating around.

  • Like 1

Share this post


Link to post
Share on other sites

I think you're after these commands

 

ctrlModelDirAndUp

ctrlSetModelDirAndUp

 

You need to set up onMouseMoving onMouseButtonDown and onMouseButtonUp event handlers.

 

You can then measure the distance a mouse cursor has travelled when the mouse button is pressed. Put this onto a scale and translate it into a direction offset for the model

 

 

Hope this helps

  • Like 1

Share this post


Link to post
Share on other sites

Hey guys,

My best regards to your replies and solutions. Now that you guys have mentioned possible ways for it to work, I am now facing an issue.

For the slider bar, I am using "ctrlSetModelDirandUp". However, the uniform model does not rotate properly on it's Y axis, so I have to constantly use "ctrlSetPosition" to correct this behaviour. (It also makes the rotation look jaggy as well)

I have over 11 "if" statements to rotate the character, and is already coming to conclusion that it is not the best "efficient" code I have made.

Probably the best description I can make out of this issue, is that the uniform acts as if its a moon orbiting nothing in the centre.

I know that it can be possible to rotate the character without the slider bar, but the uniform issue is the only thing standing in its way.

Share this post


Link to post
Share on other sites

I'm not sure if it's possible to rotate the character using setDirAndUp in your dialog but if you can, this is the code you'd want to use.

Add this to your picture box control definition:

onMouseDown = "isMouseDown == true";
onMouseUp = "isMouseDown == false";
onMouseMoving = "[myObject, _this select 1, _this select 2] call rotate";
rotate function:

rotate =
{
	if (isMouseDown) then
	{
		_objectDir = _objectDir - (_this select 1);
					
		(_this select 0) setDir _objectDir;

		_objectPitch = (_objectPitch - (_this select 2)) max -90 min +90;
		[
			(_this select 0),
			_objectPitch,
			0
		] call bis_fnc_setpitchbank;
		objectDirPitchBank =
		[
			_objectDir,
			_objectPitch,
			_objectBank
		];
	};
};
Note that it is not possible to set bank with this function, I haven't figured out the code to make that work yet, nor do I see any use for it in what you need it for.

Also, make sure you define 2 global variables, "isMouseDown" and "objectDirPitchBank", with default values of false and [0,0,0], respectively. "myObject" should also be a global variable and refers to the actual man object you are rotating around.

Looks great! Will look at it tonight, thanks dreadedEntity! :D (And hey I'm sorry about that comment I made in that other thread about names, I was really grouchy after explaining to a few users about rules & regulations of models which they ignored.)

I think you're after these commands

ctrlModelDirAndUp

ctrlSetModelDirAndUp

You need to set up onMouseMoving onMouseButtonDown and onMouseButtonUp event handlers.

You can then measure the distance a mouse cursor has travelled when the mouse button is pressed. Put this onto a scale and translate it into a direction offset for the model

Hope this helps

Thanks for the heads-up! Yeah I am currently using those commands you have mentioned for the RscObjects, but will look into the EHs.

But in any case, if I manage to get this working perfectly, I might make a public release of this, within limitations. ;) (but I do know that it is possible, since DayZ SA is not based off VBS, so I guess there is more hope to us all in Arma 3)

Kind Regards,

Rawner135

Share this post


Link to post
Share on other sites

Looks great! Will look at it tonight, thanks dreadedEntity! :D (And hey I'm sorry about that comment I made in that other thread about names, I was really grouchy after explaining to a few users about rules & regulations of models which they ignored.)

No big, I was kinda proud of myself.

 

Did it work?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×