Scaling 3D Projection

Hello all,

Me and a friend are working on making our own 3D renderer for this semester. Now the only simple point of this renderer is to display an .obj file that’s loaded by using triangles. That’s it no fancy stuff. We set some goals to only use java graphics to accomplish this.

Our method simply takes the perspective projection formula, which can be found in wikipedia, and draws it on the screen. Our problem is that we need to set the viewer’s perspective to a ridiculously large value to get the model to display and even that won’t do it properly.

Does anyone have some advice on how I could scale the perspective formula relatively to the screen size?

If code is needed I would be glad to provide it, but I love to tackle new problems and attempt my best, so any pointers would be great.

Thanks!

You just have to scale the model matrix for that object.

Creating a scale matrix is easy:


    public Matrix4f initScale(float x, float y, float z) {
        //@formatter:off
        m[0][0] = x;        m[0][1] = 0;        m[0][2] = 0;        m[0][3] = 0;
        m[1][0] = 0;        m[1][1] = y;        m[1][2] = 0;        m[1][3] = 0;
        m[2][0] = 0;        m[2][1] = 0;        m[2][2] = z;        m[2][3] = 0;
        m[3][0] = 0;        m[3][1] = 0;        m[3][2] = 0;        m[3][3] = 1;
        //@formatter:on

        return this;
    }

and simply also multiply this where you create your model matrix (with the others like position and rotation). Not sure why you’re having problems with it.

I’m very rusty. I’m probably making myself look like an idiot.

I see…

I’m not using the matrix formula, but rather the polynomial given. Thanks for the pointers!

Not sure what you mean by the polynomial given, but modern opengl runs off your matrices. You need to pass them into shaders so that GLSL knows how to do shtuff.
Are you not using modern opengl ie 3.x?

We are not.

I apologize if is not stated correctly, but we are simply using Java’s graphics library to draw the faces extracted from an .obj file. No opengl, or anything else.

@Slyth2727

[quote=“vaironl,post:1,topic:52069”]
@vaironi

Maybe this would help: http://stackoverflow.com/a/10360723. Author says that you can scale by multiplying the screen width by a focal length. Maybe try fiddling around with that value. Code snippets would be helpful for further assistance.

CopyableCougar4

Excuse me for not being able to read.