If I want to construct complex geomtry models out of simple geometry how would I do that?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

If I want to construct complex geomtry models out of simple geometry how would I do that?

ElvJOGL
Hey,

I have noticed that when one draws a triangle either with shaders or out of vertices in JOGL, the triangle comes out sort of big, and one has to apply scaling to make it smaller.

Isn't there a way where one can take the dimensions of the viewport and build a triangle(s) or a rectangle(s) the size of 50 pixels wide versus a 100 pixels wide triangle or rectangle?

For instance, I dont' want to have to scale down any of the geometry to make them look one bigger or smaller then the next one.

I want the physical distance I have from one vertex to the next to define the shape and size of the geometry. I don't want JOGL to produce that for me. Does this has to do with the perspective matrix?

Any ideas.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: If I want to construct complex geomtry models out of simple geometry how would I do that?

elect
You have two options, if you don't need perspective projection, you can use orthographic projection and make it as big as you want.

Or, you choose perspective projection and then you also set the view (camera) matrix with the so-called lookAt function
Reply | Threaded
Open this post in threaded view
|

Re: If I want to construct complex geomtry models out of simple geometry how would I do that?

ElvJOGL
This post was updated on .
are you saying that with perspective, I am able to follow a non-normalized coordinate system.

For instance for ortho the coordinates are always normalized so to change the [size] of the geometry you have to multiply the scale matrix with the transform matrix, right?

and so, now as you explain, with the perspective matrix instead, I am able to follow a coordinate system where the length of the vector at each vertex is what determines the size of the geometry.

For instance a square under perspective with coordinates {-100, -100}, {100, -100}, {100, 100}, {-100, -100} would draw a square of 200 pixels wide and 200 pixels tall, right?

But I have a problem with the literature that I am reading, they all seem to show ortho transformation and I need to know the basic setup of a perspective transformation that I can draw.

Could you give me an example with perspective using coordinates like in the example above.

And can you tell me, does using perspective projection in for your geometry, does that put more work or is it a performance issue with this projection?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: If I want to construct complex geomtry models out of simple geometry how would I do that?

elect
For ortho the coordinates can also be non-normalized, so that you can leave your geometry as it is

If you need your geometry to have exact and precise dimensions, use ortho setting the sides of the box as big as your screen. If you have 600x400, then choose left = -300, right = -300, up= 200 down = -200, near and far plane up to you, say [-100, 100].

A matrix multiplication costs something (probably very small) in terms of performances, but matrices are one of the fundamentals about 3d rendering, so this is not something you can skip

You don't need to calculate it by your own however, you can use the Floatutility class inside jogl or one of the math lib around like joml or mine jglm