本文整理汇总了C#中ISceneChildEntity.GetWorldPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ISceneChildEntity.GetWorldPosition方法的具体用法?C# ISceneChildEntity.GetWorldPosition怎么用?C# ISceneChildEntity.GetWorldPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneChildEntity
的用法示例。
在下文中一共展示了ISceneChildEntity.GetWorldPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePrim
void CreatePrim (WarpRenderer renderer, ISceneChildEntity prim)
{
try {
if ((PCode)prim.Shape.PCode != PCode.Prim)
return;
if (prim.Scale.LengthSquared () < MIN_PRIM_SIZE * MIN_PRIM_SIZE)
return;
Primitive omvPrim = prim.Shape.ToOmvPrimitive (prim.OffsetPosition, prim.GetRotationOffset ());
FacetedMesh renderMesh = null;
// Are we dealing with a sculptie or mesh?
if (omvPrim.Sculpt != null && omvPrim.Sculpt.SculptTexture != UUID.Zero) {
// Try fetching the asset
byte [] sculptAsset = m_scene.AssetService.GetData (omvPrim.Sculpt.SculptTexture.ToString ());
if (sculptAsset != null) {
// Is it a mesh?
if (omvPrim.Sculpt.Type == SculptType.Mesh) {
AssetMesh meshAsset = new AssetMesh (omvPrim.Sculpt.SculptTexture, sculptAsset);
FacetedMesh.TryDecodeFromAsset (omvPrim, meshAsset, DetailLevel.Highest, out renderMesh);
meshAsset = null;
} else // It's sculptie
{
Image sculpt = m_imgDecoder.DecodeToImage (sculptAsset);
if (sculpt != null) {
renderMesh = m_primMesher.GenerateFacetedSculptMesh (omvPrim, (Bitmap)sculpt,
DetailLevel.Medium);
sculpt.Dispose ();
}
}
sculptAsset = null;
} else {
// missing sculpt data... replace with something
renderMesh = m_primMesher.GenerateFacetedMesh (omvPrim, DetailLevel.Medium);
}
} else // Prim
{
renderMesh = m_primMesher.GenerateFacetedMesh (omvPrim, DetailLevel.Medium);
}
if (renderMesh == null)
return;
warp_Vector primPos = ConvertVector (prim.GetWorldPosition ());
warp_Quaternion primRot = ConvertQuaternion (prim.GetRotationOffset ());
warp_Matrix m = warp_Matrix.quaternionMatrix (primRot);
if (prim.ParentID != 0) {
ISceneEntity group = m_scene.GetGroupByPrim (prim.LocalId);
if (group != null)
m.transform (warp_Matrix.quaternionMatrix (ConvertQuaternion (group.RootChild.GetRotationOffset ())));
}
warp_Vector primScale = ConvertVector (prim.Scale);
string primID = prim.UUID.ToString ();
// Create the prim faces
for (int i = 0; i < renderMesh.Faces.Count; i++) {
Face renderFace = renderMesh.Faces [i];
string meshName = primID + "-Face-" + i;
warp_Object faceObj = new warp_Object (renderFace.Vertices.Count, renderFace.Indices.Count / 3);
foreach (Vertex v in renderFace.Vertices) {
warp_Vector pos = ConvertVector (v.Position);
warp_Vector norm = ConvertVector (v.Normal);
if (prim.Shape.SculptTexture == UUID.Zero)
norm = norm.reverse ();
warp_Vertex vert = new warp_Vertex (pos, norm, v.TexCoord.X, v.TexCoord.Y);
faceObj.addVertex (vert);
}
for (int j = 0; j < renderFace.Indices.Count;) {
faceObj.addTriangle (
renderFace.Indices [j++],
renderFace.Indices [j++],
renderFace.Indices [j++]);
}
Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace ((uint)i);
string materialName;
Color4 faceColor = GetFaceColor (teFace);
if (m_texturePrims && (prim.Scale.LengthSquared () > m_texturePrimSize)) {
materialName = GetOrCreateMaterial (renderer, faceColor, teFace.TextureID);
} else {
materialName = GetOrCreateMaterial (renderer, faceColor);
}
faceObj.transform (m);
faceObj.setPos (primPos);
faceObj.scaleSelf (primScale.x, primScale.y, primScale.z);
renderer.Scene.addObject (meshName, faceObj);
//.........这里部分代码省略.........
示例2: LookAt
private void LookAt(LSL_Vector target, double strength, double damping, ISceneChildEntity obj)
{
// Determine where we are looking from
LSL_Vector from = new LSL_Vector(obj.GetWorldPosition());
// The following code bit was written by Dahlia
// from the Opensimulator Core Team. Thank you for fixing this issue
// normalized direction to target
LSL_Vector dir = llVecNorm(target - from);
// use vertical to help compute left axis
LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0);
// find normalized left axis parallel to horizon
LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir));
// make up orthogonal to left and direction
up = LSL_Vector.Cross(dir, left);
// compute rotation based on orthogonal axes
LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up);
// End codebit
//If the strength is 0, or we are non-physical, set the rotation
if (strength == 0 || obj.PhysActor == null || !obj.PhysActor.IsPhysical)
SetLinkRot(obj, rot);
else
obj.startLookAt(Rot2Quaternion(rot), (float)strength, (float)damping);
}
示例3: LookAt
private void LookAt(LSL_Vector target, double strength, double damping, ISceneChildEntity obj)
{
// Determine where we are looking from
LSL_Vector from = new LSL_Vector(obj.GetWorldPosition());
// Work out the normalised vector from the source to the target
LSL_Vector delta = llVecNorm(target - from);
LSL_Vector angle = new LSL_Vector(0, 0, 0)
{
x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO,
y = llAtan2(delta.x, llSqrt((delta.y*delta.y) + (delta.z*delta.z)))
};
// Calculate the yaw
// subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system
// Calculate pitch
// we need to convert from a vector describing
// the angles of rotation in radians into rotation value
LSL_Types.Quaternion rot = llEuler2Rot(angle);
//If the strength is 0, or we are non-physical, set the rotation
if (strength == 0 || obj.PhysActor == null || !obj.PhysActor.IsPhysical)
SetLinkRot(obj, rot);
else
obj.startLookAt(Rot2Quaternion(rot), (float) strength, (float) damping);
}
示例4: CreatePrim
private void CreatePrim (WarpRenderer renderer, ISceneChildEntity prim)
{
try
{
const float MIN_SIZE = 2f;
if ((PCode)prim.Shape.PCode != PCode.Prim)
return;
if (prim.Scale.LengthSquared () < MIN_SIZE * MIN_SIZE)
return;
Primitive omvPrim = prim.Shape.ToOmvPrimitive (prim.OffsetPosition, prim.RotationOffset);
FacetedMesh renderMesh = null;
// Are we dealing with a sculptie or mesh?
if (omvPrim.Sculpt != null && omvPrim.Sculpt.SculptTexture != UUID.Zero)
{
// Try fetchinng the asset
AssetBase sculptAsset = m_scene.AssetService.Get (omvPrim.Sculpt.SculptTexture.ToString ());
if (sculptAsset != null)
{
// Is it a mesh?
if (omvPrim.Sculpt.Type == SculptType.Mesh)
{
OpenMetaverse.Assets.AssetMesh meshAsset = new OpenMetaverse.Assets.AssetMesh (omvPrim.Sculpt.SculptTexture, sculptAsset.Data);
FacetedMesh.TryDecodeFromAsset (omvPrim, meshAsset, DetailLevel.Highest, out renderMesh);
}
else // It's sculptie
{
IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder> ();
Image sculpt = imgDecoder.DecodeToImage (sculptAsset.Data);
if (sculpt != null)
{
renderMesh = m_primMesher.GenerateFacetedSculptMesh (omvPrim, (Bitmap)sculpt, DetailLevel.Medium);
sculpt.Dispose ();
}
}
}
}
else // Prim
{
renderMesh = m_primMesher.GenerateFacetedMesh (omvPrim, DetailLevel.Medium);
}
if (renderMesh == null)
return;
warp_Vector primPos = ConvertVector (prim.GetWorldPosition ());
warp_Quaternion primRot = ConvertQuaternion (prim.RotationOffset);
warp_Matrix m = warp_Matrix.quaternionMatrix (primRot);
if (prim.ParentID != 0)
{
ISceneEntity group = m_scene.GetGroupByPrim (prim.LocalId);
if (group != null)
m.transform (warp_Matrix.quaternionMatrix (ConvertQuaternion (group.RootChild.RotationOffset)));
}
warp_Vector primScale = ConvertVector (prim.Scale);
string primID = prim.UUID.ToString ();
// Create the prim faces
for (int i = 0; i < renderMesh.Faces.Count; i++)
{
Face face = renderMesh.Faces[i];
string meshName = primID + "-Face-" + i.ToString ();
warp_Object faceObj = new warp_Object (face.Vertices.Count, face.Indices.Count / 3);
for (int j = 0; j < face.Vertices.Count; j++)
{
Vertex v = face.Vertices[j];
warp_Vector pos = ConvertVector (v.Position);
warp_Vector norm = ConvertVector (v.Normal);
if (prim.Shape.SculptTexture == UUID.Zero)
norm = norm.reverse ();
warp_Vertex vert = new warp_Vertex (pos, norm, v.TexCoord.X, v.TexCoord.Y);
faceObj.addVertex (vert);
}
for (int j = 0; j < face.Indices.Count; j += 3)
{
faceObj.addTriangle (
face.Indices[j + 0],
face.Indices[j + 1],
face.Indices[j + 2]);
}
Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace ((uint)i);
string materialName;
Color4 faceColor = GetFaceColor (teFace);
if (m_texturePrims && prim.Scale.LengthSquared () > 48 * 48)
{
materialName = GetOrCreateMaterial (renderer, faceColor, teFace.TextureID);
//.........这里部分代码省略.........