Jump to content
  • Advertisement
Sign in to follow this  
AfroFire

What the heck man...

This topic is 4567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me why: Note: The blank spaces are + signs, and for some reason aren't showing up...
glVertex2d(((box->mX*pMatrix[0])/2.41421 - 0.5), ((box->mY*pMatrix[5])/2.41421 - 0.5));
glVertex2d(((box->mX*pMatrix[0])/2.41421 + 0.5), ((box->mY*pMatrix[5])/2.41421 - 0.5));
glVertex2d(((box->mX*pMatrix[0])/2.41421 + 0.5), ((box->mY*pMatrix[5])/2.41421 + 0.5));
glVertex2d(((box->mX*pMatrix[0])/2.41421 - 0.5), ((box->mY*pMatrix[5])/2.41421 + 0.5));

Gives me the desired result, while the following doesnt? Especially since pMatrix[0] AND pMatrix[5] are both == 2.41421? In theory they should cancel eachother out no matter what, but the one above is actually doing what I want it to do which is nice (I just wish I knew why).
glVertex2d(((box->mX*pMatrix[0])/pMatrix[0] - 0.5), ((box->mY*pMatrix[5])/pMatrix[5] - 0.5));
glVertex2d(((box->mX*pMatrix[0])/pMatrix[0] + 0.5), ((box->mY*pMatrix[5])/pMatrix[5] - 0.5));
glVertex2d(((box->mX*pMatrix[0])/pMatrix[0] + 0.5), ((box->mY*pMatrix[5])/pMatrix[5] + 0.5));
glVertex2d(((box->mX*pMatrix[0])/pMatrix[0] - 0.5), ((box->mY*pMatrix[5])/pMatrix[5] + 0.5));

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Are you sure that pMatrix[0] and pMatrix[5] == 2.41421? Run through with the debugger (F5 usually) to be sure.

Is the matrix a class? Maybe something is wrong with the assessors.

Share this post


Link to post
Share on other sites
What do box->mX*pMatrix[0])/pMatrix[0] - 0.5 and box->mY*pMatrix[5])/pMatrix[5] - 0.5 give you? What is the desired result?

If the desired result is 0 and you get something like -3.589387e-09, then there is nothing wrong.

Share this post


Link to post
Share on other sites
rpg_code_master - when I output the data to a file they are...

JohnBolton - the desired effect is to just have a box follow a polygon without rotating or anything along with the polygon.

Is it possible that the compiler is just cancelling the numbers out ahead of time? Even then the order of operations should still have these numbers cancelled out. I'm just not grasping what is happening here, and I can't keep dividing by a constant number, since this number is one that changes often.

Share this post


Link to post
Share on other sites
Quote:
Original post by AfroFire
rpg_code_master - when I output the data to a file they are...

Not good enough. There are a dozen ways that can go wrong. Check it in the debugger.

Share this post


Link to post
Share on other sites
I have a question regarding your code:

(box->mX * pMatrix[0])/pMatrix[0] + 0.5

is just the same as simply writing

box->mX + 0.5

So why are you doing that?

Share this post


Link to post
Share on other sites
well initially I was playin around with the projection matrix to get this effect I wanted, and I found it worked when I multiplied the projection matrix while I was drawing the point, by the points location, then it was slightly offset, so initially I divided by 2, and it was offset just a little, and I looked in the file where i print output and found 2.4... and so I just typed it in - and it corrected the offset completely, then I went and looked specifically at where the number came from, and sure enough it came from the projection matrix.... so technically speaking --- pMatrix[0]/2.4 --- is the same thing as 1.... however, its result is completely different then pMatrix[0]/pMatrix[0] - which is returning 1 btw..

.... So as Im typing this response - I wondered what would happen if I just did pMatrix[0]/2.4---- and output the difference -- initially it is 1.0, however then it degrades before (eventually) resetting back to one (after a full rotation). Interesting...

Share this post


Link to post
Share on other sites
Here is a screenshot of what I'm essentialy trying to do - This is it rotating on a single axis at a time:


However, here is the problem I experience now on multiple axis -- it gets confused and moves to the upper right and back to the lower left - back and forth... anyone know of a tutorial on how to actually do this properly? I'm just playing guess-work with numbers...

Share this post


Link to post
Share on other sites
I don't think theres much we can do yo help you with the information at hand. Only tell you potential problems.
Either pMatrix doesn't contain the values you think it contains (look in it with the debugger rather than write to a file). OR the error lies elsewhere in your code. OR the mathematics you posted are fundamentally wrong for what you're trying to achieve (actualy someone maybe able to verify this one, but I can't sorry)

Share this post


Link to post
Share on other sites
The mathematics are without a doubt wrong - Just wondering what the right one is.
I think the effect I'm going for though is called billboarding.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!