New answers tagged

0

You are doing more than you should to generate your arc ball matrix. The code below should be enough for your need. DirectX::XMMATRIX ComputeArcBallViewMatrix(DirectX::XMVECTOR origin,float distance,float yaw,float pitch,float roll = 0.f) { auto rotation = DirectX::XMMatrixRotationRollPitchYaw(pitch,yaw,roll); auto offset = ...


0

The idea of measuring the distance between quaternions is indeed a useful similarity measure. In essence, what you can measure the dot product between two quaternions qA and qB just as you compute the dot product of two vectors (see this). Moreover, since you have unit quaternions (they do represent rotations!), the dot product should be between [-1,1]. ...


2

Alright so I figured out an even more ideal solution. The way I was trying to solve the problem was going to lead to more issues than I needed to deal with, so instead I slept on the problem and thought up a different approach. Instead of trying to min-max my orientation, I now calculate how far from the target orientation the camera is, If it lays above a ...


0

If I understand your question, you want to limit the rotational velocity of a turn? Get the delta. From your rotation delta, you can find out how many radians of turn it represents from the S element (or sometimes called W element). The S element is cos(rotationAmt / 2), so can be extracted as rotationAmt = acos(deltaQuaternion.s) * 2. From there you ...


2

I bit on the mathematical side, but here's a Q & A on MSE on computing quanternion distance. Using that you could do something like: quat targetQuat = target->getOrientation(); quat currentQuat = getOrientation(); quat lerpQuat = glm::lerp(currentQuat, targetQuat, 0.05f); quat maximumQuat = targetQuat*quat(0.707, 0, -0.3535, 0); float d1 = ...


1

You can't get the "right" vector from just a "forward" vector. Any particular "forward" vector could have an infinite number of different legal "up" and "right" vectors. For example, if I am looking forward along the z axis forwardVector = vec3(0,0,1), then I could have up be along the y axis upVector = vec3(0,1,0) and right therefore be along the x axis ...


0

You want to move 2d UI (Label) with respect to your game object. WorldToScreenPoint transform the position from world space into screen space. Here you are on right track, what you are missing is that screenPosition = Camera.main.WorldToScreenPoint(transform.position); screenPosition.y = Screen.height - screenPosition.y; So, according to me your script ...


1

Simple method: Add two cameras to your scene, the first-person camera and the third-person camera. Attach both to the player-character. Move one on eye-height, the other further behind. Deactivate one of them. To switch between them, deactivate one and activate the other. This results in an immediate switch between the two perspectives. Fancier method: Have ...


0

How do I know what the camera distance is from the image plane? I'm not sure if this is a meaningful question to ask - what is the image plane? A real camera has a plane on which an image is formed, but in OpenGL there is no such thing. If you need this for some physics-based calculation, you could possibly use the near clipping plane distance (third ...


0

When making games, I typically support resolutions between 5:4 to 16:9. The best way I found to ensure maximum object coverage on the screen is to optimize for 3:2 and then adjust the camera's view along the axis that minimizes the amount of extra space. So if the game is in landscape mode and is being played on a 5:4 device, the width would remain static ...


0

To move Camera in TiledMap bounds, OrthogonalTiledMapRenderer was used. I have also noticed it behaves unexpectedly: while Camera reaches map bounds, tiled map, like by inertia, moves some pixels too far (it depends on the velocity of the swipe). As a solution, on each Camera movement, Camera is forcibly put in map bounds. See putInMapBounds() method. To ...


2

The difference between ScreenSize and WorldSize is part of the brilliance of graphics systems like OpenGL. ScreenSize is the actual size of the window in pixels. When the user grabs the window handles and resizes the window, then ScreenSize will change. WorldSize is the size of your game level or "World". It is completely arbitrary. In a 2D game, 1 unit in ...


0

I am not aware of an easy way of doing this. The way I'd do this is the following: Determine XY position of click on texture (x = 0..1, y = 0..1) How to do this depends on where you use it, but will likely require raycasting. Go to the camera that sends the image to the texture. Assuming the camera uses perspective projection: Calculate the 3D ...



Top 50 recent answers are included