40

Camera is like a camera with which Batman movie is filmed. It exists in a virtual world and can be moved around, targeting different scenes, changing focal length and other camera properties. You can have many cameras and switch between them. You can even film on several cameras at once. Typical camera coordinates are: position in virtual world, facing ...


39

4A Games, the developers of Metro: Last Light were receiving a lot of criticism for not having a FoV slider in their game. Community manager Maurice Tan defended their decision on the Steam forums as follows: The main reason for maintaining a fixed FOV is because we have 3D elements like the watch and weapon ammo that need to remain visible. In ...


14

In fact, the original question is 1 cast away from the solution. Original Code glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, window.width/window.height, 0.01f, 100.0f) Fixed Code glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, (float)window.width/window.height, 0.01f, 100.0f) The problem was that window.width and window....


12

Not having a FOV slider in your game due to budget or technical reasons is a non argument. FOV is just one parameter in the creation of the view-projection matrix. After you have a proper matrix all the other calculations will follow by themselves. To word it in another way, making the FOV changeable means that only one line of code needs to be changed (in ...


11

Think about it logically: What is your goal when you render something? To display it on the screen! What are the constraints? The model must be visible to the camera (i.e. in the view frustum, not occluded by other objects, etc.) What are the inputs? A collection of vertices in a coordinate system local to the model's origin. A transformation matrix that ...


10

To understand what's going on, you have to understand the rendering pipeline: Your geometry (the quad) is initially defined in world space, think of this as some global coordinate system. Inside of the vertex shader those are transformed to normalised device coordinates (NDC), a virtual coordinate system defined so, that everything from -1 to 1 will get ...


9

I hope I am understanding your question correctly -- if not let me know. I believe the following is where you are unprojecting the coordinates: @Override public boolean mouseMoved(int screenX, int screenY) { worldCoordinates = camera.unproject(new Vector3(screenX, screenY, 0)); return true; } Because you are using a viewport, you must add the ...


8

are these implementations actually Stacks in the data structure sense of the word or just wrapped fully accessible arrays with fancy methods called pop and push added to them? That depends on how you implement your scene stack. I have used stacks that were std::stack and I have used fancy wrappers for vectors due to the need to check other scenes. So it ...


8

My guess is you're trying to implement a camera, and should not be using SDL Viewports. The viewports are for UI elements like menus, minimaps, etc. It's a way of dividing up the screen into multiple areas. To implement a camera, you will want to think about coordinate systems. The world coordinates are the positions in the world, without thinking about the ...


5

Window coordinates - the coordinates in which the viewport is specified using glViewport - are not the same as the view space coordinates that you pass to glOrtho. Window coordinates are always measured in pixels from the lower-left corner of the window, while view space coordinates are entirely up to you and can be defined however you like. You can think ...


5

For one, nearest-neighbor will result in pixel perfect scaling only if it's used to upscale in integer multiples. Apart from that, you should not be conducting any scaling operations on your view/projection matrices. If you set your view to match the dimensions of the screen, and your projection matrix to be orthographic with dimensions that match the ...


4

First of all, your createPerspective function doesn't look quite right - compare the formulas used for gluPerspective. If you want to use the same view matrix for both cameras, then when you set up the orthographic matrix, instead of using 0, camera.width, 0, camera.height you probably want -0.5*camera.width, 0.5*camera.width, -0.5*camera.height, 0.5*camera....


4

Imagine for a second that you have a bunch of plates. You can stack plates, by putting them one on top of the other. To add a plate to the stack, we push it on top. To remove a plate from the stack we pop it off the top. We can however reach into the stack and take out any plate, its just harder and requires lifting all the other plates out of the way. The ...


4

You're right about creating a second camera, it should work for this purpose (and for minimap as well), you just need to pay attention to its settings: Normalized View Port Rect - use this to set up position and size of the second (third, etc.) camera's rectangle on the screen, all numbers are relative coordinates [0..1]. For example X=0.0, Y=0.8, W=0.2, H=...


4

I've recently been implemented something like this in the MonoGame.Extended library. Creating a letterbox / pillarbox viewport in MonoGame is actually kinda tricky. I'll do my best to provide a good answer here. There's basically 3 parts to it. The first is creating a scaling matrix to pass into the SpriteBatch.Begin call. The variables represent your ...


4

In the editor's Game view, you can set the size that you'll see when you hit Play. Across the top of that view are buttons for screen resolution; the far left side has setting for screen size, and the right side has Maximize on Play.


4

You need to project from the worldspace to screen space using the correct camera, not the project method on the Vector2. Then unproject back into the camera of the Stage (but in your case that is set to the screen so it should just work). I think you want something like this; public void addScorePopup (int score, Vector2 worldPos, Camera gameCamera) { ...


4

I'd suggest using a sine or cosine curve to determine the position at the particular time. This would produce an output like, Where the zero line is assumed to be ground level (so when the sun is below the ground it is not visible). This also makes it relatively easy to adjust how much time is spent in night or day. Use GetSunHeight(){ ...


3

The most surefire way to do this is to test each frame if the sprite has exceeded the desired boundaries (either physical screen or camera viewport), and if so to clamp them back to the exact boundary. This will prevent any weird bouncing effects from trying to correct the position using an offset, and enable the sprite to collide snugly with the boundaries....


3

xoffset = (targetScreenWidth - image1Width)/2;


3

The usual way to do this is to use a RenderTexture. You point the camera to a render texture target and that texture updates with whatever the camera sees. This requires Unity Pro. There is an example project here: http://blog.almostlogical.com/2009/12/11/render-to-texture-unity3d/ Barring that, you can set up the second camera to render to a portion of ...


3

You need to ask for the device's resolution, and then, set the viewport to fit it. I assume that you are using Cocos2d X, they call it Multi Resolution, hope this helps. Edit: This post from Jesús bosch may give extra information about the topic.


3

With a camera you separate your game measurements from the screen size and ratio. It is not always better. If you make a board game for example, you can just fit it to the width of the screen, the view will never move anyway. When using pixels to measure, you have no floating point positions. By the way i made a full pong like game without a camera. I ...


3

i think cam = GetComponent<Camera> (); is useless and wrong as you already assigned cam in the ispector.


3

Gdx.graphics.getWidth() returns the width (in pixels) of the window (or on mobile, the screen) that your application is running in. cam.viewportWidth is the width of the view of the camera, in whatever unit is applicable for you. Let's say your game world is 100 meters wide, but for some reason you only want to show a portion of that at the time, if you ...


3

Please allow me to elaborate what the responsibility of the GPU should be in the most common scenarios as well as the responsibilities of the CPU, game-engine, and OpenGL. Basics to the OpenGL Pipeline First, in the context of the OpenGL rendering pipeline, the GPU has a vertex shader program which processes only 1 vertex at a time. This vertex is ...


3

You can simply set the camera’s Viewport in the inspector. It defaults to x,y,w,h= 0,0,1,1. You could, for example, set it to 0.2,0.1,0.6,0.8 You can include another camera (full screen) that doesn’t render anything but has a clear color of black and has a depth set so it renders before the main camera to ensure you get black around the edges. The values ...


2

The Viewport class has two methods that are very useful for what you want... Viewport.Project and Viewport.UnProject, The UnProject method converts a screen space point into a point in world space, so if you calculate two points with different Z, you can build a ray in world space or in object space if you pass the right world matrix... Whith that ray you ...


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