- Joined
- Sep 6, 2013
- Messages
- 6,742
Hello guys,
some time ago when trying around with Effect natives I had no luck to effecively bring to work
My problem is the EffectOrientation works only with yaw, pitch roll, (x,y, z - axis rotation respectively), and not with facing.
In my case, I want to convert a 3D facing between two points to those axis rotations so I can use the native.
Here is some attempt, but I changed it too many times, so the current state is kind of pending ( so don't care is something makes no sense):
Basically, I want a function that lets an effect face the point xyz.
I'm using this in an orbital movement system, I tried to finish. You can ignore maybe the texts, but the demo, as the texts are about movement, and not orientation.
In the attached demo, there's a trigger "Orbit Demo 2 Copy" (the only demo that is activated^^), which calls the function
---
It's pretty easy to get it working with converting only 1 axis rotation, so let's say only x-axix, so on a plane, but somehow I don't get it done properly when rotating around all three axis.
some time ago when trying around with Effect natives I had no luck to effecively bring to work
BlzSetSpecialEffectOrientation(yaw, pitch, roll)
for my needs. The other parts I needed worked pretty fast, so this is now pretty frustrating for me, as I tried too many attempts already without real success.My problem is the EffectOrientation works only with yaw, pitch roll, (x,y, z - axis rotation respectively), and not with facing.
In my case, I want to convert a 3D facing between two points to those axis rotations so I can use the native.
Here is some attempt, but I changed it too many times, so the current state is kind of pending ( so don't care is something makes no sense):
JASS:
function SetEffectFacingXYZ takes effect e, real x_target, real y_target, real z_target returns nothing
local real x_effect = BlzGetLocalSpecialEffectX(e)
local real y_effect = BlzGetLocalSpecialEffectY(e)
local real z_effect = BlzGetLocalSpecialEffectZ(e)
local real dx = x_target - x_effect
local real dy = y_target - y_effect
local real dz = z_target - z_effect
local real effect_abs = SquareRoot(x_effect*x_effect + y_effect*y_effect + z_effect*z_effect)
local real target_abs = SquareRoot(x_target*x_target + y_target*y_target + z_target*z_target)
local real distance = SquareRoot(dx*dx + dy*dy + dz*dz)
local vector v
local vector v_plane
local real yaw = 0
local real pitch = 0
local real roll = 0
call ClearTextMessages()
//Projektion in xy
set v = vector.create(dx, dy, dz)
set v_plane = vector.create(0, 0, 1)
call v.projectPlane(v_plane)
//set v_plane.x = dx
//set v_plane.y = 0//dy
set v_plane.z = 0//dz
set v_plane.x = 1
if (v.x < 0) then
set roll = vector.getAngle(v, v_plane)
else
set roll = vector.getAngle(v, v_plane)
endif
// Projektion in xz
/*
set v.x = dx
set v.y = dy
set v.z = dz
set v_plane.x = 0
set v_plane.y = 1
set v_plane.z = 0
call v.projectPlane(v_plane)
if v.x <= 0 then
set v_plane.z = -1
set yaw = vector.getAngle(v, v_plane)
if (yaw != 0) then
set yaw = yaw - bj_PI/2
endif
call BJDebugMsg("yaw 1: " + R2S(yaw))
else
set v_plane.z = 1
set yaw = vector.getAngle(v, v_plane)
if (yaw != 0) then
set yaw = yaw - bj_PI/2
endif
call BJDebugMsg("yaw 2: " + R2S(yaw))
endif
set yaw = RAbsBJ(yaw)
*/
/*
// Projektion in yz
set v.x = dx
set v.y = dy
set v.z = dz
set v_plane.x = 1
set v_plane.y = 0
set v_plane.z = 0
call v.projectPlane(v_plane)
set v_plane.x = 0
set v_plane.y = 0
if v.z <= 0 then
set v_plane.y = 1
set pitch = vector.getAngle(v, v_plane) - bj_PI/4// + bj_PI/2
call BJDebugMsg("pitch 1: " + R2S(pitch))
else
set v_plane.y = -1
set pitch = vector.getAngle(v, v_plane) + bj_PI/2 + bj_PI*2 + bj_PI/4
call BJDebugMsg("pitch 2: " + R2S(pitch))
endif
*/
//call BJDebugMsg("yaw: " + R2S(yaw))
call BJDebugMsg("roll: " + R2S(roll))
call BlzSetSpecialEffectOrientation(e, yaw, pitch, roll)
//call BlzSetSpecialEffectOrientation(e, 0, 0, 0)
//call BlzSetSpecialEffectOrientation(e, yaw, pitch, roll)
call v.destroy()
call v_plane.destroy()
endfunction
endlibrary
Basically, I want a function that lets an effect face the point xyz.
I'm using this in an orbital movement system, I tried to finish. You can ignore maybe the texts, but the demo, as the texts are about movement, and not orientation.
In the attached demo, there's a trigger "Orbit Demo 2 Copy" (the only demo that is activated^^), which calls the function
SetEffectFacingXYZ
. In my opinon the given parameters are always connrect, and I tested it much. The effect movement also always works as expected, so this also would mean x/y/z are given correctly. But my problem is the called 3D facing-to-orientation is not working.---
It's pretty easy to get it working with converting only 1 axis rotation, so let's say only x-axix, so on a plane, but somehow I don't get it done properly when rotating around all three axis.