C++, Unreal unit converter

I cant seem to find any Unreal unit converter programs out there, i did find one actually but it doesnt work for me so i figure just make my own, but the problem is i dont even know where to start. How do i begin? i want to convert feet, centimeters, inches, and meters, i want to be able to convert to and from real units and unreal units. So how would i go about doing something like this? please explain in as much and best detail as possible. Fo those of you who dont know what an Unreal Unit is, its a unit of measurement used by Unreal Engine 3. Here is a chart showing the UU and what they convert to in real life.

http://dannyquesada.weebly.com/uploads/5/5/1/0/5510136/6450296_orig.jpg?563
Well start out with a basic uuToInches function, where it accepts the int uu and returns the inches value, which would be times 6 and divided by 8.
Ok sweet, now im a bit confused on the feet part:

1
2
3
4
5
6
7
8
9
10
11
12
void UUToFeet()
{
    int uuFt;

    cout << "Unreal Units to feet" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuFt;
    cout << "\n";

    cout << "Feet: " << uuFt * 12 / 16 << endl;
}


I entered 96 UU which should come out as 6 ft but comes out as like 128 or something.
Because 16uu equals 12 inches, or, 1 foot. It should just be / 16, not * 12 / 16. You only multiply by 12 to get inches. It might also be beneficial to make either macros or an enum to set up the conversion.
Last edited on
I dont know how to do Enum or macros, ill look into it some other time but i want to do it like this right now, so like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
void UUToFeet()
{
    int uuTft;

    cout << "\n";
    cout << "Unreal Units to feet" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTft;
    cout << "\n";

    cout << uuTft / 16 - 12 << " feet" << endl;
}


I enter 96 and i get -6 ft
Last edited on
Lol, no. Why are you subtracting 12? 6 - 12 = -6. It should be:
cout << uuTft / 16 << " feet" << endl;
Ok thanks, now, i was doing the centimeters and my number was a little off is that ok or did i do it wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
void UUToCentimeters()
{
    float uuTcm;

    cout << "\n";
    cout << "Unreal Units to Centimeters" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTcm;
    cout << "\n";

    cout << uuTcm / 0.525 << " Centimeter" << endl;
}


ok so 1 cm = 0.525 UU and when i enter 256 UU which is 487.68 cm i get: 487.619
Because you're rounding the conversion rate. The best way to get an accurate answer is to do this:
convert to inches first: uu / 16 * 12
convert to cm next: inches * 2.54

If uu = 256:
256 / 16 = 16 feet
16 * 12 = 192 inches
192 * 2.54 = 487.68 cm
Last edited on
Out of curiosity, why does Unreal have it's own measurement system?
Because of the huge engine. It basically translates down to 4 bits = 1 uu

I believe I have that wrong -.- I can't think about what the binary conversion is.
Last edited on
Wait i just realized something, i need to convert real life units to unreal units -.-, so would i just revers my stuff? EX: instead of uuTcm / 0.525 would it be 0.525 / uuTcm?
No, it would be multiplication. Also, you still need to go step by step. You're also going to be entering inches, or feet, or cms, or meters and need to convert back to feet then convert to uu.
Last edited on
i already have inches and centimeter and all that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//Unreal Unit Converter
//Created By Chay Hawk

#include <iostream>
#include <string>

using namespace std;

void UUToInches();
void UUToFeet();
void UUToCentimeters();
void UUToMeters();

int main()
{
    string choice;

    cout << "Welcome to the Unreal Unit Converter - Version: 1.0.0 Alpha" << endl;
    cout << "" << endl;
    cout << "What operations would you like to do?" << endl;
    cout << "Type in only the number" << endl;
    cout << "\n";

    //Setting up the user menu

    cout << "Unreal Units to Real Life Units" << endl;
    cout << "" << endl;
    cout << "1. UU's to Inches" << endl;
    cout << "2. UU's to Feet" << endl;
    cout << "3. UU's to Centimeters" << endl;
    cout << "4. UU's to Meters" << endl;
    cout << "\n";

    //cout << "Real Life Units to Unreal Units" << endl;

    cout << "Choice: #"; cin >> choice;

    if(choice == "1")
    {
        UUToInches();
    }
    else if(choice == "2")
    {
        UUToFeet();
    }
    else if(choice == "3")
    {
        UUToCentimeters();
    }
    else if(choice == "4")
    {
        UUToMeters();
    }
}

//Below are the Unreal Unit to real life unit conversions

void UUToInches()
{
    float uuTin;

    cout << "\n";
    cout << "Unreal Units to inches" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTin;
    cout << "\n";

    cout << uuTin * 6 / 8 << " inch(es)" << endl;
    cin.get();
}

void UUToFeet()
{
    float uuTft;

    cout << "\n";
    cout << "Unreal Units to feet" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTft;
    cout << "\n";

    cout << uuTft / 16 << " feet" << endl;
    cin.get();
}

void UUToCentimeters()
{
    float uuTcm;

    cout << "\n";
    cout << "Unreal Units to Centimeters" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTcm;
    cout << "\n";

    cout << uuTcm / 0.525 << " centimeter(s)" << endl;
    cin.get();
}

void UUToMeters()
{
    float uuTm;

    cout << "\n";
    cout << "Unreal Units to Meters" << endl;
    cout << "\n";

    cout << "Unreal Units: "; cin >> uuTm;
    cout << "\n";

    cout << uuTm / 52.5 << " meter(s)" << endl;
    cin.get();
}


so basically i would do: uuTft * 16 ??
No, you can't enter uu's and expect to get uu's. -.-

Let me make a basic converter quickly.
Here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>

float FeetToUU(float number) { return (number * 16.0); }
float InchesToUU(float number) { return FeetToUU(number / 12.0); }
float CMToUU(float number) { return InchesToUU(number / 2.54); }
float MetersToUU(float number) { return CMToUU(number * 100.0); }

int main() {
   std::cout << "Please select an option\n"
             << "\n"
             << "1) Feet to UU\n"
             << "2) Inches to UU\n"
             << "3) Centimeters to UU\n"
             << "4) Meters to UU\n"
             << "\n";
   int selection;
   std::cin >> selection;
   float number;
   switch (selection) {
      case 1:
         std::cout << "\nPlease enter number of inches: ";
         std::cin >> number;
         std::cout << "\n" << number << " inches = " << InchesToUU(number) << " UU";
         break;
      case 2:
         std::cout << "\nPlease enter number of feet: ";
         std::cin >> number;
         std::cout << "\n" << number << " feet = " << FeetToUU(number) << " UU";
         break;
      case 3:
         std::cout << "\nPlease enter number of centimeters: ";
         std::cin >> number;
         std::cout << "\n" << number << " centimeters = " << CMToUU(number) << " UU";
         break;
      case 4:
         std::cout << "\nPlease enter number of meters: ";
         std::cin >> number;
         std::cout << "\n" << number << " meters = " << MetersToUU(number) << " UU";
         break;
      default:
         std::cout << "\nNot a valid option!";
         break;
   }
   return 0;
}


It's very basic, but I just called the functions to convert it in the proper order. I didn't have actual values to test. But I do believe that is right.
Ok i got it all to work, thanks a ton :)
Topic archived. No new replies allowed.