Infinitegde
O.O
- Reaction score
- 86
3D Functions
Well, after doing a bit of research I was able to learn more about this 3D environment. So, I decided to post a few functions that pertain to this subject.
Functions:
- Yay! Sphere Projections! Basically, similar to Polar Projection except with a Z factor.
-You can set a unit's Z *almost* instantly. (This is pretty simple but I added it for the heck of it )
How to Implement:
Jass:
-Just click on the map icon in Trigger Editor, and post the scripts in there. Call them when needed through out your map
GUI:
-Just click on the map icon in Trigger Editor, and post the scripts in there.
-You must create a global variable that receives the function I.E. Point for location, Real for real.
- Create a custom script, Example, "call SetUnitZ(100,GetTriggerUnit(),false)"
or "set udg_Point = SphereProjLoc(Parameters)"
Explanation:
SphereProjLoc and SphereProjZ:
Because a location's Z value is hard to change, these function comes in a package. MAKE SURE the parameters you send to each of these functions are the equal to the parameters you enter in the other. One returns a Location(X,Y) of the Spherical Point and the other returns the Z of the location. Now, some people are confused by ZDegrees, right? Well, its simple really. If ZDegrees equals 0 then the point will be directly above the source. If ZDegrees equal pi/2 or 90 the point will be on the plane of the X and Y axis. if ZDegrees equal 180, then the point will be directly below the source. Zsource is there so you can get the Z in terms of the source. It doesn't matter if you set it to 0 then add it the Z later.
Code:
If anyone finds any errors in this, please let me know!
Spherical Coordinates in Action!
Take a look at this spell, it shows how ingenious effects can be created from this simple formula.
Well, after doing a bit of research I was able to learn more about this 3D environment. So, I decided to post a few functions that pertain to this subject.
Functions:
- SphereProjLoc takes location source, real Radius, real Degrees, real ZDegrees returns location
- SphereProjZ takes real Zsource, real Radius, real ZDegrees returns real
- SetUnitZ takes unit u, real Z returns nothing
- Yay! Sphere Projections! Basically, similar to Polar Projection except with a Z factor.
-You can set a unit's Z *almost* instantly. (This is pretty simple but I added it for the heck of it )
How to Implement:
Jass:
-Just click on the map icon in Trigger Editor, and post the scripts in there. Call them when needed through out your map
GUI:
-Just click on the map icon in Trigger Editor, and post the scripts in there.
-You must create a global variable that receives the function I.E. Point for location, Real for real.
- Create a custom script, Example, "call SetUnitZ(100,GetTriggerUnit(),false)"
or "set udg_Point = SphereProjLoc(Parameters)"
Explanation:
SphereProjLoc and SphereProjZ:
Because a location's Z value is hard to change, these function comes in a package. MAKE SURE the parameters you send to each of these functions are the equal to the parameters you enter in the other. One returns a Location(X,Y) of the Spherical Point and the other returns the Z of the location. Now, some people are confused by ZDegrees, right? Well, its simple really. If ZDegrees equals 0 then the point will be directly above the source. If ZDegrees equal pi/2 or 90 the point will be on the plane of the X and Y axis. if ZDegrees equal 180, then the point will be directly below the source. Zsource is there so you can get the Z in terms of the source. It doesn't matter if you set it to 0 then add it the Z later.
Code:
JASS:
function SphereProjLoc takes location source, real Radius, real Degrees, real ZDegrees returns location
local real x = GetLocationX(source)+Radius*Sin(ZDegrees*bj_DEGTORAD) * Cos(Degrees*bj_DEGTORAD)
local real y = GetLocationY(source)+Radius*Sin(ZDegrees*bj_DEGTORAD) * Sin(Degrees*bj_DEGTORAD)
return Location(x,y)
endfunction
function SphereProjZ takes real Zsource, real Radius, real ZDegrees returns real
return Zsource + Radius * Cos(ZDegrees*bj_DEGTORAD)
endfunction
function SetUnitZ takes unit u, real Z returns nothing //Created by Flare
call UnitAddAbility (u, 039;Amrf039;)
call SetUnitFlyHeight (u, Z, 0)
call UnitRemoveAbility (u, 039;Amrf039;)
endfunction
If anyone finds any errors in this, please let me know!
Spherical Coordinates in Action!
Take a look at this spell, it shows how ingenious effects can be created from this simple formula.