The following code calculates the cubic volume in millimeters of a prim each time its resized. It then uses that value to give you the prims volume in milliliters. Volume of a cube = length * width * height 1 cubic millimeter = <0.01,0.01,0.01>; //smallest prim1 cubic millimeter = 0.001 ml My question is this, is the code wrong or is it a scaling issue with second life? Try it, drop this code in a box and resize it. Try doing 236 ml (1 cup). Look how huge it is! Check out the image at the very bottom. A single cup can easily fit in the palm of your hand, but going by the scaling in second life it looks more like several gallons. I'm trying to come up with a standardized ratio of millimeters cubed to milliliters in second life. Any suggestions? Is it my code? vector SmallestSize = <0.01, 0.01, 0.01>;
float GetWidth()
{
vector inScale =
llGetScale();
float inWidth =
inScale.x;
return inWidth;
}
float GetLength()
{
vector inScale =
llGetScale();
float inLength =
inScale.y;
return inLength;
}
float GetHeight()
{
vector inScale =
llGetScale();
float inHeight =
inScale.z;
return inHeight;
}
CalculateVolume()
{
// get the size
float inWidth = GetWidth();
float inLength = GetLength();
float inHeight = GetHeight();
// multiple by 1000
// avoid precision loss
inWidth *= 1000.0;
inLength *= 1000.0;
inHeight *= 1000.0;
// calculate volume for a cube
float a = inWidth * inLength;
float b = a * inHeight;
// divide by 1000
// to get the actual value
float inVolume = b / 1000.0;
llSay(0, "Volume " + (string)inVolume + " mm³");
inVolume /= 1000.0;
llSay(0, "Volume " + (string)inVolume + " ml");
}
default
{
state_entry()
{
llSetScale(SmallestSize);
CalculateVolume();
}
changed(integer change)
{
if(change & CHANGED_SCALE)
{
CalculateVolume();
}
}
}