As you can see I've made an option to disable using the mat44-matrix. When I disable it, the cone gets drawn but the rotation is wrong. When I enable it, the cone is NOT drawn... Am I multiplying with a wrong rotation matrix and does that explain why nothing gets drawn?

There are no errors/warnings or anything... I don't understand this...

01-02-2013, 11:41 PM

newsb

Quote:

Originally Posted by newsb

There are no errors/warnings or anything... I don't understand this...

Ok, to help myself and some of you, I've tried to make a complete program in C which you can compile and run:

I don't understand why the cone doesn't get displayed correctly... I would REALLY appreciate some feedback, thank you... And now you should be able to copy/paste the code and run it (test on linux with gcc - I think windows would work out of the box too). You can then disable/enable the cone stuff (which I don't understand why is not working)...

I hope to hear from someone soon. Thanks.

01-03-2013, 09:53 AM

Carmine

I've run your code and had slightly better results than you.
The cone does show up when I do glMultMatrixf (mat44).
But it is not oriented or positioned properly.
Make sure you're not calling glLoadIdentity before MultMatrix.
That will definitely mess things up.

I noticed that you have the ability to print out the contents of mat44.
It's a good idea. When you do that do you get what you expected?
Do you know what the contents of a rotation transformation matrix should look like?
This can be Googled. Trig functions are involved.
Do you know what axis you should be rotating the cone around to put it in the proper orientation?

Did you know that you can use the glRotate command to accomplish what you
are trying to do without ever messing around with matrices?

01-03-2013, 01:03 PM

newsb

Quote:

Originally Posted by Carmine

I've run your code and had slightly better results than you.
The cone does show up when I do glMultMatrixf (mat44).
But it is not oriented or positioned properly.

Oh, sorry... After many hours and after having read and thought about what you wrote, I realized that my way of getting the mat44-matrix is completely nonsense... I had it mixed up with something else in my head... Sorry...

Quote:

Make sure you're not calling glLoadIdentity before MultMatrix.
That will definitely mess things up.

Ok, thank you - you're right - I understand...

Quote:

I noticed that you have the ability to print out the contents of mat44.
It's a good idea. When you do that do you get what you expected?
Do you know what the contents of a rotation transformation matrix should look like?
This can be Googled. Trig functions are involved.
Do you know what axis you should be rotating the cone around to put it in the proper orientation?

I think I can do it without using trig functions, but by using cross products... I've done something similar another time before, let me look into my old code and get back within 1-2 days...

Quote:

Did you know that you can use the glRotate command to accomplish what you
are trying to do without ever messing around with matrices?

As I wrote - I found out that I cannot construct mat44 like I do it now. I typically/usually get an invalid rotation matrix by using the method I've shown here. That explains why python didn't show anything. However, it doesn't explain why the C-code shows something... hmmmmmm. Strange C-code.... I don't understand why it shows anything at all because that transformation/rotation matrix I've made is simply nonsense with invalid directions - for instance, here is something from my python program:

I'm very happy that you took the time to write a few things - just these small things made me think a lot and spend hours remembering how I one solved a similar problem... I'll go to bed now and go to work tomorrow, but within 1-2 days I'll get back and write how I think this can be solved in an elegant way...

Thank you very much - I appreciate your help - I think I'm on the right track again now, after having been stuck for some days with this now ! :D

I'll get back with a solution - for the record - now people are helping me, so I want to give something back too, that others can/might use...

01-03-2013, 02:27 PM

Carmine

Yes. You could do this with some vector cross products, normalization, etc.

Yes. You could do this with some vector cross products, normalization, etc.

Thanks a lot for your help, Carmine. Just for the record, here's my python solution so other people can use if they like. If anyone modifies my original C-program to work with this, please post the code. It should be a VERY small task for anyone to rewrite this python-code into the equivalent C-code.