Jump to content
Gilatar

Is there a way to use the Eden Rotation XYZ values in scripting?

Recommended Posts

I'm trying to replace an object that I've played in the Eden Editor through a script, but I've changed the XYZ rotation of the object. I have managed to give the new object the XYZ position values of the old object, but I'm struggling to figure out how to change it's rotation. Is there an easy way of doing this?

 

664d87013a.png

 

I've already tried setVectorUp, but it doesn't seem to accept the above XYZ rotation values from the Eden editor.

 

Edit: Woops, looks like I posted this in the wrong subforum.

Share this post


Link to post
Share on other sites

Thanks for the help!

 

I must be doing something wrong or misunderstanding how to use the command. Are those commands intended for use only in the Editor itself and not in a running mission?

 

Either way this is what the script looks like:

_pos1 = getPos redlight1;
deleteVehicle redlight1;
_greenlight1 = createVehicle ["xCam_Flush_Light_green_F", _pos1, [], 0, "CAN_COLLIDE"];
_greenlight1 enableSimulation false;
_greenlight1 set3DENAttribute [ "position", [ 7723.08, 3663.23, 3.444 ] ];
_greenlight1 set3DENAttribute [ "rotation", [ 89.44, 85.00, 359.44 ] ];

The object appears at the original location, but at ground level and with standard rotation.

Share this post


Link to post
Share on other sites

The commands are indeed for setting the EDEN parameters. Try this function/script in your mission. It translate euler angles to vectors (I assume that is what you want):

    private ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp",
    "_upXTemp"];
    _object = _this select 0; 
    _rotations = _this select 1; 
    _aroundX = _rotations select 0; 
    _aroundY = _rotations select 1; 
    _aroundZ = (360 - (_rotations select 2)) - 360; 
    _dirX = 0; 
    _dirY = 1; 
    _dirZ = 0; 
    _upX = 0; 
    _upY = 0; 
    _upZ = 1; 
    if (_aroundX != 0) then { 
        _dirY = cos _aroundX; 
        _dirZ = sin _aroundX; 
        _upY = -sin _aroundX; 
        _upZ = cos _aroundX; 
    }; 
    if (_aroundY != 0) then { 
        _dirX = _dirZ * sin _aroundY; 
        _dirZ = _dirZ * cos _aroundY; 
        _upX = _upZ * sin _aroundY; 
        _upZ = _upZ * cos _aroundY; 
    }; 
    if (_aroundZ != 0) then { 
        _dirXTemp = _dirX; 
        _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); 
        _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);        
        _upXTemp = _upX; 
        _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); 
        _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); 		
    }; 
    _dir = [_dirX,_dirY,_dirZ]; 
    _up = [_upX,_upY,_upZ]; 
    _object setVectorDirAndUp [_dir,_up]; 

Note: Shamelessly ripped out of MapBuilder and Biki.

  • Like 2

Share this post


Link to post
Share on other sites

_pos1 = getPos redlight1;

_up = vectorUp redlight1;

_dir = vectorDir redlight1;

deleteVehicle redlight1;

_greenlight1 = createVehicle ["xCam_Flush_Light_green_F", _pos1, [], 0, "CAN_COLLIDE"];

_greenlight1 setVectorDirAndUp [ _dir, _up ];

_greenlight1 enableSimulation false;

  • Like 1

Share this post


Link to post
Share on other sites

You are both gentlemen and scholars. Thank you for the assistance  :)

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

×