Skip to content

Commit

Permalink
feat(Highlighters): add outline copy highlighter
Browse files Browse the repository at this point in the history
A new highlighter has been added that puts an outline around the
object that it is applied to. It achieves this by making a copy of
the object (or a provided mesh) and puts an outline shader on the
object, which is toggled on when the highlight occurs.

The highlighters have also been updated to have an `active`
parameter on them which is used by scripted components to know which
highlighter is the one to use when found on the component (as it may
be required to put multiple highlighter components onto an object
to toggle on and off).

The Controller Actions script has also been updated to allow the
sub elements of the controller to have a custom highlighter provided
for each so it can override the main highlighter if needed.
  • Loading branch information
thestonefox committed Sep 18, 2016
1 parent f27da1c commit 8dee203
Show file tree
Hide file tree
Showing 17 changed files with 1,065 additions and 201 deletions.
361 changes: 232 additions & 129 deletions Assets/VRTK/Examples/005_Controller_BasicObjectGrabbing.unity

Large diffs are not rendered by default.

108 changes: 98 additions & 10 deletions Assets/VRTK/Examples/035_Controller_OpacityAndHighlighting.unity
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dd076df6ddf5d40479de53c25f48c093, type: 3}
m_Name:
m_EditorClassIdentifier:
highlightBodyOnlyOnCollision: 0
--- !u!114 &217542883
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -245,6 +246,7 @@ MonoBehaviour:
uiClickButton: 3
menuToggleButton: 7
axisFidelity: 1
triggerClickThreshold: 1
triggerPressed: 0
triggerTouched: 0
triggerHairlinePressed: 0
Expand All @@ -271,6 +273,22 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d45c8d32f1d960d4498790bb3961fc52, type: 3}
m_Name:
m_EditorClassIdentifier:
modelElementPaths:
bodyModelPath: Model/body
triggerModelPath: Model/trigger
leftGripModelPath: Model/lgrip
rightGripModelPath: Model/rgrip
touchpadModelPath: Model/trackpad
appMenuModelPath: Model/button
systemMenuModelPath: Model/sys_button
elementHighlighterOverrides:
body: {fileID: 0}
trigger: {fileID: 0}
gripLeft: {fileID: 0}
gripRight: {fileID: 0}
touchpad: {fileID: 0}
appMenu: {fileID: 0}
systemMenu: {fileID: 0}
--- !u!114 &217542885
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -326,12 +344,14 @@ MonoBehaviour:
isDroppable: 1
isSwappable: 1
holdButtonToGrab: 1
grabOverrideButton: 8
rumbleOnGrab: {x: 0, y: 0}
allowedGrabControllers: 0
precisionSnap: 0
rightSnapHandle: {fileID: 0}
leftSnapHandle: {fileID: 0}
hideControllerOnGrab: 0
stayGrabbedOnTeleport: 1
grabAttachMechanic: 0
detachThreshold: 1500
springJointStrength: 500
Expand All @@ -341,10 +361,12 @@ MonoBehaviour:
isUsable: 0
useOnlyIfGrabbed: 0
holdButtonToUse: 1
useOverrideButton: 8
pointerActivatesUseAction: 0
rumbleOnUse: {x: 0, y: 0}
allowedUseControllers: 0
hideControllerOnUse: 0
usingState: 0
--- !u!54 &604099642
Rigidbody:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -783,7 +805,7 @@ Prefab:
- target: {fileID: 3380982, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
propertyPath: m_Mesh
value:
objectReference: {fileID: 1713047491}
objectReference: {fileID: 2033724836}
- target: {fileID: 11489174, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
propertyPath: size
value: 0
Expand Down Expand Up @@ -856,14 +878,51 @@ Prefab:
propertyPath: drawInGame
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2348914, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 1417681013}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
m_IsPrefabParent: 0
--- !u!21 &1417681013
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Sprites/Default
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: PixelSnap
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!4 &1494182195 stripped
Transform:
m_PrefabParentObject: {fileID: 458974, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
m_PrefabInternal: {fileID: 1188569437}
--- !u!43 &1713047491
--- !u!4 &1950519925 stripped
Transform:
m_PrefabParentObject: {fileID: 402434, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
m_PrefabInternal: {fileID: 1188569437}
--- !u!43 &2033724836
Mesh:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
Expand All @@ -879,7 +938,7 @@ Mesh:
vertexCount: 8
localAABB:
m_Center: {x: 0, y: 0.01, z: 0}
m_Extent: {x: 1.2499999, y: 0, z: 0.9000001}
m_Extent: {x: 1.2, y: 0, z: 1.0500002}
m_Shapes:
vertices: []
shapes: []
Expand All @@ -892,7 +951,7 @@ Mesh:
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexBuffer: 000001000400010005000400010002000500020006000500020003000600030007000600030000000700000004000700
m_IndexBuffer: 000004000100010004000500010005000200020005000600020006000300030006000700030007000000000007000400
m_Skin: []
m_VertexData:
m_CurrentChannels: 13
Expand Down Expand Up @@ -931,7 +990,7 @@ Mesh:
format: 0
dimension: 0
m_DataSize: 288
_typelessdata: cccc8c3f0ad7233c020040bf000000000000803f0000803f0000803f0000000000000000cccc8cbf0ad7233c020040bf000000000000803f0000803f0000803f0000803f00000000cccc8cbf0ad7233c0200403f000000000000803f0000803f0000803f0000000000000000cccc8c3f0ad7233c0200403f000000000000803f0000803f0000803f0000803f00000000ffff9f3f0ad7233c686666bf000000000000803f0000803f00000000000000000000803fffff9fbf0ad7233c686666bf000000000000803f0000803f000000000000803f0000803fffff9fbf0ad7233c6866663f000000000000803f0000803f00000000000000000000803fffff9f3f0ad7233c6866663f000000000000803f0000803f000000000000803f0000803f
_typelessdata: 6766863f0ad7233c696666bf000000000000803f0000803f0000803f0000000000000000676686bf0ad7233c696666bf000000000000803f0000803f0000803f0000803f00000000676686bf0ad7233c6966663f000000000000803f0000803f0000803f00000000000000006766863f0ad7233c6966663f000000000000803f0000803f0000803f0000803f000000009a99993f0ad7233c686686bf000000000000803f0000803f00000000000000000000803f9a9999bf0ad7233c686686bf000000000000803f0000803f000000000000803f0000803f9a9999bf0ad7233c6866863f000000000000803f0000803f00000000000000000000803f9a99993f0ad7233c6866863f000000000000803f0000803f000000000000803f0000803f
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
Expand Down Expand Up @@ -986,15 +1045,11 @@ Mesh:
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: 0, y: 0.01, z: 0}
m_Extent: {x: 1.2499999, y: 0, z: 0.9000001}
m_Extent: {x: 1.2, y: 0, z: 1.0500002}
m_MeshUsageFlags: 0
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshOptimized: 0
--- !u!4 &1950519925 stripped
Transform:
m_PrefabParentObject: {fileID: 402434, guid: 4d293c8e162f3874b982baadd71153d2, type: 2}
m_PrefabInternal: {fileID: 1188569437}
--- !u!1 &2123877843
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1080,6 +1135,7 @@ MonoBehaviour:
uiClickButton: 3
menuToggleButton: 7
axisFidelity: 1
triggerClickThreshold: 1
triggerPressed: 0
triggerTouched: 0
triggerHairlinePressed: 0
Expand All @@ -1106,6 +1162,22 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d45c8d32f1d960d4498790bb3961fc52, type: 3}
m_Name:
m_EditorClassIdentifier:
modelElementPaths:
bodyModelPath: Model/body
triggerModelPath: Model/trigger
leftGripModelPath: Model/lgrip
rightGripModelPath: Model/rgrip
touchpadModelPath: Model/trackpad
appMenuModelPath: Model/button
systemMenuModelPath: Model/sys_button
elementHighlighterOverrides:
body: {fileID: 2146663384}
trigger: {fileID: 0}
gripLeft: {fileID: 0}
gripRight: {fileID: 0}
touchpad: {fileID: 0}
appMenu: {fileID: 0}
systemMenu: {fileID: 0}
--- !u!114 &2146663382
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -1117,6 +1189,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dd076df6ddf5d40479de53c25f48c093, type: 3}
m_Name:
m_EditorClassIdentifier:
highlightBodyOnlyOnCollision: 1
--- !u!114 &2146663383
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -1132,3 +1205,18 @@ MonoBehaviour:
hideControllerDelay: 0
globalTouchHighlightColor: {r: 0, g: 0, b: 0, a: 0}
customRigidbodyObject: {fileID: 0}
--- !u!114 &2146663384
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2146663379}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c08517e04830d6d44a13c5ea5f574181, type: 3}
m_Name:
m_EditorClassIdentifier:
active: 0
thickness: 0.2
customOutlineModel: {fileID: 0}
customOutlineModelPath:
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public class VRTK_ControllerAppearance_Example : MonoBehaviour
{
public bool highlightBodyOnlyOnCollision = false;

private VRTK_ControllerTooltips tooltips;
private VRTK_ControllerActions actions;
private VRTK_ControllerEvents events;
Expand Down Expand Up @@ -106,12 +108,26 @@ private void DoTouchpadReleased(object sender, ControllerInteractionEventArgs e)

private void OnTriggerEnter(Collider collider)
{
actions.ToggleHighlightController(true, Color.yellow, 0.4f);
if (highlightBodyOnlyOnCollision)
{
actions.ToggleHighlighBody(true, Color.yellow, 0.4f);
}
else
{
actions.ToggleHighlightController(true, Color.yellow, 0.4f);
}
}

private void OnTriggerExit(Collider collider)
{
actions.ToggleHighlightController(false);
if (highlightBodyOnlyOnCollision)
{
actions.ToggleHighlighBody(false);
}
else
{
actions.ToggleHighlightController(false);
}
}
}
}
Loading

0 comments on commit 8dee203

Please sign in to comment.