Jump to content

  • Log In with Google      Sign In   
  • Create Account

Nanoha

Member Since 26 Feb 2009
Offline Last Active Today, 01:48 AM

Posts I've Made

In Topic: Resizing orthographic camera while zoomed in

27 April 2016 - 09:31 AM

Screenshot 5 looks odd, that does suggest a viewport type issue.

 

Are screenshot 1 and 2 correct or should the quad in screenshot 2 have be the same size but clipped?

 

How does a user interact with this? How do they make it zoom, do they drag the view around to move or do they click?

 

I can't really say what the exact problem is as it's probably a combination of things probably all spread out. I would approach this by trying to boil it all down to having 3 basic values, the zoom level (1x, 2x, etc) and an x/y position which you want to put at the centre of the window. Then I'd make a method that uses just those 3 values and the display size and builds both a projection matrix and a view matrix from it. Those are probably all you need to do it, you can probably get away without a view matrix too as the orthogonal projection can store that quite easily. It's probably more efficient to use only the projection matrix since you are just using 2D.

 

If any of the values change, such as the screensize, or the magnification or the positions then just call that method which will correctly build your projection. I am not familiar with DirectX but when your display size changes you may need to update the viewport or similar too.

 

How you update those values depends on how the user interacts so I can't say much but you are definitely on the right track where you convert window space to world space values as doing that makes life much easier. 

 

I think your current solution is more complicated than it needs to be but I certainly don't have as good an overview of your project as you do.


In Topic: Resizing orthographic camera while zoomed in

25 April 2016 - 03:32 PM

Could you post the code that is taking account of the zoom and also the part where you build the view matrix.

 

Some suggestions that might help you figure out the problem:

Hard code the interactions, i.e. you always 'click' the exact same place each time and zoom the exact same amount. That'll help reduce the amount of variables at play.

It might be helpful to try and use some type of checkboard image instead of the camera feed too, that should help figure out what's going on where you have an image behind as in picture 5 where there is that slight bit of extra text. With a checkboard type image instead you can see if that back image is of the previous magnification or the new magnification etc.


In Topic: Resizing orthographic camera while zoomed in

25 April 2016 - 01:54 PM

Now the trouble i'm having is to resize the orthographic camera when the window size changes while i'm zoomed in. 

Part of this issue is my quad now renders on the entire screen rather than the co-ordinates i specify.

 

If i now click on the window area then my quad is rendered correctly within the co-ordinates that I specify on window resize with the texture but i still see the texture image that was rendered on the entire screen before the quad is rendered on the appropriate co-ordinates..

 

If i'm completely zoomed out then resizing is fine and works as expected.

 

A few screenshots might help explain your problem a bit better. This sounds like an issue clearing the backbuffer/invalidating the window. It sounds like only the original window area is being updated, try checking for things like scissor rects/viewports.

 

Are you rebuilding your projection matrix when the window resizes as it sounds like calling that section of code solves the problem. I recall your previous thread and the suggestion I made should work when you resize the window:

// going to zoom in 200%
float zoom = 2; // 200%
float xPos = ...
float yPos = ...
float left = -m_displaySize.Width/(2*zoom) + xPos;
float right = m_displaySize.Width/(2*zoom) + xPos;
float top = -m_displaySize.Height/(2*zoom) + yPos;
float bottom = m_displaySize.Height/(2*zoom) + yPos;
m_projectionMatrix = Matrix.OrthoOffCenterLH(left, right, bottom, top, 0f, 100.0f);

You would have to store that x/y position and rebuild using the previous known values for them when the window resizes.


In Topic: List.Sort() lag

23 April 2016 - 10:18 AM

How are you adding those objects? Perhaps something that keeps the list ordered all the time will work better. I would think that if it is possible it's probably better to insert the item int he correct position as you add it than it is to add to the end and then sort. You'd need to use a container that supports insertion like a linked list.


In Topic: Can anyone help me test canvas on mobile?

21 April 2016 - 01:08 AM

Worked fine on:

Nexus 5

Samsung Galaxy Tab S2

 

Using Chrome on both.


PARTNERS