Welcome! Log In Create A New Profile

Advanced

Assignmet 2 Question 4 I'm lost

Posted by william 
Announcements Last Post
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
Assignmet 2 Question 4 I'm lost
March 31, 2009 08:36PM
I red the previous post about this question and I have looked at the example. I am at a bit of a los as to how we are supposed to draw the geometric primitives e.g. the cone, the cylinder and the semicircle.

I see that between glut and glu there are predefined functions to draw all the primitives we need. But these functions just draw the shapes (they do not give the vertices for the shapes created) which means there is no way to translate or rotate these objects to build a hut for example - Am I correct?

The second option seems to be to write/find our own algorithms to generate these shapes. This is the way I am leaning towards at the moment. But it does seem like a lot of work unless there is some place in the prescribed metrical I missed that gives algorithms/functions to draw these shapes.

What approach are you following to draw the shapes?

Thanks
avatar Re: Assignmet 2 Question 4 I'm lost
March 31, 2009 09:14PM
Just finished Assignment 1, didn't even want to start to think about the next nightmare!
Re: Assignmet 2 Question 4 I'm lost
April 20, 2009 09:45AM
I am also stuck on this, I see that glu provides a function for drawing a cylinder for example and it does seem easier to go that route.
Re: Assignmet 2 Question 4 I'm lost
April 20, 2009 10:06AM
Hi,

I managed to get the assignment done. I ended up going the route of drawing all the primitives myself. I had one problem when using the library. The primitives seemed to take the last color assigned using glcolor (so they all ended up being the same color). I did not spend a lot of time trying to figure out why. Other then that I don't foresee any problems using the library functions.
Re: Assignmet 2 Question 4 I'm lost
April 20, 2009 11:02AM
When you say "I ended up going the route of drawing all the primitives myself" do you mean that you wrote you own algorithms? or did you use for example of Cylinder "gluCylinder();" ?
Re: Assignmet 2 Question 4 I'm lost
April 20, 2009 11:19AM
Yip wore my own algorithms I am sure you will be able to find help on the net with the more difficult algorithms. When I asked the question above I thought I would have to rotate each vertex separately (like I did with the stick figure in assignment 1). This is not the case when using glRotate you do not need the vertices so there is nothing stopping you from using glu or glut functions.
Re: Assignmet 2 Question 4 I'm lost
April 22, 2009 01:10PM
I am using the function "gluCylinder" for the hut wall and the problem is when I try to rotate it with the rest of the scene it is staying in it place while the rest of the scene rotates. Did any one find this problem and solve it?
When i said the cylinder did not rotate with the rest of the scene I meant that it rotates in its place, without rotating along with the rest of the scene.
Re: Assignmet 2 Question 4 I'm lost
April 24, 2009 08:50AM
For anyone experiencing he above problem, the solution is to pay attention to the order of rotate and translate. In my case I had to first Rotate and then translate.
Have a good weekend thumbs up
Re: Assignmet 2 Question 4 I'm lost
April 24, 2009 09:00AM
Good stuff. Did you have a problem asigning the color to the gluCylinder?
Re: Assignmet 2 Question 4 I'm lost
April 26, 2009 07:53AM
I have not tried yet, I will let you know smile
Re: Assignmet 2 Question 4 I'm lost
April 26, 2009 10:39AM
The colour was no problem works fine. Wanted to ask what function you used for the zoom, Glulookat does not seem to work properly and perspective I am not sure about, any suggestions for this? Also do you have to apply the function to each shape or can it be done globally?
Re: Assignmet 2 Question 4 I'm lost
April 26, 2009 05:27PM
I used Glulookat for the zoom yes. I am sure as you have guessed it is just a matter of moving the cammera closer and further away from your scene (that is what I did anayway) and as such is aplied globaly. The only tick I used when positioning the cammera is to: give your cammera a distance from the scene and angle with the scene (then you use sin and cos the calculate the x, y and z courdinates of the cammera), not saying you have to do it that way but it made things simpler for me. What problems are you having?
Re: Assignmet 2 Question 4 I'm lost
April 27, 2009 11:25AM
I understand what the glulookat function does, but I do not know how to implement it, I have attached a call for the keys } and { to function which has the glulookat function it and I have tried different calculations with in the glulookat function mainly for the Z components and the Centre X component and nothing is happening to the overall scene, I then thought perhaps I should add the glulookat inside the glutReshapeFunc thinking it has something to do with the reshaping but still nothing.

Am I on the right track?
Re: Assignmet 2 Question 4 I'm lost
April 28, 2009 07:45AM
Try the following. Use gluLook in your display function (do it before you rotate the entire scene) Hope this helps
Re: Assignmet 2 Question 4 I'm lost
April 30, 2009 08:10AM
Thanks, I will give it a try.
Re: Assignmet 2 Question 4 I'm lost
May 01, 2009 05:19PM
I'm struggling to draw the semi circle, can anyone help me?
Re: Assignmet 2 Question 4 I'm lost
May 03, 2009 08:40AM
I too am stuggling with the semi sphere.
Re: Assignmet 2 Question 4 I'm lost
May 03, 2009 11:25AM
I am having trouble with the rotation, I have no problem rotating the scene when it is at 0 degrees which will rotate on the X-axis, my problem is the rest of the angles, how do you rotate the scene proportionaly?
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 09:27AM
Hi,

I am not sure if understand your question correctly but... It sounds like your cammera is remaining in one place and you are rotating the scene around the x axis to give either a more top or a more front view am I correct? I did it the other way around I move the cammera and only rotate the scene around the y axis. What are the simptoms of the problem? (for lack of a better description does it wobble or does it not rotate around the center of the scene?) I have not tried it myself but i dont see a problem with you rotating your scene around more then one of the axis.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 09:37AM
It wobbles, i.e. it turns in all directions and does not look like the example given by the lecturer. Perhaps I should be using a function such as gluLookat or something of that nature to rotate the camera around instead of the scene as you mentioned, the question is how?

While I am writing what did you do for the semi-sphere problem?, I tried using the glsphere and then clipping it but that does not help because the scene rotates and where ever you clip it eventually it will disapear from the scene.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 09:54AM
Ok wait.... I just want to make sure we are not missing each other.
Yes I use glLookat. But I calculate the coordinates for the camera myself (as mentioned quite a few posts back)
I rotate the scene about the y-axis (and only about the y-axis).
Then I move the camera up and down (remember to always keep the camera the same distance from the center of the scene (the distance of the camera only changes when zooming).)
I found an algorithm for a sphere in a book and adapted it to only draw the top half of the sphere.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 12:37PM
Thanks, that is what I meant. I shall work on this again, and will try post my results.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 02:41PM
When you say calculate the coordinates, you are using COS and SIN and only calculating for x and y coordinates right?
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 02:48PM
Now that I am thinking about it you probably do not use glrotate at all to rotate the scene but rather you are using glulookat for that as well, am I right? at least this is what I am understanding from yoor last few posts
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 02:56PM
I ll look at the how I position the camera again tonight. I use glRotate to rotate the scene around the y-axis. I move the cammera up, down, closer and further.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 03:34PM
When you say " I move the cammera up, down, closer and further" I assume you are talking about using gluLookat()?
In between thanks for the guidance smile
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 03:40PM
Jip I change the parameters that go into gluLookat() when zooming or moving the camera up and down.

No problem glad to help.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 03:52PM
Thanks, I look forward to hearing from you tonight.
Re: Assignmet 2 Question 4 I'm lost
May 04, 2009 04:43PM
I have a feeling you made a mistake when you said "I rotate the scene about the y-axis (and only about the y-axis)" I think you might have meant the z-axis, as it does not seem to make any sense any other way. smile
Re: Assignmet 2 Question 4 I'm lost
May 05, 2009 07:30AM
Hi, It is difficult to awnser that one, I am sure I rotate around the y-axis because that is what the question asks (under the keyboard callback heading first bullet). In my project if I whould rotate around the z-axis the scene whould be upside-down after 180 digrees of rotation. Now back to your prevous question.
To calculate the camera position.
I use cos for the x coordinate,
I use sin for the y coordinete,
and I use cos for the z coordinate.
Sorry, only registered users may post in this forum.

Click here to login