* From Dahlia
* Committing : 0001449: Patch implements X and Y Top Shear parameters for torus prim physical mesh generation (PATCH attached) * The included patch implements the X and Y Top Shear parameter adjustments to the mesh generator for the torus prim physical mesh. These are approximations as I was unable to determine their exact function but they appear to generate meshes which quite closely duplicate their counterparts in the viewer. * Thanks Dahlia!!!!0.6.0-stable
parent
4ec4e16c80
commit
99e7a2a380
|
@ -255,7 +255,6 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
Mesh newLayer;
|
Mesh newLayer;
|
||||||
Mesh lastLayer = null;
|
Mesh lastLayer = null;
|
||||||
|
|
||||||
//int start = 0;
|
|
||||||
int step;
|
int step;
|
||||||
int steps = 24;
|
int steps = 24;
|
||||||
|
|
||||||
|
@ -274,8 +273,17 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
float totalSkew = skew * 2.0f * pathLength;
|
float totalSkew = skew * 2.0f * pathLength;
|
||||||
float skewStart = (-skew) + pathCutBegin * 2.0f * skew;
|
float skewStart = (-skew) + pathCutBegin * 2.0f * skew;
|
||||||
|
|
||||||
float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions);
|
// It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end
|
||||||
float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions);
|
// angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used
|
||||||
|
// to calculate the sine for generating the path radius appears to approximate it's effects there
|
||||||
|
// too, but there are some subtle differences in the radius which are noticeable as the prim size
|
||||||
|
// increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on
|
||||||
|
// the meshes generated with this technique appear nearly identical in shape to the same prims when
|
||||||
|
// displayed by the viewer.
|
||||||
|
|
||||||
|
|
||||||
|
float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions) - pushY * 0.9f;
|
||||||
|
float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions) - pushY * 0.9f;
|
||||||
float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution
|
float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution
|
||||||
|
|
||||||
step = (int)(startAngle / stepSize);
|
step = (int)(startAngle / stepSize);
|
||||||
|
@ -284,6 +292,7 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
float xProfileScale = 1.0f;
|
float xProfileScale = 1.0f;
|
||||||
float yProfileScale = 1.0f;
|
float yProfileScale = 1.0f;
|
||||||
|
|
||||||
|
|
||||||
#if SPAM
|
#if SPAM
|
||||||
System.Console.WriteLine("Extruder: twistTop: " + twistTop.ToString() + " twistbot: " + twistBot.ToString() + " twisttotal: " + twistTotal.ToString());
|
System.Console.WriteLine("Extruder: twistTop: " + twistTop.ToString() + " twistbot: " + twistBot.ToString() + " twisttotal: " + twistTotal.ToString());
|
||||||
System.Console.WriteLine("Extruder: startAngle: " + startAngle.ToString() + " endAngle: " + endAngle.ToString() + " step: " + step.ToString());
|
System.Console.WriteLine("Extruder: startAngle: " + startAngle.ToString() + " endAngle: " + endAngle.ToString() + " step: " + step.ToString());
|
||||||
|
@ -346,35 +355,41 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
float twist = twistBot + (twistTotal * (float)percentOfPath);
|
float twist = twistBot + (twistTotal * (float)percentOfPath);
|
||||||
|
|
||||||
float zOffset = (float)(System.Math.Sin(angle) * (0.5f - yPathScale)) * radiusScale;
|
float xOffset;
|
||||||
float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale;
|
float yOffset;
|
||||||
float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath);
|
float zOffset;
|
||||||
|
|
||||||
// next apply twist rotation to the profile
|
|
||||||
if (twistTotal != 0.0f || twistBot != 0.0f)
|
xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath);
|
||||||
{
|
xOffset += (float) System.Math.Sin(angle) * pushX * 0.45f;
|
||||||
Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist);
|
yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale;
|
||||||
foreach (Vertex v in newLayer.vertices)
|
zOffset = (float)(System.Math.Sin(angle + pushY * 0.9f) * (0.5f - yPathScale)) * radiusScale;
|
||||||
|
|
||||||
|
|
||||||
|
// next apply twist rotation to the profile layer
|
||||||
|
if (twistTotal != 0.0f || twistBot != 0.0f)
|
||||||
{
|
{
|
||||||
if (v != null)
|
Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist);
|
||||||
|
foreach (Vertex v in newLayer.vertices)
|
||||||
{
|
{
|
||||||
vTemp = v * profileRot;
|
if (v != null)
|
||||||
v.X = vTemp.X;
|
{
|
||||||
v.Y = vTemp.Y;
|
vTemp = v * profileRot;
|
||||||
v.Z = vTemp.Z;
|
v.X = vTemp.X;
|
||||||
|
v.Y = vTemp.Y;
|
||||||
|
v.Z = vTemp.Z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// now orient the rotation of the profile relative to it's position on the path
|
// now orient the rotation of the profile layer relative to it's position on the path
|
||||||
Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle);
|
// adding pushY to the angle used to generate the quat appears to approximate the viewer
|
||||||
|
Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f);
|
||||||
foreach (Vertex v in newLayer.vertices)
|
foreach (Vertex v in newLayer.vertices)
|
||||||
{
|
{
|
||||||
if (v != null)
|
if (v != null)
|
||||||
{
|
{
|
||||||
vTemp = v * layerRot;
|
vTemp = v * layerRot;
|
||||||
//v.X = xProfileScale * vTemp.X + xOffset;
|
|
||||||
//v.Y = yProfileScale * vTemp.Y + yOffset;
|
|
||||||
v.X = vTemp.X + xOffset;
|
v.X = vTemp.X + xOffset;
|
||||||
v.Y = vTemp.Y + yOffset;
|
v.Y = vTemp.Y + yOffset;
|
||||||
v.Z = vTemp.Z + zOffset;
|
v.Z = vTemp.Z + zOffset;
|
||||||
|
|
Loading…
Reference in New Issue