# Tag Info

64

Why ? Because, A camera represents a projection view. But in case of 3D Camera (Virtual Camera), camera moves instead of the world. I have made a detailed explanation later of this answer. Understanding Mathematically Projection View moves around space and change its orientation. The first thing to notice is that the desired projection on the ...

26

Mahbubar R Aaman's answer is quite correct and the links he provides explain the math accurately, but in the event you want a less technical/mathy answer, I'll try a different approach. Positions of objects in the real world and the game world are defined with some coordinate system. A coordinate system gives meaning to position values. If I tell you that ...

12

Because if you only divide [x, y, z] by z you get [x/z, y/z, 1] and you lost the actual value of z, which is actually useful if you want to do near/far plane clipping or fill a Z-buffer. The best way to keep some information about z, at least on the GPU, is therefore to use 4 components instead of 3. In practice, what is actually in the last two vector ...

10

Yes, the Update loop is ideal for this. There are no special plug-ins required and you can do this with the free version. Basically you move the objects a tiny bit towards their destination each frame. When all those frames run one right after the other, it gives the appearance of smooth movement. A self contained script would look like the one I've created ...

10

Because of the linearity (aka distributive property) of vector addition and matrix multiplication, it doesn't matter! Yay! Transform(Sum(v_i)) = Transform(v_0 + v_1 + ... + v_n) = Transform(v_0) + Transform(v_1) + ... + Transform(v_n) = Sum(Transform(v_i)) EDIT: However, transformations are not commutative, so these ...

9

Just adding to the other two (excellent) answers some further elaboration on a point that Mahbubur R Aaman touched on: "there is no camera". This is quite true and represents a failing of the common "camera" analogy, because the "camera" does not actually exist. It's important to realise that the camera analogy is just exactly that - an analogy. It doesn'...

8

I'm not sure of a good way to preface this, other than I hope it ties together nicely by the end. That said, let's dive in: A rotation and an orientation are different because the former describes a transformation, and the latter describes a state. A rotation is how an object gets into an orientation, and an orientation is the local rotated space of the ...

7

You actually just made a simple typo. gameObject is the current GameObject that your script is attached to. GameObject is the type. The error message is saying that the Find(string) function only works when it is called on the type (GameObject) not an instance of the type (gameObject). Simply put, use GameObject.Find("First Person Controller") instead of ...

6

From the image it looks like both your coordinate systems are cartesian coordinates, where the only difference between the two is that one has a different origin from the other. If this is the case then to translate from xyz coordinates to x'y'z' coordinates all you need is a translation, i.e. x' = x + dx y' = y + dy z' = z + dz Where [dx, dy, dz] is the ...

6

Mathematically, the quantity you're asking about is called the operator norm. Unfortunately, there's no simple formula for it. If it's a fully general affine transformation - for instance, if it could have an arbitrary combination of rotations and nonuniform scales, in any order - then I'm afraid there's nothing for it but to use singular value ...

6

Normally I store all objects as 4x4 Matrices (you could do 3x3 but easier for me just to have 1 class) instead of translating back and forth between a 4x4 and 3 sets of vector3s (Translation, Rotation, Scale). Euler angles are notoriously difficult to deal with in certain scenarios so I would recommend using Quaternions if you really want to store the ...

6

In short - it is better to do the transformation on the GPU. Firstly, the GPU is designed to support huge amounts of parallelisation. Your CPU on the other hand is not nearly as capable. The NVIDIA GTX 980, for example, has 2048 CUDA cores to process those vertices with in comparison to the 2-16 threads/cores a processor might support. So from a number ...

6

The simplest way this can happen is if you shrink an object until its local scale in one or more axes is 0 (flattening it to a plane, line, or point). You can avoid this by disallowing scales below a certain magnitude on any axis. (If your system allows hierarchical nesting of transforms, you'll also have to watch out that no chain of parented matrices ...

5

If you are sure your has a uniform scale and no skew components, then the non-translation part of the matrix can be expressed as M_33 = R * (s * I), where R is the an orthogonal rotation matrix, and s is the uniform scale. This is vaguely annoying so solve, but in 3d comes out to be: scale_x = sqrt(m00^2 + m01^2 +m02^2); // scale_y = sqrt(m10^2 + m11^2 +...

5

Rotating a point p using a quaternion q is done with q * [0, p] / q. Replacing q with -q has absolutely no effect on the result. If your rotations "go the wrong direction" when the sign of the quaternion changes, then the problem lies in the way you use the quaternions to rotate points.

5

Expressing rotations with quaternions can be done from an axis-angle representation, but not in a single way. For that same axis angle (w, a) pair, you get two quaternions performing the same task. One has its components based directly on the w vector and the a angle, the other has the same components, but negated. This is normal, since they describe the ...

5

Moving the camera or moving the world are two equally valid choices which both amount to the same thing. At the end of the day you are changing from one coordinate system to the other. The above answers are correct but which way you visualise it are two sides of the same coin. Transformations can go either way - they are just the inverse of each other. Part ...

5

If you want to rotate an object around.Center must be at the point(0,0,0) To achieve that simply Translate the object to point(0,0,0) Rotate and Translate back example: Translate(0,0,-1) Rotate(90) Translate(0,0,1)

5

You can check if cross(up, zaxis) is too close to zero (use an epsilon like 1e-4 or something like that), and switch to an alternative up-vector if so. For instance, if your usual up-vector is (0, 1, 0), you could switch to (1, 0, 0).

4

I would posit instead that it's a flawed analogy. At its most basic, "moving the camera" and "moving the world" are exactly the same mathematical construct - it's just that moving the world is somewhat easier to think about conceptually, especially when it comes to hierarchical transformations. Basically, you're moving the world around the camera only in ...

4

I don't think that the claim is categorically true, as one only rarely "moves" the world coordinates in a game, but actually changes the coordinates of the virtual camera. What the concept of camera actually does, is transform the finite viewing frustum -- that is a truncated pyramid with 8 corner points (or defined by intersection of 6 planes) to a unit ...

4

Quite a common thing to do with some matrices is to cache the value and only update it when it's changed. There's two ways to manage this scheme, push or pull. Pushing matrices would involve, at the point of a matrix changing, letting child nodes know that the matrix has changed. These nodes will then have to let their children know, and so on. The upside ...

4

Just take the desired movement vector, multiply it by the object's rotation matrix, then use the result as before, i.e. convert it to a translation matrix and multiply it into the position_mat.

4

You need a combination of scale and translation matrices. You could first go to a "normalized" screen space (origin at 0,0 and scaling to 1,1) using, in pseudo-code: MatToNormalized = Translation(-1, -1) x Scale(1/2, 1/4) Then you can easily map to any kind of screen space. E.g. for question 1.: MatToFullscreen = MatToNormalized x Scale(600, 500) And ...

4

To implement Lorentz contraction, your best bet is probably just to explicitly scale the object by 1/gamma along the direction of motion. The trouble is that the Lorentz transformation displaces vertices in the time direction as well as in space, so by itself it will not give you what a moving object looks like at a specific moment in time. To do that, you ...

4

Given the following: A as the 4x4 augmented translation matrix to move any of the point of the plane into the origin I as the 3x3 identity matrix N as the 3-dimensional unit normal vector for the plane (calculable by creating a cross product from any two non-parallel lines on the plane, then normalising them) The calculation steps for the augmented ...

4

(a) To produce a "squash" matrix that smashes things to the ground plane parallel to a given sun vector, I would build it by composing two matrices: A shear matrix that maps the sun vector to +Y (straight up) while leaving the X and Z axes unchanged. A scaling matrix that scales Y by zero while leaving X and Z unchanged. Specifically, assuming you're ...

4

OpenGL is a state-machine, it has a current matrix. There are several functions to manipulate the current matrix: glLoadIdentity, glLoadMatrix overwrite the current matrix. glTranslate, glScale, glRotate, glMultMatrix multiply the current matrix with the appropriate matrix generated by these functions from the right. Now, whenever you draw something it ...

4

What you are looking for is the LookAt algorithm. OpenGL already has that in a nice function: gluLookAt, although it multiplies the current matrix instead of returning it to you so you may need some push/pop trickery to get at it. If you want to do it yourself, there are two ways; by constructing a transformation matrix, or by using quaternions. Here's the ...

4

The best way to gain intuition about how a matrix behaves is by determining its effect on the standard basis vectors: 1 0 0 e1 = 0 e2 = 1 e3 = 0 0 0 1 Since any 3D vector can be written as a combination of a*e1 + b*e2 + c*e3, if we know how a matrix changes these three vectors, we know how a matrix changes any ...

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