XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

How to implement metric calculations to 3D Pixels

Last post 3/6/2008 5:10 PM by Ashour. 5 replies.
  • 3/5/2008 3:13 PM

    How to implement metric calculations to 3D Pixels

    Hi,

    I'm currently stuck with a problem that do exists between maths and graphics or XNA inner system,I got an object this object moves i want to calculate its speed so i made variables for acceleration and speed but i can't really implement real speeds and accelerations since i can't convert the metric untis to pixels so for example i got my object moving at 10km/h i wanna make this in pixels so how its possible?

    Ashour
  • 3/5/2008 3:56 PM In reply to

    Re: How to implement metric calculations to 3D Pixels

    Is this a 2D or 3D game? If it's 3D stop thinking about pixels (unless you are working on pixel shader effects). Your 3D motion should be based on how many units/second, not pixels/second.

    But more on topic it depends on what scale you have in your 3D game. If your game is modeled such that 1 unit = 1 meter, then that's a real easy conversion. However if you arbitrarily made your model so that you have a human that's like 17.343285 units tall, then you are in for some fun math to convert that into a real world measurement.

    Either way, it'd help if you describe a bit more of what you have and what you are trying to do (is this for simply displaying the speed or is this for actually moving the object?).
  • 3/5/2008 4:42 PM In reply to

    Re: How to implement metric calculations to 3D Pixels

    it's a matter of scale like Nick said. Here's how you can find it.

    Find the base scale. 2 Meter tall human is 17.343285 units tall in your game. Then 1 unit = 2 / 17.343285 or .1153 meters

    if 1 unit = .1153 meters... then save this. You will reuse this value a lot.

    float unitScale = .1153;


    10Km/h = 10,000 meters/hour = 10,000 / unitScale = 86730.26 units/hour

    so: velocity = metricVel / unitScale;
  • 3/6/2008 4:04 AM In reply to

    Re: How to implement metric calculations to 3D Pixels

    My game is a 3D game and i need this for calulations of movment not only  displaying the speed so am going to try to make a unit measure like the human is 2units = 2 meter then i'll just make everything goes with my units like terrian is 100units that what i got hope that is what you mean.

    Thanks

    Ashour
  • 3/6/2008 11:16 AM In reply to

    Re: How to implement metric calculations to 3D Pixels

    Yes - the bottom line is that YOU decide what a unit is. I you are writing a flight sim then maybe i unit is 1km if you are writing an ant game then maybe one unit is 1mm.

    However once you decide you need to make sure everything is modelled, sized (or scaled and positioned based on those definitions.

    You might still want to avoid hard coding values and use constants so you can tweak forces and things later. eg. 9.8 m/s^2 maybe correct for the real world but sometimes it just feels to fast in a game and maybe you want to balance playability with realism. Its much easier if constants like this exist only in one place.

     

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 3/6/2008 5:10 PM In reply to

    Re: How to implement metric calculations to 3D Pixels

    I now fixed it as making my plane as the unit and i made everything else related to it but i had to reduce the gravity accleration as it was going to be something like 98000.

    Ashour
Page 1 of 1 (6 items) Previous Next