Tag Info

New answers tagged

0

I don't know if this is a typo in your question or the actual mistake: x = normalize(Oa); v = normalize(Ob); z = a.crossProduct(b); y = x.crossProduct(z); For one you don't seem to be using v at all, but your z looks wrong to me. Did you mean the following? z = normalize(Oa.crossProduct(Ob)); Note the Oa and Ob instead of a and b. The difference is the ...


0

Since your game is 2D, I will assume, as I read in your comments, that there is no "camera". I will assume that you have a view rotation around the player called viewRot. Your player is the center of rotation as well as the center of the bullet. We will first rotate the bullet around itself because it seems logic to me to apply self transformations before ...


1

You could do something as simple as XMVector3TransformNormal of the direction light with the original Rotation. Generally in SIMD-friendly coding, individual component access is a performance hit, so you want to avoid doing it whenever possible. That's why in DirectXMath (aka XNAMath version 3) the individual element members _11 - _44 were removed from ...


0

Ok, think I got it. I now build the rotation matrix directly from the vectors: xAxis = cross(normal, (p1 - p0)) yAxis = cross(normal, xAxis) zAxis = normal rotationMatrix = [ xAxis.x, yAxis.x, zAxis.x, xAxis.y, yAxis.y, zAxis.y, xAxis.z, yAxis.z, zAxis.z ]


0

Workable solution /** * update player's logic, called by game loop */ public void update() { // calculates angle angle(); // rotates the player if there is movement if(left || right || up || down) { rotate(); } // update player's position if(left) { x -= moveSpeed; } if(right) { x += ...


0

There may be some issue with ROTATE_ANGLE_OFFSET and - if(currentAngle < 0) currentAngle = 359; if(currentAngle > 360) currentAngle = 1; -if you aren't using single-degree steps. Might want to try - if(currentAngle < 0) currentAngle += 360; if(currentAngle > 360) currentAngle = currentAngle % 360; More Stuff That Might be ...


4

To get a value inside [-pi,pi], you can add pi, do fmod, and subtract pi again. Here is one way that works. Unfortunately you still need to somehow test whether from - to is positive or negative before calling fmod: Scalar rotationBetween(Scalar from, Scalar to) { return (from > to) ? -pi + std::fmod(from - to + pi, pi * 2) : ...


0

I think the following should do the trick. (Edit: as pointed out in the comments, this gives the unsigned rotation). Scalar rotationBetween(Scalar from, Scalar to) { //Calculates the two possibilities, and take the smallest Scalar difference = std::min( std::fmod(from - to, pi * 2), std::fmod(to - from, pi * 2)); //takes the above ...


1

A solution that would work in all cases would be inverse kinematics. You may want to look it up, but that is quite a complex topic. Here is a general solution for your special problem: I don't really understand how the TopDondur and Berrels are related (or even what TopDondur is supposed to be) so I will for sake of simplicity assume only on "character". ...


1

Local vs. Global coordinate spaces apply to all transforms: position, rotation, and scale. They can be thought of by imagining the movement you do when instructed "turn left" and you are, say, inside a bus facing the back of the bus; does that mean your left, or the left side of the bus? Your local coordinate system defines "left" to your left, but that ...


1

jME3 uses a Scene Graph for rendering, which basically means that you have a tree structure of nodes where the leaf nodes are models. Each level of node can have a different local Position/Scale/Rotation. To calculate the global P/S/R (that is, where a leaf node would actually be rendered) for a node you take it's parents global P/S/R and add that to the ...


1

Being able to rotate your cube regardless of the axis has to do with the matrix manipulations you apply to the cube. The best way I have found to keep track of your transformations is to keep a reference location that you create when the object is instantiated. Then you apply your rotations relative to that reference point. In XNA an easy way to do this is ...


2

The method camera.rotate() (and all other transformation methods on camera) act on the current state of the camera. So if it's rotated 30 degrees, it will add more 30 degrees to the rotation. If you want to keep at 30 degrees (but still applying the transform every step), you have to make it look back at whatever it was looking before. Assuming you're using ...



Top 50 recent answers are included