LDraw.org Discussion Forums

Full Version: Simple renderer in .net with SharpGL (openGL)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
I think so, but i'm not sure. I am a bit confused by my own ancient code (given it uses 1,-1,1 which seems to be the neg y correction and not left/right conversion). In short I think my above code is wrong and/or just plain inefficient Smile

So i did a bit of searching and found you can actually just use right handed stuff in directx just by replacing the LH with RH in all the api calls.
Ok, i'll try.
Life can be so easy Smile Thanks, that problem is solved. If I run into the next I'll ask again.
Ok, here is my next challenge:

I have currently a fixed value for field of view and distance.
The lookat point is calculated as the middle of the bounding box.

But how can I calculate the field of view and the distance (camera location point) to get the same behaviour like all other viewers out there???
In LDCad I use the zoom value as the with of the frustum at the lookat point. Everything else is then calculated based on that.
I think I know what I was doing in my old code, it doesn't matter which axis you clip as long it exactly one, so I choice Y to simultaneous correct for the neg y axis.
I am sure you are right Smile
But I have no clue how to do all this. You know my code. Where should I add what???
Sorry for being so stupid, but all the vectors drive me crazy. Also in schooltime vectors has not be my friends.
I'm afraid setting up a decent camera system isn't done in a couple of lines, I use a handfull of different classes (window, frustum, boundingbox, etc) for it in my renderer.

First you (neg) translate your scene to the lookat point and apply optional rotation.
Then you calculate the distance from the lookat point to the eye (zoom and fov angle combined with trigonometry)
That value you use to (neg) translate the scene, so it ends up in front of the camera.
Last you determine far and near

In this situation the camera eye is always at 0,0,0 and you basically put the model inside it's view (frustum).
Ok, thanks so far for your help.

I understand (hopefully) most of what you have said.
But I think it needs to be calculated the other way round.
Field of view is a given (fixed) value (maybe changeable elsewhere) and based of the bounding box I need to find the distance to this bounding box by a calculation. The camera will be only zoomed on a dedicated line. By doing this I have always the same point from which i look at the model.
O you are looking for the auto fit values, sorry I thought you wanted a simple movable camera.

Simplest way to do auto fit is to calculate the bounding sphere of the model and based on it's radius and the lookat point calculate the eye position.

An exact auto fit is something very different though, I'm still not happy with mine (which is the 3rd version or so).
Pages: 1 2 3 4 5 6