ScriptSpot

Forum topic · General Scripting

quaternion rotation and UI

By alecb513 · 2015-04-09

Description

Hello, I'm trying to create a UI control that (in this case a spinner) rotates geometry that's stored in an array. Converting the angle axis to quat is working really well. However, with the way I have it set up, when you switch between the spinners that control the x, y, and z rotation the geometry will reset the pivot point to work with the corresponding axis. I understand this from me assigning values for x y and z.

Is there a way to put some sort of dynamic variable for x y and z, so it can work with quaternion math, but know that the rotation should be on a local x y or z based on what spinner is being used?


on spn_xSlide changed true do
(
	for i = 1 to myArray.count do
		
	(
		myArray[i].rotation = (angleaxis (spn_xSlide.value)[1, 0, 0]) as quat
	)
)
	
on spn_ySlide changed true do
(
	for i = 1 to myArray.count do
	(
		myArray[i].rotation = (angleaxis (spn_ySlide.value)[0, 1, 0]) as quat
	)
)

on spn_zSlide changed true do
(
	for i = 1 to myArray.count do
	(
		myArray[i].rotation = (angleaxis (spn_zSlide.value)[0, 0,1]) as quat
	)
)

This is my first post! Please let me know if i did something stupid while submitting

Comments (3)

Thanks!

alecb513 · 2015-04-13

Thanks for your hep! It worked perfectly!

`

pixamoon · 2015-04-23

great :) happy it helped

`

pixamoon · 2015-04-09

yes, because on every spn_Slide change it reset others angles to 0

maybe you can start from (eulerAngles x y z)

it can look this way:


on spn_xSlide changed val do
(
	for i = 1 to myArray.count do
	(
		myArray[i].rotation = (eulerAngles spn_xSlide.value spn_ySlide.value spn_zSlide.value) as quat
	)
)
 
on spn_ySlide changed val do
(
	for i = 1 to myArray.count do
	(
		myArray[i].rotation = (eulerAngles spn_xSlide.value spn_ySlide.value spn_zSlide.value) as quat
	)
)
 
on spn_zSlide changed val do
(
	for i = 1 to myArray.count do
	(
		myArray[i].rotation = (eulerAngles spn_xSlide.value spn_ySlide.value spn_zSlide.value) as quat
	)
)

Hope it helps,
Pixamoon