Tag Info

Hot answers tagged

2

if (Math.abs( angle) > mindelta ) transform.LookAt (currCustom); I think it depends on floating point math errors, I suggest to define a min angle (mindelta in my code example) inside wich, the turret doesn't move


2

The trick here is conversion between world space and screen space. World space is the coordinate system you use for your game logic - calculations of pathing, movement, formations, etc. Your original formation code is correct for world space. Screen space is the coordinate system in which items are displayed. Because you're using an axonometric projection ...


1

I need a way of translating a set of points P I suppose you mean rotating here? Let Z = (0,0,1). If cross(N,Z) has length 0, it means that all your points already lie in the desired plane. Otherwise we can build a basis of the target plane: U = normalize(cross(N,Z)) V = cross(N,U) Now to transform a point P = (x,y,0) so that it lies in your target ...


1

You have at least one error. This is incorrect: float newDistance = newPointOnPlane.x + newPointOnPlane.y + newPointOnPlane.z It should instead be: float newDistance = glm::dot(newPointOnPlane, newNormal); Because the "distance" of a plane is the distance along the normal to the plane origin, which is given by the dot product between the normal and the ...


1

You should probably use glm::angleAxis() (documentation here): glm::quat &rot = glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f));


1

the glm::quat(float, float, float, float); constructor doesn't do what you think it does. It sets the values directly. The values of the quaternion (w, x, y, z) are in order: the cosine of half the angle, the sine of half the angle times the x coordinate of the normalized rotation axis, and the same for the y ans z components. So instead you want to use ...



Only top voted, non community-wiki answers of a minimum length are eligible