UnityEngine.Matrix4x4.TRS(UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Vector3)

Here are the examples of the csharp api UnityEngine.Matrix4x4.TRS(UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

99 Examples 7

19 View Source File : MeshCombineUtility.cs
License : Apache License 2.0
Project Creator : mogoson

public static Mesh CombineMeshes(IEnumerable<MeshFilter> filters, Vector3 center, bool mergeSubMeshes = true)
        {
            var combines = new List<CombineInstance>();
            foreach (var filter in filters)
            {
                var pos = filter.transform.position - center;
                var combine = new CombineInstance
                {
                    mesh = filter.sharedMesh,
                    transform = Matrix4x4.TRS(pos, filter.transform.rotation, filter.transform.lossyScale)
                };
                combines.Add(combine);
            }
            var rebornMesh = new Mesh();
            rebornMesh.CombineMeshes(combines.ToArray(), mergeSubMeshes);

#if !UNITY_5_5_OR_NEWER
            //Mesh.Optimize was removed in version 5.5.2p4.
            rebornMesh.Optimize();
#endif
            return rebornMesh;
        }

19 View Source File : AppearanceInstance.cs
License : MIT License
Project Creator : slavidodo

protected void InternalDraw(CommandBuffer commandBuffer, Vector2Int screenPosition, bool highlighted,
                                      float highlightOpacity, CachedSprite cachedSprite, Material material = null, MaterialPropertyBlock props = null) {
            if (_shouldRecalculateTRS) {
                var position = new Vector2(screenPosition.x - _type.OffsetX, screenPosition.y - _type.OffsetY);
                if (ClampeToFieldSize)
                    _trsMatrix = Matrix4x4.TRS(position, Quaternion.Euler(180, 0, 0), s_fieldVector);
                else
                    _trsMatrix = Matrix4x4.TRS(position - cachedSprite.size + s_fieldVector, Quaternion.Euler(180, 0, 0), cachedSprite.size);

                _screenPosition = screenPosition;
                _shouldRecalculateTRS = false;
            } else if (_screenPosition != screenPosition) {
                _trsMatrix[0, 3] += (screenPosition.x - _screenPosition.x);
                _trsMatrix[1, 3] += (screenPosition.y - _screenPosition.y);
                _screenPosition = screenPosition;
            }

            if (material == null)
                material = OpenTibiaUnity.GameManager.AppearanceTypeMaterial;

            if (props == null)
                props = cachedSprite.materialProperyBlock;

            props.SetFloat("_HighlightOpacity", highlighted ? highlightOpacity : 0);
            if (commandBuffer != null)
                commandBuffer.DrawMesh(s_mesh, _trsMatrix, material, 0, 0, props);
        }

19 View Source File : NavMeshSurface.cs
License : MIT License
Project Creator : DKaravolos

List<NavMeshBuildSource> CollectSources()
        {
            var sources = new List<NavMeshBuildSource>();
            var markups = new List<NavMeshBuildMarkup>();

            List<NavMeshModifier> modifiers;
            if (m_CollectObjects == CollectObjects.Children)
            {
                modifiers = new List<NavMeshModifier>(GetComponentsInChildren<NavMeshModifier>());
                modifiers.RemoveAll(x => !x.isActiveAndEnabled);
            }
            else
            {
                modifiers = NavMeshModifier.activeModifiers;
            }

            foreach (var m in modifiers)
            {
                if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
                    continue;
                if (!m.AffectsAgentType(m_AgentTypeID))
                    continue;
                var markup = new NavMeshBuildMarkup();
                markup.root = m.transform;
                markup.overrideArea = m.overrideArea;
                markup.area = m.area;
                markup.ignoreFromBuild = m.ignoreFromBuild;
                markups.Add(markup);
            }

            if (m_CollectObjects == CollectObjects.All)
            {
                NavMeshBuilder.CollectSources(null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
            }
            else if (m_CollectObjects == CollectObjects.Children)
            {
                NavMeshBuilder.CollectSources(transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
            }
            else if (m_CollectObjects == CollectObjects.Volume)
            {
                Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
                var worldBounds = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));
                NavMeshBuilder.CollectSources(worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
            }

            if (m_IgnoreNavMeshAgent)
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent<NavMeshAgent>() != null));

            if (m_IgnoreNavMeshObstacle)
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent<NavMeshObstacle>() != null));

            AppendModifierVolumes(ref sources);

            return sources;
        }

19 View Source File : PointGroupTest.cs
License : MIT License
Project Creator : IxxyXR

public override void DoUpdate()
    {
        if (!SlowMerge)
        {
            GetComponent<MeshRenderer>().enabled = false;
            Mesh mesh;
            if (Application.isPlaying)
            {
                mesh = GetComponent<MeshFilter>().mesh;
            }
            else
            {
                mesh = GetComponent<MeshFilter>().sharedMesh;
            }
            
            if (mesh == null) return;
            
            var matrices = new List<Matrix4x4>();
            var transformBefore = Matrix4x4.TRS(Position, Quaternion.Euler(Rotation), Scale);
            var replacedulativeTransform = Matrix4x4.TRS(PositionEach, Quaternion.Euler(RotationEach), ScaleEach);
            var currentreplacedulativeTransform = replacedulativeTransform;

            var baseMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.localScale);
            foreach (var m in sym.matrices)
            {
                matrices.Add(
                    (baseMatrix * (ApplyAfter ? currentreplacedulativeTransform * m : m * currentreplacedulativeTransform)) * transformBefore
                );
                currentreplacedulativeTransform *= replacedulativeTransform;
            }
            DrawInstances(mesh, GetComponent<MeshRenderer>().material, matrices);
        }

        base.DoUpdate();
    }

19 View Source File : GvrAudio.cs
License : MIT License
Project Creator : harshitjuneja

private static void ConvertAudioTransformFromUnity (ref Vector3 position,
                                                      ref Quaternion rotation) {
    pose.SetRightHanded(Matrix4x4.TRS(position, rotation, Vector3.one));
    position = pose.Position;
    rotation = pose.Orientation;
  }

19 View Source File : NavMeshLinkEditor.cs
License : MIT License
Project Creator : DKaravolos

static Matrix4x4 UnscaledLocalToWorldMatrix(Transform t)
        {
            return Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
        }

19 View Source File : ImageEffects.cs
License : MIT License
Project Creator : PacktPublishing

public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
    {
        bool invertY = source.texelSize.y < 0.0f;
        if (invertY)
        {
            center.y = 1.0f - center.y;
            angle = -angle;
        }

        Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);

        material.SetMatrix("_RotationMatrix", rotationMatrix);
        material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
        material.SetFloat("_Angle", angle * Mathf.Deg2Rad);

        Graphics.Blit(source, destination, material);
    }

19 View Source File : GameObjectBrush.cs
License : Apache License 2.0
Project Creator : DarkLop

private void FlipX()
		{
			BrushCell[] oldCells = m_Cells.Clone() as BrushCell[];
			BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, m_Size);

			foreach (Vector3Int oldPos in oldBounds.allPositionsWithin)
			{
				int newX = m_Size.x - oldPos.x - 1;
				int toIndex = GetCellIndex(newX, oldPos.y, oldPos.z);
				int fromIndex = GetCellIndex(oldPos);
				m_Cells[toIndex] = oldCells[fromIndex];
			}

			int newPivotX = m_Size.x - pivot.x - 1;
			pivot = new Vector3Int(newPivotX, pivot.y, pivot.z);
			Matrix4x4 flip = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(-1f, 1f, 1f));
			Quaternion orientation = Quaternion.Euler(0f, 0f, -180f);
			
			foreach (BrushCell cell in m_Cells)
			{
				Vector3 oldOffset = cell.offset;
				cell.offset = flip * oldOffset;
				cell.orientation = cell.orientation*orientation;
			}
		}

19 View Source File : MinimapRenderer.cs
License : MIT License
Project Creator : slavidodo

public RenderError Render(RenderTexture renderTarget) {
            if (MiniMapStorage == null || !OpenTibiaUnity.GameManager.IsGameRunning || !WorldMapStorage.Valid)
                return RenderError.MiniMapNotValid;

            var commandBuffer = new CommandBuffer();
            commandBuffer.SetRenderTarget(renderTarget);
            commandBuffer.ClearRenderTarget(false, true, Color.black);

            var zoom = new Vector2() {
                x = Screen.width / (float)Constants.MiniMapSideBarViewWidth,
                y = Screen.height / (float)Constants.MiniMapSideBarViewHeight,
            };

            zoom *= _zoomScale;

            var drawnSectors = new List<MiniMapSector>();

            // 4 is the maximum number of sectors to be drawn (pre-calculated)
            // todo; provide a function to calculate it (if someone plans to use minimap differently)
            Vector3Int curPosition = new Vector3Int(0, 0, PositionZ);
            for (int i = 0; i < 4; i++) {
                curPosition.x = _positionRect.x + i % 2 * _positionRect.width;
                curPosition.y = _positionRect.y + (i / 2) * _positionRect.height;

                var sector = MiniMapStorage.AcquireSector(curPosition, false);
                if (sector == null || drawnSectors.IndexOf(sector) != -1)
                    continue;

                drawnSectors.Add(sector);

                var sectorRect = new RectInt(sector.SectorX, sector.SectorY, Constants.MiniMapSectorSize, Constants.MiniMapSectorSize);
                var translation = sectorRect.position - _positionRect.position;

                Matrix4x4 transformation = Matrix4x4.TRS(translation * zoom, Quaternion.Euler(180, 0, 0), Constants.MiniMapSectorSize * zoom);

                var props = new MaterialPropertyBlock();
                props.SetTexture("_MainTex", sector.SafeDrawTexture);
                props.SetVector("_MainTex_UV", new Vector4(1, 1, 0, 0));
                props.SetFloat("_HighlightOpacity", 0);
                Utils.GraphicsUtility.DrawTexture(commandBuffer, transformation, OpenTibiaUnity.GameManager.AppearanceTypeMaterial, props);
            }

            Graphics.ExecuteCommandBuffer(commandBuffer);
            commandBuffer.Dispose();

            return RenderError.None;

        }

19 View Source File : RuleTile.cs
License : Apache License 2.0
Project Creator : DarkLop

public bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, ref Matrix4x4 transform)
		{
			// Check rule against rotations of 0, 90, 180, 270
			for (int angle = 0; angle <= (rule.m_RuleTransform == TilingRule.Transform.Rotated ? 270 : 0); angle += 90)
			{
				if (RuleMatches(rule, position, tilemap, angle))
				{
					transform = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -angle), Vector3.one);
					return true;
				}
			}

			// Check rule against x-axis mirror
			if ((rule.m_RuleTransform == TilingRule.Transform.MirrorX) && RuleMatches(rule, position, tilemap, true, false))
			{
				transform = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(-1f, 1f, 1f));
				return true;
			}

			// Check rule against y-axis mirror
			if ((rule.m_RuleTransform == TilingRule.Transform.MirrorY) && RuleMatches(rule, position, tilemap, false, true))
			{
				transform = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(1f, -1f, 1f));
				return true;
			}

			return false;
		}

19 View Source File : WallPaperTest.cs
License : MIT License
Project Creator : IxxyXR

public override void DoUpdate()
    {
        if (!SlowMerge)
        {
            GetComponent<MeshRenderer>().enabled = false;
            Mesh mesh;
            if (Application.isPlaying)
            {
                mesh = GetComponent<MeshFilter>().mesh;
            }
            else
            {
                mesh = GetComponent<MeshFilter>().sharedMesh;
            }
            
            if (mesh == null) return;
            
            var matrices = new List<Matrix4x4>();
            var replacedulativeTransform = Matrix4x4.TRS(PositionEach, Quaternion.Euler(RotationEach), ScaleEach);
            var currentreplacedulativeTransform = replacedulativeTransform;

            var baseMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.localScale);
            foreach (var m in sym.matrices)
            {
                matrices.Add(
                    baseMatrix * (ApplyAfter ? currentreplacedulativeTransform * m : m * currentreplacedulativeTransform)
                );
                currentreplacedulativeTransform *= replacedulativeTransform;
            }
            DrawInstances(mesh, GetComponent<MeshRenderer>().material, matrices);
        }

        base.DoUpdate();
    }

19 View Source File : AttackTrigger.cs
License : MIT License
Project Creator : Interactml

void OnDrawGizmos()
        {
            if (Application.isPlaying)
            {
                Gizmos.color = DebugColor;
                Gizmos.matrix = transform.localToWorldMatrix;

                if (Collider && Collider.enabled)
                {
                    if (Collider is BoxCollider)
                    {
                        BoxCollider _C = Collider as BoxCollider;
                        if (!_C.enabled) return;
                        var sizeX = transform.lossyScale.x * _C.size.x;
                        var sizeY = transform.lossyScale.y * _C.size.y;
                        var sizeZ = transform.lossyScale.z * _C.size.z;
                        Matrix4x4 rotationMatrix = Matrix4x4.TRS(_C.bounds.center, transform.rotation, new Vector3(sizeX, sizeY, sizeZ));

                        Gizmos.matrix = rotationMatrix;
                        Gizmos.DrawCube(Vector3.zero, Vector3.one);
                        Gizmos.color = new Color(DebugColor.r, DebugColor.g, DebugColor.b, 1f);
                        Gizmos.DrawWireCube(Vector3.zero, Vector3.one);
                    }
                    else if (Collider is SphereCollider)
                    {
                        SphereCollider _C = Collider as SphereCollider;

                        if (!_C.enabled) return;

                        Gizmos.matrix = transform.localToWorldMatrix;

                        Gizmos.DrawSphere(Vector3.zero + _C.center, _C.radius);
                        Gizmos.color = new Color(DebugColor.r, DebugColor.g, DebugColor.b, 1f);
                        Gizmos.DrawWireSphere(Vector3.zero + _C.center, _C.radius);
                    }
                }
            }



        }

19 View Source File : GameObjectBrush.cs
License : Apache License 2.0
Project Creator : DarkLop

private void FlipY()
		{
			BrushCell[] oldCells = m_Cells.Clone() as BrushCell[];
			BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, m_Size);

			foreach (Vector3Int oldPos in oldBounds.allPositionsWithin)
			{
				int newY = m_Size.y - oldPos.y - 1;
				int toIndex = GetCellIndex(oldPos.x, newY, oldPos.z);
				int fromIndex = GetCellIndex(oldPos);
				m_Cells[toIndex] = oldCells[fromIndex];
			}

			int newPivotY = m_Size.y - pivot.y - 1;
			pivot = new Vector3Int(pivot.x, newPivotY, pivot.z);
			Matrix4x4 flip = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(1f, -1f, 1f));
			Quaternion orientation = Quaternion.Euler(0f, 0f, -180f);
			foreach (BrushCell cell in m_Cells)
			{
				Vector3 oldOffset = cell.offset;
				cell.offset = flip * oldOffset;
				cell.orientation = cell.orientation * orientation;
			}
		}

19 View Source File : Ui.cs
License : GNU General Public License v3.0
Project Creator : k0np4ku

private void OnGUI()
        {
            GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(Screen.width / 1024f, Screen.height / 576f, 1f));
            if (Inst != null)
                _windowRect = GUILayout.Window(0, _windowRect, MainWindow, GUIContent.none, GUIStyle.none);
        }

19 View Source File : SteamVR_Utils.cs
License : MIT License
Project Creator : dag10

public HmdMatrix34_t ToHmdMatrix34()
		{
			var m = Matrix4x4.TRS(pos, rot, Vector3.one);
			var pose = new HmdMatrix34_t();

			pose.m0  =  m[0, 0];
            pose.m1  =  m[0, 1];
			pose.m2  = -m[0, 2];
			pose.m3  =  m[0, 3];

			pose.m4  =  m[1, 0];
			pose.m5  =  m[1, 1];
			pose.m6  = -m[1, 2];
			pose.m7  =  m[1, 3];

			pose.m8  = -m[2, 0];
			pose.m9  = -m[2, 1];
			pose.m10 =  m[2, 2];
			pose.m11 = -m[2, 3];

			return pose;
		}

19 View Source File : RenderCompositor.cs
License : MIT License
Project Creator : olokobayusuf

private void Composite (Layer layer) {
			commandQueue.Enqueue(() => {
				// Set the render target
				Graphics.SetRenderTarget(composite);
				// Load the ortho projection
				GL.PushMatrix();
				GL.LoadPixelMatrix(0, composite.width, 0, composite.height);
				// Set the material texture
				material.SetTexture("_MainTex", layer.texture);
				// Set the material preplaced
				if (!material.SetPreplaced(0)) {
					Debug.LogError("Compositor: Failed to activate compositor material to composite layer");
					return;
				}
				// Apply the transformations // Note that the multiplication is done in reverse order
				var extent = new Vector2(layer.texture.width, layer.texture.height) * 0.5f;
				GL.MultMatrix(
					Matrix4x4.Translate((Vector3)layer.offset) *
					Matrix4x4.Translate(extent) *
					Matrix4x4.Scale(layer.scale) *
					Matrix4x4.TRS(Vector2.zero, Quaternion.AngleAxis(layer.rotation, Vector3.forward), Vector3.one) *
					Matrix4x4.Translate(-extent)
				);
				// Draw the quad
				GL.Begin(GL.QUADS);
				GL.TexCoord2(0f, 0f);
				GL.Vertex3(0f, 0f, 0);
				GL.TexCoord2(0f, 1f);
				GL.Vertex3(0f, layer.texture.height, 0);
				GL.TexCoord2(1f, 1f);
				GL.Vertex3(layer.texture.width, layer.texture.height, 0);
				GL.TexCoord2(1f, 0f);
				GL.Vertex3(layer.texture.width, 0f, 0);
				GL.End();
				// Restore camera projection
				GL.PopMatrix ();
            });
        }

19 View Source File : NavMeshSurfaceEditor.cs
License : MIT License
Project Creator : DKaravolos

void OnSceneGUI()
        {
            if (!editingCollider)
                return;

            var navSurface = (NavMeshSurface)target;
            var color = navSurface.enabled ? s_HandleColor : s_HandleColorDisabled;
            var localToWorld = Matrix4x4.TRS(navSurface.transform.position, navSurface.transform.rotation, Vector3.one);
            using (new Handles.DrawingScope(color, localToWorld))
            {
                m_BoundsHandle.center = navSurface.center;
                m_BoundsHandle.size = navSurface.size;

                EditorGUI.BeginChangeCheck();
                m_BoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(navSurface, "Modified NavMesh Surface");
                    Vector3 center = m_BoundsHandle.center;
                    Vector3 size = m_BoundsHandle.size;
                    navSurface.center = center;
                    navSurface.size = size;
                    EditorUtility.SetDirty(target);
                }
            }
        }

19 View Source File : MarksView.cs
License : MIT License
Project Creator : slavidodo

public void DrawMarks(CommandBuffer commandBuffer, Marks marks, int screenX, int screenY, Vector2 zoom) {
            var texture = OpenTibiaUnity.GameManager.MarksViewTexture;
            var material = OpenTibiaUnity.GameManager.MarksViewMaterial;

            var position = new Vector2(screenX, screenY) * zoom;
            var scale = new Vector2(Constants.FieldSize, Constants.FieldSize) * zoom;
            var transformation = Matrix4x4.TRS(position, Quaternion.Euler(180, 0, 0), scale);

            var size = _marksStartSize;

            foreach (var information in _marksViewInformations) {
                if (!marks.IsMarkSet(information.MarkType))
                    continue;

                uint eightBit = marks.GetMarkColor(information.MarkType);
                if (eightBit > Marks.MarksNumTotal)
                    continue;

                Color color;
                if (eightBit > Marks.MarkNumColors)
                    color = s_FrameColors[(int)eightBit];
                else
                    color = Colors.ColorFrom8Bit((int)eightBit);

                var uv = new Vector4() {
                    z = size * Constants.FieldSize / (float)texture.width,
                    w = (Constants.MarkThicknessBold - information.MarkThickness) * Constants.FieldSize / (float)texture.height,
                    x = Constants.FieldSize / (float)texture.width,
                    y = Constants.FieldSize / (float)texture.height,
                };

                var props = new MaterialPropertyBlock();
                props.SetTexture("_MainTex", texture);
                props.SetVector("_MainTex_ST", uv);
                props.SetColor("_Color", color);
                Utils.GraphicsUtility.DrawTexture(commandBuffer, transformation, material, props);
            }
        }

19 View Source File : UnityARSessionNativeInterface.cs
License : MIT License
Project Creator : codeyuan666

public static UnityARUserAnchorData UnityARUserAnchorDataFromGameObject(GameObject go) {
            // create an anchor data struct from a game object transform
            Matrix4x4 matrix = Matrix4x4.TRS(go.transform.position, go.transform.rotation, go.transform.localScale);
            UnityARUserAnchorData ad = new UnityARUserAnchorData();
            ad.transform.column0 = matrix.GetColumn(0);
            ad.transform.column1 = matrix.GetColumn(1);
            ad.transform.column2 = matrix.GetColumn(2);
            ad.transform.column3 = matrix.GetColumn(3);
            return ad;
        }

19 View Source File : SplitStackWindow.cs
License : MIT License
Project Creator : slavidodo

protected void Update() {
            if (Screen.width != _screenWidth || Screen.height != _screenHeight) {
                _screenWidth = Screen.width;
                _screenHeight = Screen.height;
                var zoom = new Vector2(Screen.width / (float)Constants.FieldSize, Screen.height / (float)Constants.FieldSize);
                _viewMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, zoom)
                    * OpenTibiaUnity.GameManager.MainCamera.worldToCameraMatrix;

                if (!!_objectInstance)
                    _objectInstance.InvalidateTRS();
            }
        }

19 View Source File : NavMeshSourceTag.cs
License : MIT License
Project Creator : Donut-Studios

public static void Collect(ref List<NavMeshBuildSource> sources)
    {
        sources.Clear();

        for (var i = 0; i < m_Meshes.Count; ++i)
        {
            var mf = m_Meshes[i];
            if (mf == null) continue;

            var m = mf.sharedMesh;
            if (m == null) continue;

            var s = new NavMeshBuildSource();
            s.shape = NavMeshBuildSourceShape.Mesh;
            s.sourceObject = m;
            s.transform = mf.transform.localToWorldMatrix;
            s.area = 0;
            sources.Add(s);
        }

        for (var i = 0; i < m_Terrains.Count; ++i)
        {
            var t = m_Terrains[i];
            if (t == null) continue;

            var s = new NavMeshBuildSource();
            s.shape = NavMeshBuildSourceShape.Terrain;
            s.sourceObject = t.terrainData;
            // Terrain system only supports translation - so we preplaced translation only to back-end
            s.transform = Matrix4x4.TRS(t.transform.position, Quaternion.idenreplacedy, Vector3.one);
            s.area = 0;
            sources.Add(s);
        }
    }

19 View Source File : GvrPostRender.cs
License : MIT License
Project Creator : harshitjuneja

private void ComputeUIMatrix() {
    centerWidthPx = kCenterLineThicknessDp / 160.0f * Screen.dpi / 2;
    buttonWidthPx = kButtonWidthDp / 160.0f * Screen.dpi / 2;
    xScale = buttonWidthPx / Screen.width;
    yScale = buttonWidthPx / Screen.height;
    xfm = Matrix4x4.TRS(new Vector3(0.5f, yScale, 0), Quaternion.idenreplacedy,
                        new Vector3(xScale, yScale, 1));
  }

19 View Source File : SoftMask.cs
License : GNU General Public License v3.0
Project Creator : Cytoid

void UpdateMaskTexture()
		{
			if (!graphic || !graphic.canvas)
			{
				return;
			}

			_stencilDepth = MaskUtilities.GetStencilDepth(transform, MaskUtilities.FindRootSortOverrideCanvas(transform));

			// Collect children soft masks.
			int depth = 0;
			s_TmpSoftMasks[0].Add(this);
			while (_stencilDepth + depth < 3)
			{
				int count = s_TmpSoftMasks[depth].Count;
				for (int i = 0; i < count; i++)
				{
					List<SoftMask> children = s_TmpSoftMasks[depth][i]._children;
					int childCount = children.Count;
					for (int j = 0; j < childCount; j++)
					{
						var child = children[j];
						var childDepth = child.m_PartOfParent ? depth : depth + 1;
						s_TmpSoftMasks[childDepth].Add(child);
					}
				}
				depth++;
			}

			// Clear.
			_cb.Clear();
			_cb.SetRenderTarget(softMaskBuffer);
			_cb.ClearRenderTarget(false, true, s_ClearColors[_stencilDepth]);

			// Set view and projection matrices.
			var c = graphic.canvas.rootCanvas;
			var cam = c.worldCamera ?? Camera.main;
			if (c && c.renderMode != RenderMode.ScreenSpaceOverlay && cam)
			{
				_cb.SetViewProjectionMatrices(cam.worldToCameraMatrix, GL.GetGPUProjectionMatrix(cam.projectionMatrix, false));
			}
			else
			{
				var pos = c.transform.position;
				var vm = Matrix4x4.TRS(new Vector3(-pos.x, -pos.y, -1000), Quaternion.idenreplacedy, new Vector3(1, 1, -1f));
				var pm = Matrix4x4.TRS(new Vector3(0, 0, -1), Quaternion.idenreplacedy, new Vector3(1 / pos.x, 1 / pos.y, -2 / 10000f));
				_cb.SetViewProjectionMatrices(vm, pm);
			}

			// Draw soft masks.
			for (int i = 0; i < s_TmpSoftMasks.Length; i++)
			{
				int count = s_TmpSoftMasks[i].Count;
				for (int j = 0; j < count; j++)
				{
					var sm = s_TmpSoftMasks[i][j];

					if (i != 0)
					{
						sm._stencilDepth = MaskUtilities.GetStencilDepth(sm.transform, MaskUtilities.FindRootSortOverrideCanvas(sm.transform));
					}

					// Set material property.
					sm.material.SetInt(s_ColorMaskId, (int)1 << (3 - _stencilDepth - i));
					sm._mpb.SetTexture(s_MainTexId, sm.graphic.mainTexture);
					sm._mpb.SetFloat(s_SoftnessId, sm.m_Softness);

					// Draw mesh.
					_cb.DrawMesh(sm.mesh, sm.transform.localToWorldMatrix, sm.material, 0, 0, sm._mpb);
				}
				s_TmpSoftMasks[i].Clear();
			}

			Graphics.ExecuteCommandBuffer(_cb);
		}

19 View Source File : Pose3D.cs
License : MIT License
Project Creator : harshitjuneja

protected void Set(Vector3 position, Quaternion orientation) {
    Position = position;
    Orientation = orientation;
    Matrix = Matrix4x4.TRS(position, orientation, Vector3.one);
  }

19 View Source File : RuleTile.cs
License : Apache License 2.0
Project Creator : DarkLop

private static Matrix4x4 ApplyRandomTransform(TilingRule.Transform type, Matrix4x4 original, float perlinScale, Vector3Int position)
		{
			float perlin = GetPerlinValue(position, perlinScale, 200000f);
			switch (type)
			{
				case TilingRule.Transform.MirrorX:
					return original * Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(perlin < 0.5 ? 1f : -1f, 1f, 1f));
				case TilingRule.Transform.MirrorY:
					return original * Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(1f, perlin < 0.5 ? 1f : -1f, 1f));
				case TilingRule.Transform.Rotated:
					int angle = Mathf.Clamp(Mathf.FloorToInt(perlin * 4), 0, 3) * 90;
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -angle), Vector3.one);		
			}
			return original;
		}

19 View Source File : PointGroupTest.cs
License : MIT License
Project Creator : IxxyXR

public override void AfterAllOps()
    {
        base.AfterAllOps();
        if (SlowMerge)
        {
            GetComponent<MeshRenderer>().enabled = true;
            poly = poly.Cloner(sym.matrices, Matrix4x4.TRS(PositionEach, Quaternion.Euler(RotationEach), ScaleEach), ApplyAfter);
        }
    }

19 View Source File : NodeEditorGUI.cs
License : MIT License
Project Creator : Interactml

public static void EndZoomed(Rect rect, float zoom, float topPadding) {
            GUIUtility.ScaleAroundPivot(Vector2.one * zoom, rect.size * 0.5f);
            Vector3 offset = new Vector3(
                (((rect.width * zoom) - rect.width) * 0.5f),
                (((rect.height * zoom) - rect.height) * 0.5f) + (-topPadding * zoom) + topPadding,
                0);
            GUI.matrix = Matrix4x4.TRS(offset, Quaternion.idenreplacedy, Vector3.one);
        }

19 View Source File : GameObjectBrush.cs
License : Apache License 2.0
Project Creator : DarkLop

public override void Rotate(RotationDirection direction, Grid.CellLayout layout)
		{
			Vector3Int oldSize = m_Size;
			BrushCell[] oldCells = m_Cells.Clone() as BrushCell[];
			size = new Vector3Int(oldSize.y, oldSize.x, oldSize.z);
			BoundsInt oldBounds = new BoundsInt(Vector3Int.zero, oldSize);

			foreach (Vector3Int oldPos in oldBounds.allPositionsWithin)
			{
				int newX = direction == RotationDirection.Clockwise ? oldSize.y - oldPos.y - 1 : oldPos.y;
				int newY = direction == RotationDirection.Clockwise ? oldPos.x : oldSize.x - oldPos.x - 1;
				int toIndex = GetCellIndex(newX, newY, oldPos.z);
				int fromIndex = GetCellIndex(oldPos.x, oldPos.y, oldPos.z, oldSize.x, oldSize.y, oldSize.z);
				m_Cells[toIndex] = oldCells[fromIndex];
			}

			int newPivotX = direction == RotationDirection.Clockwise ? oldSize.y - pivot.y - 1 : pivot.y;
			int newPivotY = direction == RotationDirection.Clockwise ? pivot.x : oldSize.x - pivot.x - 1;
			pivot = new Vector3Int(newPivotX, newPivotY, pivot.z);

			Matrix4x4 rotation = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? 90f : -90f), Vector3.one);
			Quaternion orientation = Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? 90f : -90f);
			foreach (BrushCell cell in m_Cells)
			{
				cell.offset = rotation * cell.offset;
				cell.orientation = cell.orientation * orientation;
			}
		}

19 View Source File : Unitile.cs
License : MIT License
Project Creator : IxxyXR

void ut_33336()
    {
        // TODO Fix...
        float rot = Mathf.Acos(5f / (Mathf.Sqrt(7f) * 2f));
        set_incs(Mathf.Sqrt(7f), Mathf.Sqrt(21f));
        set_polygon(6, rot);
        add_polygon(0, 0);
        add_polygon(Mathf.Sqrt(7f) / 2f, Mathf.Sqrt(21f) / 2f);
        for (int i = 0; i < 6; i++)
        {
            float rot2 = rot + Mathf.PI / 3f + i * Mathf.PI / 3f; //var trans = Matrix4x4.TRS(new Vector3(Mathf.Sqrt(3f) - 1f / Mathf.Sqrt(3f), 0, 0), Quaternion.idenreplacedy, Vector3.one);
            var trans = Matrix4x4.TRS(
                new Vector3(Mathf.Sqrt(3f) - 1f / Mathf.Sqrt(3f), 0, 0),
                Quaternion.idenreplacedy,
                Vector3.one
            );
            trans *= Matrix4x4.TRS(
                Vector3.zero,
                Quaternion.Euler(0, 0, rot2),
                Vector3.one
            );
            set_polygon(3, rot2);
            var cent = trans.MultiplyPoint3x4(Vector3.zero);
            add_polygon(cent.x, cent.z);
            add_polygon(cent.x + Mathf.Sqrt(7f) / 2f, cent.z + Mathf.Sqrt(21f) / 2f);
            if (i < 3)
            {
                trans = Matrix4x4.TRS(
                    new Vector3(0, 0, 1f),
                    Quaternion.idenreplacedy,
                    Vector3.one) * trans;
                cent = trans.MultiplyPoint3x4(Vector3.zero);
                if (i == 1) add_polygon(cent.x, cent.z);
                add_polygon(cent.x + Mathf.Sqrt(7f) / 2f, cent.z + Mathf.Sqrt(21f) / 2f);
            }
        }
    }

19 View Source File : SteamVR_Utils.cs
License : MIT License
Project Creator : dag10

public HmdMatrix44_t ToHmdMatrix44()
		{
			var m = Matrix4x4.TRS(pos, rot, Vector3.one);
			var pose = new HmdMatrix44_t();

			pose.m0  =  m[0, 0];
            pose.m1  =  m[0, 1];
			pose.m2  = -m[0, 2];
			pose.m3  =  m[0, 3];

			pose.m4  =  m[1, 0];
			pose.m5  =  m[1, 1];
			pose.m6  = -m[1, 2];
			pose.m7  =  m[1, 3];

			pose.m8  = -m[2, 0];
			pose.m9  = -m[2, 1];
			pose.m10 =  m[2, 2];
			pose.m11 = -m[2, 3];

			pose.m12 =  m[3, 0];
			pose.m13 =  m[3, 1];
			pose.m14 = -m[3, 2];
			pose.m15 =  m[3, 3];

			return pose;
		}

19 View Source File : WallPaperTest.cs
License : MIT License
Project Creator : IxxyXR

public override void DoUpdate()
    {
        if (!SlowMerge)
        {
            GetComponent<MeshRenderer>().enabled = false;
            Mesh mesh;
            if (Application.isPlaying)
            {
                mesh = GetComponent<MeshFilter>().mesh;
            }
            else
            {
                mesh = GetComponent<MeshFilter>().sharedMesh;
            }
            
            if (mesh == null) return;
            
            var matrices = new List<Matrix4x4>();
            var replacedulativeTransform = Matrix4x4.TRS(PositionEach, Quaternion.Euler(RotationEach), ScaleEach);
            var currentreplacedulativeTransform = replacedulativeTransform;

            var baseMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.localScale);
            foreach (var m in sym.matrices)
            {
                matrices.Add(
                    baseMatrix * (ApplyAfter ? currentreplacedulativeTransform * m : m * currentreplacedulativeTransform)
                );
                currentreplacedulativeTransform *= replacedulativeTransform;
            }
            DrawInstances(mesh, GetComponent<MeshRenderer>().material, matrices);
        }

        base.DoUpdate();
    }

19 View Source File : NetworkHitbox.cs
License : MIT License
Project Creator : deadgg

private void OnDrawGizmos()
        {
            Gizmos.color = new Color(0.2f, 0.2f, 1f, 0.3f);
            Gizmos.matrix = Matrix4x4.TRS(transform.TransformPoint(_hitboxCenter), transform.rotation, transform.lossyScale);
            Gizmos.DrawCube(Vector3.zero, _hitboxSize);
            Gizmos.DrawWireCube(Vector3.zero, _hitboxSize);
        }

19 View Source File : UIPanelInspector.cs
License : MIT License
Project Creator : mamoniem

void AdjustClipping (UIPanel p, Vector3 startLocalPos, Vector4 startCR, Vector3 worldDelta, UIWidget.Pivot pivot)
	{
		Transform t = p.cachedTransform;
		Transform parent = t.parent;
		Matrix4x4 parentToLocal = (parent != null) ? t.parent.worldToLocalMatrix : Matrix4x4.idenreplacedy;
		Matrix4x4 worldToLocal = parentToLocal;
		Quaternion invRot = Quaternion.Inverse(t.localRotation);
		worldToLocal = worldToLocal * Matrix4x4.TRS(Vector3.zero, invRot, Vector3.one);
		Vector3 localDelta = worldToLocal.MultiplyVector(worldDelta);

		float left = 0f;
		float right = 0f;
		float top = 0f;
		float bottom = 0f;

		Vector2 dragPivot = NGUIMath.GetPivotOffset(pivot);

		if (dragPivot.x == 0f && dragPivot.y == 1f)
		{
			left = localDelta.x;
			top = localDelta.y;
		}
		else if (dragPivot.x == 0f && dragPivot.y == 0.5f)
		{
			left = localDelta.x;
		}
		else if (dragPivot.x == 0f && dragPivot.y == 0f)
		{
			left = localDelta.x;
			bottom = localDelta.y;
		}
		else if (dragPivot.x == 0.5f && dragPivot.y == 1f)
		{
			top = localDelta.y;
		}
		else if (dragPivot.x == 0.5f && dragPivot.y == 0f)
		{
			bottom = localDelta.y;
		}
		else if (dragPivot.x == 1f && dragPivot.y == 1f)
		{
			right = localDelta.x;
			top = localDelta.y;
		}
		else if (dragPivot.x == 1f && dragPivot.y == 0.5f)
		{
			right = localDelta.x;
		}
		else if (dragPivot.x == 1f && dragPivot.y == 0f)
		{
			right = localDelta.x;
			bottom = localDelta.y;
		}

		AdjustClipping(p, startCR,
			Mathf.RoundToInt(left),
			Mathf.RoundToInt(top),
			Mathf.RoundToInt(right),
			Mathf.RoundToInt(bottom));
	}

19 View Source File : UnityARSessionNativeInterface.cs
License : MIT License
Project Creator : codeyuan666

public static UnityARAnchorData UnityARAnchorDataFromGameObject(GameObject go) {
            // create an anchor data struct from a game object transform
            Matrix4x4 matrix = Matrix4x4.TRS(go.transform.position, go.transform.rotation, go.transform.localScale);
            UnityARAnchorData ad = new UnityARAnchorData();
            ad.transform.column0 = matrix.GetColumn(0);
            ad.transform.column1 = matrix.GetColumn(1);
            ad.transform.column2 = matrix.GetColumn(2);
            ad.transform.column3 = matrix.GetColumn(3);
            return ad;
        }

19 View Source File : pb_Stl.cs
License : GNU General Public License v3.0
Project Creator : NoteCAD

private static Vector3[] Left2Right(Vector3[] v)
		{
			Matrix4x4 l2r = Matrix4x4.TRS(Vector3.zero, Quaternion.idenreplacedy, new Vector3(1f, 1f, -1f));
			Vector3[] r = new Vector3[v.Length];

			for(int i = 0; i < v.Length; i++)
				r[i] = l2r.MultiplyPoint3x4(v[i]);

			return r;
		}

19 View Source File : NavMeshSurfaceEditor.cs
License : MIT License
Project Creator : DKaravolos

static void RenderBoxGizmo(NavMeshSurface navSurface, GizmoType gizmoType, bool selected)
        {
            var color = selected ? s_HandleColorSelected : s_HandleColor;
            if (!navSurface.enabled)
                color = s_HandleColorDisabled;

            var oldColor = Gizmos.color;
            var oldMatrix = Gizmos.matrix;

            // Use the unscaled matrix for the NavMeshSurface
            var localToWorld = Matrix4x4.TRS(navSurface.transform.position, navSurface.transform.rotation, Vector3.one);
            Gizmos.matrix = localToWorld;

            if (navSurface.collectObjects == CollectObjects.Volume)
            {
                Gizmos.color = color;
                Gizmos.DrawWireCube(navSurface.center, navSurface.size);

                if (selected && navSurface.enabled)
                {
                    var colorTrans = new Color(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, color.a * 0.15f);
                    Gizmos.color = colorTrans;
                    Gizmos.DrawCube(navSurface.center, navSurface.size);
                }
            }
            else
            {
                if (navSurface.navMeshData != null)
                {
                    var bounds = navSurface.navMeshData.sourceBounds;
                    Gizmos.color = Color.grey;
                    Gizmos.DrawWireCube(bounds.center, bounds.size);
                }
            }

            Gizmos.matrix = oldMatrix;
            Gizmos.color = oldColor;

            Gizmos.DrawIcon(navSurface.transform.position, "NavMeshSurface Icon", true);
        }

19 View Source File : Water.cs
License : MIT License
Project Creator : PacktPublishing

void Update()
	{
		if( !GetComponent<Renderer>() )
			return;
		Material mat = GetComponent<Renderer>().sharedMaterial;
		if( !mat )
			return;
			
		Vector4 waveSpeed = mat.GetVector( "WaveSpeed" );
		float waveScale = mat.GetFloat( "_WaveScale" );
		Vector4 waveScale4 = new Vector4(waveScale, waveScale, waveScale * 0.4f, waveScale * 0.45f);
		
		// Time since level load, and do intermediate calculations with doubles
		double t = Time.timeSinceLevelLoad / 20.0;
		Vector4 offsetClamped = new Vector4(
			(float)System.Math.IEEERemainder(waveSpeed.x * waveScale4.x * t, 1.0),
			(float)System.Math.IEEERemainder(waveSpeed.y * waveScale4.y * t, 1.0),
			(float)System.Math.IEEERemainder(waveSpeed.z * waveScale4.z * t, 1.0),
			(float)System.Math.IEEERemainder(waveSpeed.w * waveScale4.w * t, 1.0)
		);
		
		mat.SetVector( "_WaveOffset", offsetClamped );
		mat.SetVector( "_WaveScale4", waveScale4 );
			
		Vector3 waterSize = GetComponent<Renderer>().bounds.size;		
		Vector3 scale = new Vector3( waterSize.x*waveScale4.x, waterSize.z*waveScale4.y, 1 );
		Matrix4x4 scrollMatrix = Matrix4x4.TRS( new Vector3(offsetClamped.x,offsetClamped.y,0), Quaternion.idenreplacedy, scale );
		mat.SetMatrix( "_WaveMatrix", scrollMatrix );
				
		scale = new Vector3( waterSize.x*waveScale4.z, waterSize.z*waveScale4.w, 1 );
		scrollMatrix = Matrix4x4.TRS( new Vector3(offsetClamped.z,offsetClamped.w,0), Quaternion.idenreplacedy, scale );
		mat.SetMatrix( "_WaveMatrix2", scrollMatrix );
	}

19 View Source File : VisualizationJoint.cs
License : MIT License
Project Creator : Daimler

private Matrix4x4 GetGlobalMatrix()
        {
            var t = j.GetOffsetPositions().ToVector3();
            var q = j.GetOffsetRotation().ToQuaternion();
            var m = Matrix4x4.TRS(t, q, Vector3.one);
        
            if (parent != null)
            {
                var parentM = parent.GetGlobalMatrix();
                m = parentM * m;
            }
            
            return m;
        }

19 View Source File : StabilizationPlaneModifier.cs
License : MIT License
Project Creator : pampas93

private void OnDrawGizmos()
        {
            if (Application.isPlaying && DrawGizmos)
            {
                Vector3 focalPlaneNormal = -GazeNormal;
                Vector3 planeUp = Vector3.Cross(Vector3.Cross(focalPlaneNormal, Vector3.up), focalPlaneNormal);
                Gizmos.matrix = Matrix4x4.TRS(planePosition, Quaternion.LookRotation(focalPlaneNormal, planeUp), new Vector3(4.0f, 3.0f, 0.01f));

                Color gizmoColor = Color.magenta;
                gizmoColor.a = 0.5f;
                Gizmos.color = gizmoColor;

                Gizmos.DrawWireCube(Vector3.zero, Vector3.one);
                Gizmos.DrawCube(Vector3.zero, Vector3.one);
            }
        }

19 View Source File : NavMeshSurface.cs
License : MIT License
Project Creator : DKaravolos

void AppendModifierVolumes(ref List<NavMeshBuildSource> sources)
        {
            // Modifiers
            List<NavMeshModifierVolume> modifiers;
            if (m_CollectObjects == CollectObjects.Children)
            {
                modifiers = new List<NavMeshModifierVolume>(GetComponentsInChildren<NavMeshModifierVolume>());
                modifiers.RemoveAll(x => !x.isActiveAndEnabled);
            }
            else
            {
                modifiers = NavMeshModifierVolume.activeModifiers;
            }

            foreach (var m in modifiers)
            {
                if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
                    continue;
                if (!m.AffectsAgentType(m_AgentTypeID))
                    continue;
                var mcenter = m.transform.TransformPoint(m.center);
                var scale = m.transform.lossyScale;
                var msize = new Vector3(m.size.x * Mathf.Abs(scale.x), m.size.y * Mathf.Abs(scale.y), m.size.z * Mathf.Abs(scale.z));

                var src = new NavMeshBuildSource();
                src.shape = NavMeshBuildSourceShape.ModifierBox;
                src.transform = Matrix4x4.TRS(mcenter, m.transform.rotation, Vector3.one);
                src.size = msize;
                src.area = m.area;
                sources.Add(src);
            }
        }

19 View Source File : AppearanceInstance.cs
License : MIT License
Project Creator : slavidodo

protected void InternalDraw(CommandBuffer commandBuffer, Vector2Int screenPosition, bool highlighted,
                                      float highlightOpacity, CachedSprite cachedSprite, Material material = null, MaterialPropertyBlock props = null) {
            if (_shouldRecalculateTRS) {
                var position = new Vector2(screenPosition.x - _type.OffsetX, screenPosition.y - _type.OffsetY);
                if (ClampeToFieldSize)
                    _trsMatrix = Matrix4x4.TRS(position, Quaternion.Euler(180, 0, 0), s_fieldVector);
                else
                    _trsMatrix = Matrix4x4.TRS(position - cachedSprite.size + s_fieldVector, Quaternion.Euler(180, 0, 0), cachedSprite.size);

                _screenPosition = screenPosition;
                _shouldRecalculateTRS = false;
            } else if (_screenPosition != screenPosition) {
                _trsMatrix[0, 3] += (screenPosition.x - _screenPosition.x);
                _trsMatrix[1, 3] += (screenPosition.y - _screenPosition.y);
                _screenPosition = screenPosition;
            }

            if (material == null)
                material = OpenTibiaUnity.GameManager.AppearanceTypeMaterial;

            if (props == null)
                props = cachedSprite.materialProperyBlock;

            props.SetFloat("_HighlightOpacity", highlighted ? highlightOpacity : 0);
            if (commandBuffer != null)
                commandBuffer.DrawMesh(s_mesh, _trsMatrix, material, 0, 0, props);
        }

19 View Source File : LPShapeCircle.cs
License : MIT License
Project Creator : BelkinAndrey

public static void DrawGizmosPlaying (float radius,Transform transform,bool tran,float diff, Color colour,Vector3 Point,bool loop)
	{	
		Vector3 pos;
		Quaternion ang;
		if (tran)pos = transform.position;
		else pos = Vector3.zero;
		if (diff !=0f) ang = Quaternion.AngleAxis(diff,Vector3.forward);
		else ang = Quaternion.idenreplacedy;
		
		Gizmos.matrix = Matrix4x4.TRS(pos,ang,Vector3.one); 
		Gizmos.color = colour;
		Gizmos.DrawWireSphere(Point,radius);
	}

19 View Source File : TextualEffectInstance.cs
License : MIT License
Project Creator : slavidodo

public override void Draw(CommandBuffer commandBuffer, Vector2Int screenPosition, int patternX, int patternY, int patternZ, bool highlighted = false, float highlightOpacity = 0) {
            RebuildCache();
            var material = OpenTibiaUnity.GameManager.OutlinedVerdanaFontMaterial;
            var matrix = Matrix4x4.TRS(new Vector2(screenPosition.x, screenPosition.y), Quaternion.Euler(180, 0, 0), Vector3.one);
            commandBuffer.DrawMesh(_mesh, matrix, material);
        }

19 View Source File : NavMeshSurface.cs
License : MIT License
Project Creator : DKaravolos

Bounds CalculateWorldBounds(List<NavMeshBuildSource> sources)
        {
            // Use the unscaled matrix for the NavMeshSurface
            Matrix4x4 worldToLocal = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
            worldToLocal = worldToLocal.inverse;

            var result = new Bounds();
            foreach (var src in sources)
            {
                switch (src.shape)
                {
                    case NavMeshBuildSourceShape.Mesh:
                    {
                        var m = src.sourceObject as Mesh;
                        result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, m.bounds));
                        break;
                    }
                    case NavMeshBuildSourceShape.Terrain:
                    {
                        // Terrain pivot is lower/left corner - shift bounds accordingly
                        var t = src.sourceObject as TerrainData;
                        result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, new Bounds(0.5f * t.size, t.size)));
                        break;
                    }
                    case NavMeshBuildSourceShape.Box:
                    case NavMeshBuildSourceShape.Sphere:
                    case NavMeshBuildSourceShape.Capsule:
                    case NavMeshBuildSourceShape.ModifierBox:
                        result.Encapsulate(GetWorldBounds(worldToLocal * src.transform, new Bounds(Vector3.zero, src.size)));
                        break;
                }
            }
            // Inflate the bounds a bit to avoid clipping co-planar sources
            result.Expand(0.1f);
            return result;
        }

19 View Source File : PipelineTile.cs
License : Apache License 2.0
Project Creator : DarkLop

private Matrix4x4 GetTransform(byte mask)
		{
			switch (mask)
			{
				case 9:
				case 10:
				case 7:
				case 2:
				case 8:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -90f), Vector3.one);
				case 3: 
				case 14:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -180f), Vector3.one);
				case 6: 
				case 13:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -270f), Vector3.one);
			}
			return Matrix4x4.idenreplacedy;
		}

19 View Source File : ImageEffects.cs
License : Apache License 2.0
Project Creator : activey

public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
        {
            bool invertY = source.texelSize.y < 0.0f;
            if (invertY)
            {
                center.y = 1.0f - center.y;
                angle = -angle;
            }

            Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);

            material.SetMatrix("_RotationMatrix", rotationMatrix);
            material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
            material.SetFloat("_Angle", angle*Mathf.Deg2Rad);

            Graphics.Blit(source, destination, material);
        }

19 View Source File : LPShapeTools.cs
License : MIT License
Project Creator : BelkinAndrey

public static void DrawGizmosPlaying (Transform transform,bool tran,float diff, Color colour,Vector3[] Points,bool loop)
	{	
		Vector3 pos;
		Quaternion ang;
		if (tran)pos = transform.position;
		else pos = Vector3.zero;
		if (diff !=0f) ang = Quaternion.AngleAxis(diff,Vector3.forward);
		else ang = Quaternion.idenreplacedy;
		
		Gizmos.matrix = Matrix4x4.TRS(pos,ang,Vector3.one); 
		
		DrawGizmos(colour,Points,loop);
    }

19 View Source File : StabilizationPlaneModifier.cs
License : MIT License
Project Creator : dag10

private void OnDrawGizmos()
        {
            if (UnityEngine.Application.isPlaying)
            {
                Vector3 focalPlaneNormal = -Camera.main.transform.forward;
                Vector3 planeUp = Vector3.Cross(Vector3.Cross(focalPlaneNormal, Vector3.up), focalPlaneNormal);
                Gizmos.matrix = Matrix4x4.TRS(planePosition, Quaternion.LookRotation(focalPlaneNormal, planeUp), new Vector3(4.0f, 3.0f, 0.01f));

                Color gizmoColor = Color.magenta;
                gizmoColor.a = 0.5f;
                Gizmos.color = gizmoColor;

                Gizmos.DrawWireCube(Vector3.zero, Vector3.one);
                Gizmos.DrawCube(Vector3.zero, Vector3.one);
            }
        }

19 View Source File : TerrainTile.cs
License : Apache License 2.0
Project Creator : DarkLop

private Matrix4x4 GetTransform(byte mask)
		{
			switch (mask)
			{
				case 4:
				case 20:
				case 28:
				case 68:
				case 84:
				case 92:
				case 116:
				case 124:
				case 93:
				case 125:
				case 221:
				case 253:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -90f), Vector3.one);
				case 16:
				case 80:
				case 112:
				case 81:
				case 113:
				case 209:
				case 241:
				case 117:
				case 245:
				case 247:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -180f), Vector3.one);
				case 64:
				case 65:
				case 193:
				case 69:
				case 197:
				case 71:
				case 199:
				case 213:
				case 215:
				case 223:
					return Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -270f), Vector3.one);
			}
			return Matrix4x4.idenreplacedy;
		}

19 View Source File : PointGroupTest.cs
License : MIT License
Project Creator : IxxyXR

public override void DoUpdate()
    {
        if (!SlowMerge)
        {
            GetComponent<MeshRenderer>().enabled = false;
            Mesh mesh;
            if (Application.isPlaying)
            {
                mesh = GetComponent<MeshFilter>().mesh;
            }
            else
            {
                mesh = GetComponent<MeshFilter>().sharedMesh;
            }
            
            if (mesh == null) return;
            
            var matrices = new List<Matrix4x4>();
            var transformBefore = Matrix4x4.TRS(Position, Quaternion.Euler(Rotation), Scale);
            var replacedulativeTransform = Matrix4x4.TRS(PositionEach, Quaternion.Euler(RotationEach), ScaleEach);
            var currentreplacedulativeTransform = replacedulativeTransform;

            var baseMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.localScale);
            foreach (var m in sym.matrices)
            {
                matrices.Add(
                    (baseMatrix * (ApplyAfter ? currentreplacedulativeTransform * m : m * currentreplacedulativeTransform)) * transformBefore
                );
                currentreplacedulativeTransform *= replacedulativeTransform;
            }
            DrawInstances(mesh, GetComponent<MeshRenderer>().material, matrices);
        }

        base.DoUpdate();
    }

See More Examples