浏览代码

Merge pull request #37 from johnsietsma/FeatheringTransformFixes

Don't transform mesh verts, they're already in plane space.
/1.5-preview
GitHub 6 年前
当前提交
1e10980e
共有 2 个文件被更改,包括 19 次插入23 次删除
  1. 25
      Assets/Prefabs/AR Point Cloud Debug Visualizer.prefab
  2. 17
      Assets/Scripts/ARFeatheredPlaneMeshVisualizer.cs

25
Assets/Prefabs/AR Point Cloud Debug Visualizer.prefab


m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_SourcePrefab: {fileID: 0}
m_IsPrefabParent: 1
m_IsPrefabAsset: 1
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
serializedVersion: 5
serializedVersion: 6
m_Component:
- component: {fileID: 4459255792954120}
- component: {fileID: 198296754606205776}

--- !u!4 &4459255792954120
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1854016325464908}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}

--- !u!114 &114143057649092886
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1854016325464908}
m_Enabled: 1

--- !u!114 &114674181514608572
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1854016325464908}
m_Enabled: 1

--- !u!198 &198296754606205776
ParticleSystem:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1854016325464908}
serializedVersion: 5

m_Mesh: {fileID: 0}
m_MeshRenderer: {fileID: 0}
m_SkinnedMeshRenderer: {fileID: 0}
m_Sprite: {fileID: 0}
m_SpriteRenderer: {fileID: 0}
m_UseMeshMaterialIndex: 0
m_UseMeshColors: 1
alignToDirection: 0

m_PostInfinity: 2
m_RotationOrder: 4
EmissionModule:
enabled: 0
enabled: 1
serializedVersion: 4
rateOverTime:
serializedVersion: 2

vectorLabel1_3: W
--- !u!199 &199567844588220584
ParticleSystemRenderer:
serializedVersion: 5
serializedVersion: 6
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1854016325464908}
m_Enabled: 1

m_Pivot: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 0
m_VertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}

17
Assets/Scripts/ARFeatheredPlaneMeshVisualizer.cs


float m_FeatheringWidth = 0.2f;
ARPlaneMeshVisualizer m_PlaneMeshVisualizer;
ARPlane m_ARPlane;
m_ARPlane = GetComponent<ARPlane>();
m_FeatheredPlaneMaterial = GetComponent<MeshRenderer>().material;
}

/// <remarks>
/// The <c>ARPlaneMeshVisualizer</c> has a <c>meshUpdated</c> event that can be used to modify the generated
/// mesh. In this case we'll add UV2s to mark the boundary vertices.
/// This technique avoids having to generate extra vertices for the boundary. It works best when the shape is
/// is fairly uniform and the center vert is close to the barycentric center.
/// This technique avoids having to generate extra vertices for the boundary. It works best when the plane is
/// is fairly uniform.
/// </remarks>
/// <param name="mesh">The <c>Mesh</c> generated by <c>ARPlaneMeshVisualizer</c></param>
void GenerateBoundaryUVs(Mesh mesh)

s_FeatheringUVs.Clear();
if (s_FeatheringUVs.Capacity < vertexCount) { s_FeatheringUVs.Capacity = vertexCount; }
// Figure out where the plane center is in plane-local space (it's in session-local space)
BoundedPlane boundedPlane = m_ARPlane.boundedPlane;
Pose planePose = boundedPlane.Pose;
Vector3 centerInPlaneSpace = planePose.InverseTransformPosition(boundedPlane.Center);
Vector3 centerInPlaneSpace = s_Vertices[s_Vertices.Count - 1];
float vertexDist = Vector3.Distance(planePose.InverseTransformPosition(s_Vertices[i]), centerInPlaneSpace);
float vertexDist = Vector3.Distance(s_Vertices[i], centerInPlaneSpace);
float uvMapping = vertexDist / (vertexDist - featheringWidth);
float uvMapping = vertexDist / Mathf.Max(vertexDist - featheringWidth, 0.001f);
uv.x = uvMapping;
// All the UV mappings will be different. In the shader we need to know the UV value we need to fade out by.

正在加载...
取消
保存