Tag Info

New answers tagged

1

You can look into the Perspective n Point problem. I think that's what this issue is officially called.


0

Well, getting 2d orientation from 3d points can be done by multiplying it with the world, view, and projection matrices. You could reverse these calculations. The thing is, you donĀ“t know depth. What you get is a line inside the viewing frustum , between the near and far clipping plane of the camera, that tells you where you see this point. But there is no ...


0

You could use the distance formula: Formula: sqrt((p2.x - p1.x)^2 + (p2.y - p1.y)^2 + (p2.z - p1.z)^2) Code: Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2) + Math.pow(p2.z - p1.z, 2))


0

The method I use is called barycentric interpolation. I would write a guide how to do it, but I don't think I could possibly sum it up better than this tutorial.


1

abs(x1-x2) + abs(y1-y2), as proposed by this answer will not always be correct. If you are willing to perform two more multiplication, you can perform an exact ordering without the cost of a squareroot. Consider the distances from (0,0) to the points (3, 4) and (5, 1). The distances are 5 and ~5.09, but the abs algorithm shows (5, 1) as being closer. ...


0

abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2) is much more efficient than using square root. If you don't need the actual distance, and just need to compare distances, this is the way to go. There will be a margin of error here, so it will give you a rough sort. Thanks to David for pointing this out


14

Compute the vector representing the displacement between the two points p0 and p1: v = p1 - p0 and then compute the length of that vector: distance = sqrt(dot(v, v)) A vector in this case is an element of the real 3D coordinate space, so it has three components (X, Y and Z). A point also has the same three coordinates, and we can subtract two points ...


2

You need a way to convert that rotation vector into either a Matrix or a Quaternion. Some math librarys have a built in method for doing that. If you choose a Matrix, then assuming you are in a Y-up world, the 3rd row or column (depending on if you are using DirectX or openGL) is a vector representing the direction your entity is looking (call it ...


1

It's assumed that point A is at the origin. Let d be the unit vector in the direction point A is currently looking at, and p be the unit vector in the direction of B - A. Notice that d and p necessarily define a plane in 3D-space. If you can imagine this, then it becomes clear that a single rotation of d by an amount equal to the angle between these two ...


0

For this kind of thing, it depends on what your goals is. If you're looking to ensure that lines are 1 pixel wide, then you could draw the grid using lines instead of textured triangles: However with ensuring that lines are 1 pixel wide, when they're so far away that the individual grid spaces are less than 1px, it will look like a solid: With your ...


0

You can't avoid this problem, you can try super sampling to make it less jarring ... but high frequency + high contrast works very bad in quantisize space. I go around this with a very small bit of blurring on the texture, it's counter intuitive but then you have more chance than a pixel pick a blur value and make the line looks antialiased on the texture, ...


0

The way you draw them, you have big cells that contain 10x10 small cells. Would it be acceptable to draw only the big cells when they're at a certain distance from the camera? That would be one possibility. Another would be to actually draw lines, like in a wireframe mesh. They are always exactly one pixel wide. That's all the ideas i have right now.


0

Why not Zoidberg both? Make a big 3D model of your map. Then, cut it into pieces. The size of the pieces doesn't matter all that much, but it'll be an inverse relationship between memory and speed. The bigger your "chunks" are, the more memory it will take, but the less often you'll have to load new ones. It's the opposite for small chunks. In the code ...


0

I guess I found out the problem. Its not the model or camera that is not rotating, the problem is with the terrain. As the only thing I draw is model and terrain, I was basing my vision on the terrain, but when I log the position, its rotating the model and keeping it in the same position, wich is the correct thing to do, so its yaw is correct, the problem ...


0

I'm want to clarify about this line in your camera Update method campos = Vector3.Transform(campos, Matrix.CreateFromQuaternion(player.rotation)); As I can understand you rotate camera with your model. If so you cannot not see rotation. Did you have any other objects in scene to determine that model realy rotated or not? Please add some screenshots with ...


1

Since I misunderstood your question and your camera seems not to be working correctly here is a minimal solution for what you want to achive. (Note this is a bare bones example which uses only what you need) class FollowCamera { public Vector3 offset; public MeshTransform target; public Matrix view; public Matrix projection; public ...


-1

Not a pro at these things but try changing effect.World = transforms[mesh.ParentBone.Index] * worldMatrix; to... effect.World = worldMatrix * transforms[mesh.ParentBone.Index];


1

If I understand right what you are trying to move the camera backwards and upwards relative to the player model. However, in the Z-axis direction XNA ago, that is, you need to set Z coord 100 instead of -100. Or you can do like that: Vector3 thirdPersonReference = Vectro3.Up * 100 + Vector3.Backward * 100; Vector3.Backward has value (0, 0, 1), abd ...


1

If You subdivide the line into CE and ED and the projection of the 2 lines combined will be the projection of the full line. Using that we split the line where it intersects the screen then EC' will be the resulting line and you ignore the ED part of the line. Current day graphics pipelines will do this automatically using frustum culling with the near ...


1

It is pretty complicated stuff going on and its not that simple as it look bcs of the way of opengl buffering system works.The best way to do it is just draw 3d and then 2d. You might create some kind of ArrayList which will keep track of all 2d drawing requests. And when 3d is done you execute them all.


0

When reading your question, I can translate it two ways. Is there an engine that can create sounds based on physical simulations? Such as air blowing across a reed, or a hammer striking a string? In gaming? not that I've heard of. Is there an engine that plays pre-existing sounds but modifies them based on physical information such as distance from ...


0

I realize this is an old question, but things have been progressing in the last couple of years, and what you are describing is becoming more and more feasible, computationally. Tools like Synthesis Toolkit are used to answer the following sort of question: "My physics engine told me that the flute is vibrating in such-and-such manner. What note does that ...


1

glViewport lets you control the part of the screen where the output of your gl drawing commands will get rendered. It affects the gl commands that you issue after setting up the viewport. So, if you want to render the game to full screen and a minimap to a small portion, then: set glViewport to the entire screen, render game set glViewport to the minimap ...


0

You can make objects appear smaller or larger simply by moving the camera further or closer to them, so you will need to change the view matrix. However, since the numbers you are dealing with are potentially large, be sure to also fix the projection matrix for the near and far clipping plane values. Finally, note that astronomy pictures are often taken ...


0

Your code would face towards the destination, and it seems like you're following some kind of path. The problem is that if the direction you're traveling isn't the same as the look at to the goal, it'll look odd. You can solve this by either getting the direction you're traveling in and using that instead. (This is specific to how you're moving it, however ...


0

In 2D you can use Atan2 (http://docs.unity3d.com/ScriptReference/Mathf.Atan2.html) facing_angle = Mathf.Atan2( new_pos.y - old_pos.y, new_pos.x - old_pos.x); Or using (X,Z) if that's how your world is oriented: facing_angle = Mathf.Atan2( new_pos.z - old_pos.z, new_pos.x - old_pos.x); Or Transform.LookAt ...


3

Going 3D when the game is basically a 2D game seems like an overkill. In your place, i'd rather use a 2D engine that handles already tiles and slopes, and just use a few tricks for the parts where a '3D' effect is required. Just a small example, a bridge : So for the player, that would look like : Now you can add some invisible trigger zones that ...


2

Add a logical third dimension and add logic to tiles by type. So a horizontal bridge will allow you to pass from left to right on Z = 1 and from top to bottom on Z = 0.(like flow bridges game) Now change the Z when walking up or down a hill. Allow jumping 1 unit high. That's about it. edit: here is an example tutorial- http://rpgmaker.net/tutorials/163/


6

The first thing I would suggest is to use a 2d implementation like the one in Teleglitch, like you said yourself, you found solutions, this is a lot simpler. Line of sight is a gameplay mechanic. If the game is top-down, the gameplay is essentially 2d and there is likely a limited benefit to using actual 3d line of sight. No, you are absolutely right. This ...


2

Here's wiki on topic: Field of view in video games X and Y angles can be set separately to allow for wide/tall views. For example if you need a panorama for 3 displays like so, with default FOVy, but 120 degrees FOVx:


1

This problem is called Inverse Kinematics. In Inverse Kinematics, you begin with some "desired" translation and rotation for the endpoint in a kinematic chain. The goal is to determine where all the other objects in the kinematic chain are (their rotations and translations), and joint angles (if you have any joints). In your case, you are putting in the ...


2

One popular method is to use parent-children hierarchies to store matrix transformations in relative space. If you are moving the table and everything along with it, the bowls are the children of the table as far as their location is concerned. This can be done as simply as storing and pushing matrices in an array, and multiplying them. This could also be a ...



Top 50 recent answers are included