Welcome! Log In Create A New Profile

Advanced

Mesh display.

Posted by BenVP 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Mesh display.
February 14, 2011 03:48PM
Ok, so I managed to copy the data into a 2D array. Yet when I use the algorithm on page 269 I get a cross section of the mesh and my computer just hangs and refreshes after a while with the same image.When I sample the data, the cross section becomes even more jagged.

I am currently using myinit() with
Language: C++
glOrtho(0.0, 50.0, 0.0, 50.0, -50.0, 50.0);
inside of it.

I have also tried using this function instead of myinit()
Language: C++
void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w, 50.0*(GLfloat)h/(GLfloat)w, -50.0, 50.0); else glOrtho (-50.0*(GLfloat)w/(GLfloat)h, 50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -50.0, 50.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity (); }

Using my reshape causes nothing to be displayed.
Have tired a small 5x5 array with lower numbers and it works fine on both functions.

Am I missing anything? Been struggling with this for a week now,
Any help / advice welcome

Thanks,
Benjamin Prevenhueber
avatar Re: Mesh display.
February 15, 2011 02:20PM
Hanging problem has been solved by sampling.cpp that has been uploaded onto MyUnisa.
avatar Re: Mesh display.
February 15, 2011 05:52PM
After a week of pulling my hair out, I finally have a mesh of Honolulu smoking smiley

Re: Mesh display.
February 23, 2011 10:48PM
iv been using the same ortho and myinit and getting a distorted mesh...still pulling my hairconfused smiley
Re: Mesh display.
February 24, 2011 12:23PM
im not sure how to scale...where about must i look to find info on that...thanx
Re: Mesh display.
February 24, 2011 02:39PM
jen8, I'd say you should look to scale in the sampling code that was given us. I did mine there, untill I found my mesh looking normal.

_______________________________________
Don't be different...be the one making a difference
avatar Re: Mesh display.
February 24, 2011 02:46PM
BlaXpydo Wrote:
-------------------------------------------------------
> jen8, I'd say you should look to scale in the
> sampling code that was given us. I did mine there,
> untill I found my mesh looking normal.

Just devide the ypt by an integer value before you store it.
avatar Re: Mesh display.
February 24, 2011 03:02PM
jen8 Wrote:
-------------------------------------------------------
> iv been using the same ortho and myinit and

Asked the lecturer a week ago about glOrth version of myReshape and he said we should use the one on page 267, which uses a glFrustum.
Just change the last value (20.0) to (200.0) in both the if and else parts, to get a bigger volume.
See if that helps.

> getting a distorted mesh...still pulling my hairconfused smiley
Re: Mesh display.
February 28, 2011 12:47AM
thank you soooooooo much for all your help i finally completed this assignment...smiling bouncing smiley ...the scaling did help.i divided the y by 0.01
avatar Re: Mesh display.
February 28, 2011 09:28AM
You're welcome.
Glad I could help.
Re: Mesh display.
March 01, 2011 10:25PM
BenVP

What options did you use to make the lines not get drawn in front of the meshes?

My current program at the moment looks almost exactly the same then yours but I can see my GL_LINE_LOOP lines that should be behind the mountain any insight would be appreciated.
avatar Re: Mesh display.
March 02, 2011 09:00AM
>but I can see my GL_LINE_LOOP lines that should be behind the mountain
when does this occur?

Things to look out for:
Have you used the polygon offset code on page 269?
Is it in the right order? gl_quads then gl_line_loop
How are you viewing the object? + / - z?
What angle of view are you using?
Re: Mesh display.
March 02, 2011 06:34PM
BenVP Wrote:
-------------------------------------------------------
> >but I can see my GL_LINE_LOOP lines that should
> be behind the mountain
> when does this occur?
>
> Things to look out for:
> Have you used the polygon offset code on page
> 269?

You mean:

glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(1.0, 0.5);

as you init your application or:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

as you reshape your viewport? Sorry I'm using the Fourth Edition of the prescribed book.


> Is it in the right order? gl_quads then
> gl_line_loop

Yes

> How are you viewing the object? + / - z?

using glFrustum with a +2.0 on z.

> What angle of view are you using?

I'm using gluLookAt(viewer[0],viewer[1],viewer[2], 5.0, 0.0, 5.0, 0.0, 1.0, 0.0);

So to see my problem here is a image:



Is it cheating to enable GL_DEPTH_TEST?

Thanks,
avatar Re: Mesh display.
March 02, 2011 08:54PM
d-_-b Wrote:
-------------------------------------------------------
> BenVP Wrote:
> --------------------------------------------------
> -----
> > >but I can see my GL_LINE_LOOP lines that
> should
> > be behind the mountain
> > when does this occur?
> >
> > Things to look out for:
> > Have you used the polygon offset code on page
> > 269?
>
> You mean:
>

I meant did you use the code segment
Language: C++
glColor3f(1.0, 1.0, 1.0); glBegin(GL_QUADS); glVertex3i(i,y[i][j],j); glVertex3i(i+1,y[i+1][j],j); glVertex3i(i+1,y[i+1][j+1],j+1); glVertex3i(i,y[i][j+1],j+1); glEnd();   glColor3f(0.0, 0.0, 0.0); glBegin(GL_LINE_LOOP); glVertex3i(i,y[i][j],j); glVertex3i(i+1,y[i+1][j],j); glVertex3i(i+1,y[i+1][j+1],j+1); glVertex3i(i,y[i][j+1],j+1); glEnd();


> glEnable(GL_POLYGON_OFFSET_LINE);
> glPolygonOffset(1.0, 0.5);

Never used this. ^
Not meant to be used.

>
> as you init your application or:
>
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
>
> as you reshape your viewport? Sorry I'm using the
> Fourth Edition of the prescribed book.

I don't think the book editions are that different.
I could be wrong.

>
>
> > Is it in the right order? gl_quads then
> > gl_line_loop
>
> Yes
>
> > How are you viewing the object? + / - z?
>
> using glFrustum with a +2.0 on z.

Try zooming out more to see what happens.

>
> > What angle of view are you using?
>
> I'm using gluLookAt(viewer[0],viewer[1],viewer[2],
> 5.0, 0.0, 5.0, 0.0, 1.0, 0.0);
>
> So to see my problem here is a image:
>
> http://i.imgur.com/0kqvS.jpg
>
> Is it cheating to enable GL_DEPTH_TEST?

This just makes the mesh look fragmented,
it looks better without it. Not meant to be used.

>
> Thanks,
Re: Mesh display.
March 03, 2011 11:52AM
Ok, been working on the assignment this week...all seems fine, but I'm not happy with my mesh. Too linear. Why could that be?

_______________________________________
Don't be different...be the one making a difference
Re: Mesh display.
March 04, 2011 09:52AM
Thanks for the feedback BenVP!

I was a idiot:

I created a function called DrawHeightMap(bool wireframe) where I first draw all the quads and then the lines and that created the "see through" effect as in the image I posted earlier.

Kind Regards,
avatar Re: Mesh display.
March 04, 2011 04:35PM
You're welcome.
avatar Re: Mesh display.
March 04, 2011 04:35PM
Hi guys,

I having trouble with the drawing of the mesh, everything looks OK at the start,
as you can see where I made the arrow the back lines, are at the back of the mountain where they should be.

But now when I zoom in on the small bump in the rectangle area, it looks fine...

until I rotate around it a bit...

Is there any trick or something I can use to get around that?
I used the code on page 296, but that did not solve this problem.

Thanks
Rotti
Re: Mesh display.
March 07, 2011 11:38AM
hello could you please help me,i dont know what to do with these honolulu sample digits

blv
avatar Re: Mesh display.
November 05, 2011 02:01AM
BenVP Wrote:
-------------------------------------------------------
> Hanging problem has been solved by sampling.cpp
> that has been uploaded onto MyUnisa.

Hi, from the name of this .cpp file and the screenshots I've seen, I suspect this might be similar to my solution from some years ago: http://dl.dropbox.com/u/3038174/cos340%20ass2.pdf

I'd greatly appreciate it if you could post the code here or mail it to me at thomas.ludwig@gmail.com, thanks grinning smiley
Sorry, only registered users may post in this forum.

Click here to login