Game Development Reference
In-Depth Information
for (int i = 0; i < m_Weapon.GetMaxAmmunition(); i++)
{
Ammunition Ammo = new Ammunition(iContext, null, CubeMesh, null, Material1, Shader,
AmmunitionRange,AmmunitionSpeed);
// Set Intial Position and Orientation
Vector3 Axis = new Vector3(1,0,1);
Vector3 Scale = new Vector3(0.3f,0.3f,0.3f);
Ammo.m_Orientation.SetRotationAxis(Axis);
Ammo.m_Orientation.SetScale(Scale);
Ammo.GetObjectPhysics().SetGravity(false);
Ammo.GetObjectPhysics().SetGravityLevel(0.003f);
Vector3 GridColor = new Vector3(1,0f,0);
Ammo.SetGridSpotLightColor(GridColor);
Ammo.GetObjectPhysics().SetMassEffectiveRadius(10);
Ammo.GetObjectPhysics().SetMass(100);
Ammo.GetObjectStats().SetDamageValue(25);
m_Weapon.LoadAmmunition(Ammo, i);
}
}
The MapWindowCoordsToWorldCoords() function uses the gluUnProject() function to translate screen
coordinates generated by user touches to world coordinates, which are returned in a float array.
Using the MapWindowCoordsToWorldCoords() function (see Listing 7-59), the following are
accomplished:
A new float array, ObjectCoords , is created to return in homogeneous
coordinates the 3D world coordinates that correspond to the screen
coordinates.
1.
2.
The y screen position is translated from screen coordinates to the y
coordinate system that OpenGL uses, by subtracting the y location in
screen coordinates from the Android's screen height. For example, a point
that was input as (0,0) is now sent to the gluUnProject() function as
(0, screenheight) . A point that was input as (0, screenheight) would be
transformed into (0,0) .
The GLU.gluUnProject() function is then called to convert the screen touch
coordinates into 3D world coordinates.
3.
The ObjectCoords float array that holds the 3D world coordinates is returned.
4.
Search WWH ::




Custom Search