mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
* Moves the Meshmerizer to a separate plugin
* Experimental. Linux Prebuild needs testing. * One more update after this to remove the ODEMeshing directory....
This commit is contained in:
83
OpenSim/Region/Physics/Meshing/Extruder.cs
Normal file
83
OpenSim/Region/Physics/Meshing/Extruder.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.Physics.Meshing
|
||||
{
|
||||
class Extruder
|
||||
{
|
||||
public float startParameter;
|
||||
public float stopParameter;
|
||||
public Manager.PhysicsVector size;
|
||||
|
||||
public Mesh Extrude(Mesh m)
|
||||
{
|
||||
// Currently only works for iSteps=1;
|
||||
Mesh result = new Mesh();
|
||||
|
||||
Mesh workingPlus = m.Clone();
|
||||
Mesh workingMinus = m.Clone();
|
||||
|
||||
foreach (Vertex v in workingPlus.vertices)
|
||||
{
|
||||
if (v == null)
|
||||
continue;
|
||||
|
||||
v.Z = +.5f;
|
||||
v.X *= size.X;
|
||||
v.Y *= size.Y;
|
||||
v.Z *= size.Z;
|
||||
}
|
||||
|
||||
foreach (Vertex v in workingMinus.vertices)
|
||||
{
|
||||
if (v == null)
|
||||
continue;
|
||||
|
||||
v.Z = -.5f;
|
||||
v.X *= size.X;
|
||||
v.Y *= size.Y;
|
||||
v.Z *= size.Z;
|
||||
}
|
||||
|
||||
foreach (Triangle t in workingMinus.triangles)
|
||||
{
|
||||
t.invertNormal();
|
||||
}
|
||||
|
||||
result.Append(workingMinus);
|
||||
result.Append(workingPlus);
|
||||
|
||||
int iLastNull = 0;
|
||||
for (int i = 0; i < workingPlus.vertices.Count; i++)
|
||||
{
|
||||
int iNext = (i + 1);
|
||||
|
||||
if (workingPlus.vertices[i] == null) // Can't make a simplex here
|
||||
{
|
||||
iLastNull = i+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == workingPlus.vertices.Count-1) // End of list
|
||||
{
|
||||
iNext = iLastNull;
|
||||
}
|
||||
|
||||
if (workingPlus.vertices[iNext] == null) // Null means wrap to begin of last segment
|
||||
{
|
||||
iNext = iLastNull;
|
||||
}
|
||||
|
||||
Triangle tSide;
|
||||
tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]);
|
||||
result.Add(tSide);
|
||||
|
||||
tSide = new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]);
|
||||
result.Add(tSide);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user