public void StartDecalUpdateJobs() { var decalSetsEnum = m_DecalSets.GetEnumerator(); while (decalSetsEnum.MoveNext()) { DecalSet decalSet = decalSetsEnum.Current.Value; if (decalSet.Count == 0) { continue; } decalSet.updateJobHandle.Complete(); decalSet.StartUpdateJob(); } }
public void RemoveDecal(DecalProjectorComponent decal) { if (decal.CullIndex == DecalProjectorComponent.kInvalidIndex) // check if we have this decal { return; } DecalSet decalSet = null; int key = decal.m_Material.GetInstanceID(); if (m_DecalSets.TryGetValue(key, out decalSet)) { decalSet.RemoveDecal(decal); if (decalSet.Count == 0) { m_DecalSets.Remove(key); } } }
public void RemoveDecal(DecalHandle handle) { if (!DecalHandle.IsValid(handle)) { return; } DecalSet decalSet = null; int key = handle.m_MaterialID; if (m_DecalSets.TryGetValue(key, out decalSet)) { decalSet.RemoveDecal(handle); if (decalSet.Count == 0) { m_DecalSets.Remove(key); } } }
void Shoot() { RaycastHit hitInfo; var ray = m_Camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitInfo)) { // Debug.Log(hitInfo.transform.name); SkinnedMeshRenderer ski = hitInfo.transform.GetComponent <SkinnedMeshRenderer>(); if (ski == null) { return; } // for (int i = 0; i < ski.Length; i++) // { DecalSet decalset = ski.GetComponent <DecalSet>(); decalset.AddDecal(transform, hitInfo.point, decalMaterial, m_Size, Random.Range(0, 360), m_NormalFactor, m_Offset); // } } }
public static void PaintDecal(Application app, Scene scene, Engn_Camera cam) { Vector3 hitPos; Drawable hitDrawable; if (Rbfx_Utility.Raycast(scene, cam, 250.0f, out hitPos, out hitDrawable)) { var targetNode = hitDrawable.Node; var decal = targetNode.GetComponent <DecalSet>(); if (decal == null) { var cache = app.Context.Cache; decal = targetNode.CreateComponent <DecalSet>(); var decalse = new DecalSet(app.Context); decal.Material = Material_Ext.noLitFromColor(new Color(1, 0, 0, .5f), false); //cache.GetMaterial("Materials/UrhoDecal.xml"); } // Add a square decal to the decal set using the geometry of the drawable that was hit, orient it to face the camera, // use full texture UV's (0,0) to (1,1). Note that if we create several decals to a large object (such as the ground // plane) over a large area using just one DecalSet component, the decals will all be culled as one unit. If that is // undesirable, it may be necessary to create more than one DecalSet based on the distance decal.AddDecal( hitDrawable, //drawable triangle hitPos, //location cam.CameraNode.Rotation, //Rotation 0.5f, //size 1.0f, //aspect ratio 1.0f, //depth Vector2.ZERO, //uv top left coor Vector2.ONE, //uv bottomright coor 0.0f, //timetolive 0.1f, //normalCutoff uint.MaxValue); } }
public void AddDecal(DecalProjectorComponent decal) { if (decal.CullIndex != DecalProjectorComponent.kInvalidIndex) //do not add the same decal more than once { return; } if (!decal.IsValid()) { return; } DecalSet decalSet = null; int key = decal.m_Material.GetInstanceID(); if (!m_DecalSets.TryGetValue(key, out decalSet)) { decalSet = new DecalSet(decal.m_Material); m_DecalSets.Add(key, decalSet); } decalSet.AddDecal(decal); }