OpenTKstart's picture

Perpective View

Hello,

i want to move the perspective view without transform the graphic object. As you can see on the following pics...

1.

2.

...the object changes it´s position and we can see the side of the cube. Thats not what i want, i want just to move the previewfield, imagine that i have a bigger field-of-view and want to scroll up/down without changing the preview of the object, like this:

I get this effect when i make scaleZ=0. But when i scale the object will lose it´s transformation, like when i zommed in before, the zoom effect get lost.
How can i solve this problem. Sry for my bad english :D

thx


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
avc81's picture

maybe the orthographic projection would suit your needs.

mOfl's picture

As avc81 said, the orthographic projection is what you want. What you do not want is the perspective distortion, yet this is exactly what the perspective projection does. Either you use the orthographic projection or you implement an algorithm known from billboarding such that the cube always faces the camera. The first one is the way to go.

OpenTKstart's picture

Wow thx, thats what i want. But everything is now bigger, how can i zoom. The transformation in x,y-direction works, but not in z-direction...

avc81's picture

i implement zoom by means of the Matrix4d.CreateOrthographicOffCenter function

OpenTKstart's picture
avc81 wrote:

i implement zoom by means of the Matrix4d.CreateOrthographicOffCenter function

And when you want to zoom, you always call this method or do you call MatrixMul. And i dont know how to change the values (left,right,top,bottom) to zoom in and out. I tried a lot but the object just change its form...

avc81's picture

every time there is a "zoom action" i recalculate left,right, top, bottom values and then i call that method.

= OpenTKstart wrote:

And i dont know how to change the values (left,right,top,bottom) to zoom in and out

Basically a "n0-zoom" scene is given by

 Dim right As Double = _scenewidth * 0.5 
 Dim top As Double =_sceneheight * 0.5 
 Dim left As Double = - _scenewidth * 0.5 
 Dim bottom As Double = - _sceneheight * 0.5

while a "zoomfactor-scene" is given by

 Dim right As Double = _scenewidth* 0.5 * _zoomfactor
 Dim top As Double = _sceneheight * 0.5 * _zoomfactor 
 Dim left As Double = -_scenewidth * 0.5 * _zoomfactor
 Dim bottom As Double =- _sceneheight * 0.5 * _zoomfactor

where zoomfactor must be >0 (just play with this value and see what happens ;))

Hope this helps

avc81's picture

...obviously i'm assuming that your entity is centered at 0,0,0

OpenTKstart's picture

Thx, i got it now.
My second problem now is to fix the object at the mouse while i move it (right, left, top, down). Because the ratio changes in every zoom-position. I move the object by Transformation. I calculated the moveDivFactor based on the screenSize:

like this:
800x1 + 600x2 = 36
800x1 + 800x2= 48
...so i got x1=0 and x2=0,06

however it worked fine but only when i dont zoom

transformation.X -= e.XDelta / (float)(this.Height * _moveDivFactor );
transformation.Y -= e.YDelta/ (float)(this.Height * _moveDivFactor ) ;

But know when i zoom the proportions change and the object isn´t fixed at the object 1:1 when i move it. Do you have any clue?