Jump to content

How to rotate and position object?


DrMasik

Recommended Posts

Sorry for poor English.

I'm need to rotate newly create object. The function createObject(BlockPlan plan, Matrix position) needed to set position argument.

Type Matrix (class) has some properties. How can I calculate values for that properties (right, up, look, translation, pos, position) to rotate object?

Link to comment
Share on other sites

1. function Matrix rotate(Matrix in, float angle, vec3 axis) - rotates orientation Matrix around the axis by angle specified in radians. The rotation should be performed on server side and it's instant.

local entity = Entity()
entity.orientation = rotate(entity.orientation, 1.57, vec3(1, 0, 0))

 

2. Gradually rotating entity using following function:

function addRotation(vec3 axis, float angularVelocity) - will add angular velocity and the entity will still rotate around the axis. But you'll need to apply it every update and stop when it will be enough.

Also, you need to use this function on both client and server I think.

function MyNamespace.update()
    Velocity():addRotation(vec3(1, 0, 0), 2)
end

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...