public static GameObject CreateGameObject(Transform parent, GameObject prefabObj)
	{
		GameObject newChild = (GameObject)NcSafeTool.SafeInstantiate(prefabObj);
		if (parent != null)
		{	// 원본 transform을 유지 시켜주자
 			NcTransformTool	trans	= new NcTransformTool(newChild.transform);
			newChild.transform.parent = parent;
 			trans.CopyToLocalTransform(newChild.transform);
		}
		return newChild;
	}
	public static GameObject CreateGameObject(Transform parent, string name)
	{
		GameObject newChild = new GameObject(name);
		if (parent != null)
		{	// 원본 transform을 유지 시켜주자
 			NcTransformTool	trans	= new NcTransformTool(newChild.transform);
			newChild.transform.parent = parent;
 			trans.CopyToLocalTransform(newChild.transform);
		}
		return newChild;
	}
Esempio n. 3
0
	// Property -------------------------------------------------------------------------
	public override bool ShowPopupWindow(Object selObj)
	{
		if ((selObj is Transform))
		{
			m_PopupPosition		= FXMakerLayout.GetGUIMousePosition();
			m_SelectedTransform	= selObj as Transform;
			if (m_CopyTransform == null)
				m_CopyTransform = new NcTransformTool();
			SaveTransform();
			enabled	= true;
		} else {
			enabled	= false;
		}

		m_nWorldLocalSelIndex	= EditorPrefs.GetInt	("FxmPopup_Transform.m_nWorldLocalSelIndex"		, m_nWorldLocalSelIndex);
		InitFloatInput();

		return enabled;
	}
Esempio n. 4
0
    public ParticleSystem.Particle[] ShurikenScaleParticle(ParticleSystem.Particle[] parts, int nCount, bool bScale, bool bPosUpdate)
    {
        float num;

        if (bScale)
        {
            num = NcTransformTool.GetTransformScaleMeanValue(base.get_transform());
        }
        else
        {
            num = 1f / NcTransformTool.GetTransformScaleMeanValue(base.get_transform());
        }
        for (int i = 0; i < nCount; i++)
        {
            if (this.m_bWorldSpace)
            {
                if (bPosUpdate)
                {
                    Vector3 vector = this.m_OldPos - base.get_transform().get_position();
                    if (bScale)
                    {
                        int expr_66_cp_1 = i;
                        parts[expr_66_cp_1].set_position(parts[expr_66_cp_1].get_position() - vector * (1f - 1f / num));
                    }
                }
                int expr_90_cp_1 = i;
                parts[expr_90_cp_1].set_position(parts[expr_90_cp_1].get_position() - base.get_transform().get_position());
                int expr_B2_cp_1 = i;
                parts[expr_B2_cp_1].set_position(parts[expr_B2_cp_1].get_position() * num);
                int expr_CA_cp_1 = i;
                parts[expr_CA_cp_1].set_position(parts[expr_CA_cp_1].get_position() + base.get_transform().get_position());
            }
            else
            {
                int expr_F1_cp_1 = i;
                parts[expr_F1_cp_1].set_position(parts[expr_F1_cp_1].get_position() * num);
            }
            int expr_109_cp_1 = i;
            parts[expr_109_cp_1].set_startSize(parts[expr_109_cp_1].get_startSize() * num);
        }
        return(parts);
    }
Esempio n. 5
0
    void RenderParticleWire(Vector3 pos, float fSize, float fRot)
    {
        if (System.Single.IsNaN(pos.x))
        {
            return;
        }

        fSize *= 0.5f;
//		m_meshRenderer.sharedMaterial.color = m_backgroundColor;
        InitLineMaterial();
        m_lineMaterial.SetPass(0);

        NcTransformTool.InitWorldTransform(m_CalcChildTrans);
        m_CalcChildTrans.LookAt(Camera.main.transform, Camera.main.transform.up);
        m_CalcChildTrans.position = pos;


        GL.PushMatrix();
        GL.MultMatrix(m_CalcChildTrans.localToWorldMatrix);
        GL.Begin(GL.LINES);
        GL.Color((m_bRoot ? FXMakerOption.inst.m_ColorRootWireframe : FXMakerOption.inst.m_ColorChildWireframe));

        {
            GL.Vertex(new Vector3(-fSize, -fSize, 0));
            GL.Vertex(new Vector3(+fSize, -fSize, 0));

            GL.Vertex(new Vector3(+fSize, -fSize, 0));
            GL.Vertex(new Vector3(+fSize, +fSize, 0));

            GL.Vertex(new Vector3(+fSize, +fSize, 0));
            GL.Vertex(new Vector3(-fSize, +fSize, 0));

            GL.Vertex(new Vector3(-fSize, +fSize, 0));
            GL.Vertex(new Vector3(-fSize, -fSize, 0));

            GL.Vertex(new Vector3(-fSize, -fSize, 0));
            GL.Vertex(new Vector3(+fSize, +fSize, 0));
        }

        GL.End();
        GL.PopMatrix();
    }
Esempio n. 6
0
    public Particle[] LegacyScaleParticle(Particle[] parts, bool bScale, bool bPosUpdate)
    {
        float fScale;

        if (bScale)
        {
            fScale = NcTransformTool.GetTransformScaleMeanValue(transform);
        }
        else
        {
            fScale = 1 / NcTransformTool.GetTransformScaleMeanValue(transform);
        }

        for (int n = 0; n < parts.Length; n++)
        {
            if (IsMeshParticleEmitter() == false)
            {
                if (m_bWorldSpace)
                {
                    if (bPosUpdate)
                    {
                        Vector3 move = (m_OldPos - transform.position);
                        if (bScale)
                        {
                            parts[n].position -= move * (1 - 1 / fScale);
                        }
                    }
                    parts[n].position -= transform.position;
                    parts[n].position *= fScale;
                    parts[n].position += transform.position;
                }
                else
                {
                    parts[n].position *= fScale;
                }
            }
            parts[n].angularVelocity *= fScale;
            parts[n].velocity        *= fScale;
            parts[n].size            *= fScale;
        }
        return(parts);
    }
Esempio n. 7
0
    public ParticleSystem.Particle[] ShurikenScaleParticle(ParticleSystem.Particle[] parts, int nCount, bool bScale, bool bPosUpdate)
    {
        float num;

        if (bScale)
        {
            num = NcTransformTool.GetTransformScaleMeanValue(base.transform);
        }
        else
        {
            num = 1f / NcTransformTool.GetTransformScaleMeanValue(base.transform);
        }
        for (int i = 0; i < nCount; i++)
        {
            if (this.m_bWorldSpace)
            {
                if (bPosUpdate)
                {
                    Vector3 a = this.m_OldPos - base.transform.position;
                    if (bScale)
                    {
                        int expr_66_cp_1 = i;
                        parts[expr_66_cp_1].position = parts[expr_66_cp_1].position - a * (1f - 1f / num);
                    }
                }
                int expr_90_cp_1 = i;
                parts[expr_90_cp_1].position = parts[expr_90_cp_1].position - base.transform.position;
                int expr_B2_cp_1 = i;
                parts[expr_B2_cp_1].position = parts[expr_B2_cp_1].position * num;
                int expr_CA_cp_1 = i;
                parts[expr_CA_cp_1].position = parts[expr_CA_cp_1].position + base.transform.position;
            }
            else
            {
                int expr_F1_cp_1 = i;
                parts[expr_F1_cp_1].position = parts[expr_F1_cp_1].position * num;
            }
            int expr_109_cp_1 = i;
            parts[expr_109_cp_1].size = parts[expr_109_cp_1].size * num;
        }
        return(parts);
    }
Esempio n. 8
0
    public ParticleSystem.Particle[] ShurikenScaleParticle(ParticleSystem.Particle[] parts, int nCount, bool bScale, bool bPosUpdate)
    {
        float fScale;

        if (bScale)
        {
            fScale = NcTransformTool.GetTransformScaleMeanValue(transform);
        }
        else
        {
            fScale = 1 / NcTransformTool.GetTransformScaleMeanValue(transform);
        }

        for (int n = 0; n < nCount; n++)
        {
            if (m_bWorldSpace)
            {
                if (bPosUpdate)
                {
                    Vector3 move = (m_OldPos - transform.position);
                    if (bScale)
                    {
                        parts[n].position -= move * (1 - 1 / fScale);
                    }
                }
                parts[n].position -= transform.position;
                parts[n].position *= fScale;
                parts[n].position += transform.position;
            }
            else
            {
                parts[n].position *= fScale;
            }
            //          parts[n].angularVelocity *= fScale;
#pragma warning disable CS0618 // Type or member is obsolete
            parts[n].size *= fScale;
#pragma warning restore CS0618 // Type or member is obsolete
                               //           parts[n].velocity *= fScale;
        }
        return(parts);
    }
Esempio n. 9
0
    protected void ChangeParent(Transform newParent, Transform child, bool bKeepingLocalTransform, Transform addTransform)
    {
        NcTransformTool tool = null;

        if (bKeepingLocalTransform)
        {
            tool = new NcTransformTool(child.transform);
            if (addTransform != null)
            {
                tool.AddTransform(addTransform);
            }
        }
        child.parent = newParent;
        if (bKeepingLocalTransform)
        {
            tool.CopyToLocalTransform(child.transform);
        }
        if (bKeepingLocalTransform)
        {
        }
    }
Esempio n. 10
0
    // Property -------------------------------------------------------------------------
    public override bool ShowPopupWindow(Object selObj)
    {
        if ((selObj is Transform))
        {
            m_PopupPosition     = FXMakerLayout.GetGUIMousePosition();
            m_SelectedTransform = selObj as Transform;
            if (m_CopyTransform == null)
            {
                m_CopyTransform = new NcTransformTool();
            }
            SaveTransform();
            enabled = true;
        }
        else
        {
            enabled = false;
        }

        m_nWorldLocalSelIndex = EditorPrefs.GetInt("FxmPopup_Transform.m_nWorldLocalSelIndex", m_nWorldLocalSelIndex);
        InitFloatInput();

        return(enabled);
    }
Esempio n. 11
0
    void SaveTransform()
    {
        if (m_SaveTrans == null)
        {
            m_SaveTrans = new NcTransformTool();
        }

        int nGroup = 3;

        for (int n = 0; n < nGroup; n++)
        {
            TRANS_TYPE nTrans = (TRANS_TYPE)n;

            if (m_nWorldLocalSelIndex == 0)
            {
                switch (nTrans)
                {
                case TRANS_TYPE.POSITION:       m_SaveTrans.m_vecPos = m_SelectedTransform.position;                 break;

                case TRANS_TYPE.ROTATION:       m_SaveTrans.m_vecRotHint = m_SelectedTransform.eulerAngles;              break;

                case TRANS_TYPE.SCALE:          m_SaveTrans.m_vecScale = m_SelectedTransform.lossyScale;               break;
                }
            }
            else
            {
                switch (nTrans)
                {
                case TRANS_TYPE.POSITION:       m_SaveTrans.m_vecPos = m_SelectedTransform.localPosition;    break;

                case TRANS_TYPE.ROTATION:       m_SaveTrans.m_vecRotHint = m_SelectedTransform.localEulerAngles; break;

                case TRANS_TYPE.SCALE:          m_SaveTrans.m_vecScale = m_SelectedTransform.localScale;               break;
                }
            }
        }
    }
Esempio n. 12
0
 public float GetScaleMaxMeshNormalVelocity()
 {
     return(m_fLegacyMaxMeshNormalVelocity * (m_bScaleWithTransform ? NcTransformTool.GetTransformScaleMeanValue(transform) : 1));
 }
Esempio n. 13
0
 //  public void UpdateAnimation(float fElapsedRate, bool bResetStartTime)
 //  {
 //      UpdateAnimation(fElapsedRate);
 //      if (bResetStartTime)
 //          m_fStartTime = GetEngineTime();
 //  }
 public void ResetPosition()
 {
     m_NcTansform = new NcTransformTool(transform);
 }
Esempio n. 14
0
 public void CopyToTransform(Transform dst)
 {
     dst.set_position(this.m_vecPos);
     dst.set_rotation(this.m_vecRot);
     NcTransformTool.CopyLossyToLocalScale(this.m_vecScale, dst);
 }
Esempio n. 15
0
 public static void CopyLossyToLocalScale(Vector3 srcLossyScale, Transform dst)
 {
     dst.set_localScale(NcTransformTool.GetUnitVector());
     dst.set_localScale(new Vector3((dst.get_lossyScale().x != 0f) ? (srcLossyScale.x / dst.get_lossyScale().x) : srcLossyScale.x, (dst.get_lossyScale().y != 0f) ? (srcLossyScale.y / dst.get_lossyScale().y) : srcLossyScale.y, (dst.get_lossyScale().z != 0f) ? (srcLossyScale.z / dst.get_lossyScale().z) : srcLossyScale.z));
 }
Esempio n. 16
0
 public static void InitWorldScale(Transform dst)
 {
     dst.set_localScale(NcTransformTool.GetUnitVector());
     dst.set_localScale(new Vector3((dst.get_lossyScale().x != 0f) ? (1f / dst.get_lossyScale().x) : 1f, (dst.get_lossyScale().y != 0f) ? (1f / dst.get_lossyScale().y) : 1f, (dst.get_lossyScale().z != 0f) ? (1f / dst.get_lossyScale().z) : 1f));
 }
Esempio n. 17
0
	// --------------------------------------------------------------------------
	public void SetTransform(NcTransformTool val)
	{
		m_vecPos	= val.m_vecPos;
		m_vecRot	= val.m_vecRot;
		m_vecScale	= val.m_vecScale;
	}
Esempio n. 18
0
    // ------------------------------------------------------------------------
    void Awake()
    {
        m_NcTansform = new NcTransformTool(transform);
//      Debug.Log("NcCurveAnimation.Awake " + transform.parent.name);
    }
Esempio n. 19
0
 public void ResetPosition()
 {
     this.m_NcTansform = new NcTransformTool(base.transform);
 }
Esempio n. 20
0
	protected void ChangeParent(Transform newParent, Transform child, bool bKeepingLocalTransform, Transform addTransform)
	{
		// Keeping transform
		NcTransformTool	trans = null;
		if (bKeepingLocalTransform)
		{
			trans	= new NcTransformTool(child.transform);
			if (addTransform != null)
				trans.AddTransform(addTransform);
		}
		child.parent = newParent;
		if (bKeepingLocalTransform)
			trans.CopyToLocalTransform(child.transform);

		// Update component
		if (bKeepingLocalTransform)
		{
// 			NcEffectBehaviour[]	coms = gameObject.GetComponentsInChildren<NcEffectBehaviour>();
// 			foreach (NcEffectBehaviour com in coms)
// 				com.SendMessage("Update", SendMessageOptions.DontRequireReceiver);
			NcBillboard[]	ncBills = gameObject.GetComponentsInChildren<NcBillboard>();
	 		foreach (NcBillboard ncb in ncBills)
				ncb.UpdateBillboard();
		}
	}
Esempio n. 21
0
    List <Vector4> GetParticlePostions(bool bPosUpdate)
    {
        List <Vector4> listPartis = new List <Vector4>();

        if (IsLegacy() || IsShuriken())
        {
            CreateTempObject();

            if (IsShuriken())
            {
                float fScale = 1.0f;
                ParticleSystem.Particle[] parts = new ParticleSystem.Particle[m_BaseTrans.GetComponent <ParticleSystem>().particleCount];
                m_BaseTrans.GetComponent <ParticleSystem>().GetParticles(parts);

                NcTransformTool.InitWorldTransform(m_CalcBaseTrans);
                if (m_bWorldParticle)
                {
                    NcParticleSystem ncPartScale = m_BaseTrans.GetComponent <NcParticleSystem>();
                    if (m_bScaledParticle)
                    {
                        ncPartScale.ShurikenScaleParticle(parts, parts.Length, true, bPosUpdate);
                    }
                }
                else
                {
                    m_CalcBaseTrans.position = m_BaseTrans.position;
                    m_CalcBaseTrans.rotation = m_BaseTrans.rotation;

                    if (m_bScaledParticle)
                    {
                        NcTransformTool.CopyLossyToLocalScale(NcTransformTool.GetTransformScaleMeanVector(m_BaseTrans), m_CalcBaseTrans);
                        fScale = NcTransformTool.GetTransformScaleMeanValue(m_BaseTrans);
                    }
                }

                foreach (ParticleSystem.Particle part in parts)
                {
                    Vector3 worldPos;
                    float   fSize = part.size * fScale;
                    NcTransformTool.InitLocalTransform(m_CalcChildTrans);
                    m_CalcChildTrans.localPosition = part.position;
                    worldPos = m_CalcChildTrans.position;

                    listPartis.Add(new Vector4(worldPos.x, worldPos.y, worldPos.z, fSize));
                }
            }
            else
            {
                float      fScale = 1.0f;
                Particle[] parts  = m_BaseTrans.GetComponent <ParticleEmitter>().particles;

                NcTransformTool.InitWorldTransform(m_CalcBaseTrans);
                if (m_bWorldParticle)
                {
                    // m_bLegacyRuntimeScale
                    NcParticleSystem ncPartScale = m_BaseTrans.GetComponent <NcParticleSystem>();
                    if (m_bScaledParticle)
                    {
                        ncPartScale.LegacyScaleParticle(parts, true, bPosUpdate);
                    }
                }
                else
                {
                    m_CalcBaseTrans.position = m_BaseTrans.position;
                    m_CalcBaseTrans.rotation = m_BaseTrans.rotation;

                    // m_bLegacyRuntimeScale
                    NcParticleSystem ncPartScale = m_BaseTrans.GetComponent <NcParticleSystem>();
                    if (m_bScaledParticle && ncPartScale.IsMeshParticleEmitter() == false)
                    {
                        NcTransformTool.CopyLossyToLocalScale(NcTransformTool.GetTransformScaleMeanVector(m_BaseTrans), m_CalcBaseTrans);
                        fScale = NcTransformTool.GetTransformScaleMeanValue(m_BaseTrans);
                    }
                    else
                    {
                        fScale = NcTransformTool.GetTransformScaleMeanValue(m_BaseTrans);
                    }
                }

                foreach (Particle part in parts)
                {
                    if (System.Single.IsNaN(part.position.x))
                    {
                        continue;
                    }
                    Vector3 worldPos;
//					float	fSize	= part.size;
                    float fSize = part.size * fScale;                                   // m_bLegacyRuntimeScale
                    NcTransformTool.InitLocalTransform(m_CalcChildTrans);
                    m_CalcChildTrans.localPosition = part.position;
                    worldPos = m_CalcChildTrans.position;
                    listPartis.Add(new Vector4(worldPos.x, worldPos.y, worldPos.z, fSize));
                }
            }
        }
        return(listPartis);
    }
Esempio n. 22
0
 public void BackupTransform(Transform targetTrans)
 {
     m_Transform  = targetTrans;
     m_NcTansform = new NcTransformTool(m_Transform);
 }
Esempio n. 23
0
 public void CopyToTransform(Transform dst)
 {
     dst.position = this.m_vecPos;
     dst.rotation = this.m_vecRot;
     NcTransformTool.CopyLossyToLocalScale(this.m_vecScale, dst);
 }
Esempio n. 24
0
 public static void CopyLossyToLocalScale(Vector3 srcLossyScale, Transform dst)
 {
     dst.localScale = NcTransformTool.GetUnitVector();
     dst.localScale = new Vector3((dst.lossyScale.x == 0f) ? srcLossyScale.x : (srcLossyScale.x / dst.lossyScale.x), (dst.lossyScale.y == 0f) ? srcLossyScale.y : (srcLossyScale.y / dst.lossyScale.y), (dst.lossyScale.z == 0f) ? srcLossyScale.z : (srcLossyScale.z / dst.lossyScale.z));
 }
Esempio n. 25
0
 public static void InitWorldScale(Transform dst)
 {
     dst.localScale = NcTransformTool.GetUnitVector();
     dst.localScale = new Vector3((dst.lossyScale.x == 0f) ? 1f : (1f / dst.lossyScale.x), (dst.lossyScale.y == 0f) ? 1f : (1f / dst.lossyScale.y), (dst.lossyScale.z == 0f) ? 1f : (1f / dst.lossyScale.z));
 }
 public static void InitWorldScale(Transform dst)
 {
     dst.localScale = NcTransformTool.GetUnitVector();
     dst.localScale = new Vector3((dst.lossyScale.x != 0f) ? (1f / dst.lossyScale.x) : 1f, (dst.lossyScale.y != 0f) ? (1f / dst.lossyScale.y) : 1f, (dst.lossyScale.z != 0f) ? (1f / dst.lossyScale.z) : 1f);
 }
Esempio n. 27
0
	void Update()
	{
		if (m_bStartDetach == false)
		{
			m_bStartDetach = true;

			if (transform.parent != null)
			{
				m_ParentGameObject = transform.parent.gameObject;
				m_ncDetachObject	= NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
			}

			// Detach Parent
			GameObject	parentObj = GetRootInstanceEffect();

			if (m_bFollowParentTransform)
			{
				m_OriginalPos.SetLocalTransform(transform);
				ChangeParent(parentObj.transform, transform, false, null);
				m_OriginalPos.CopyToLocalTransform(transform);
			} else {
				ChangeParent(parentObj.transform, transform, false, null);
			}

			if (m_bParentHideToStartDestroy == false)
				StartDestroy();
		}

		// Live time
		if (0 < m_fStartDestroyTime)
		{
			if (0 < m_fSmoothDestroyTime)
			{
				if (m_bSmoothHide)
				{
					float fAlphaRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
					if (fAlphaRate < 0)
						fAlphaRate = 0;

					if (m_bMeshFilterOnlySmoothHide)
					{
						// Recursively
						MeshFilter[] meshFilters = transform.GetComponentsInChildren<MeshFilter>(true);
						Color		color;
						for (int n = 0; n < meshFilters.Length; n++)
						{
							Color[]	colors	= meshFilters[n].mesh.colors;
							if (colors.Length == 0)
							{
								colors = new Color[meshFilters[n].mesh.vertices.Length];
								for (int c = 0; c < colors.Length; c++)
									colors[c] = Color.white;
							}
							for (int c = 0; c < colors.Length; c++)
							{
								color		= colors[c];
								color.a		= Mathf.Min(color.a, fAlphaRate);
								colors[c]	= color;
							}
							meshFilters[n].mesh.colors	= colors;
						}
					} else {
						// Recursively
						Renderer[] rens = transform.GetComponentsInChildren<Renderer>(true);
						for (int n = 0; n < rens.Length; n++)
						{
							Renderer	ren		= rens[n];
							string		colName	= GetMaterialColorName(ren.sharedMaterial);

							if (colName != null)
							{
								Color col	= ren.material.GetColor(colName);
								col.a		= Mathf.Min(col.a, fAlphaRate);
								ren.material.SetColor(colName, col);
// 								AddRuntimeMaterial(ren.material);
							}
						}
					}
				}
				if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
					Object.Destroy(gameObject);
			}
		} else {
			if (m_bParentHideToStartDestroy)
				if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
					StartDestroy();
		}

		// follow parent transform
 		if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
 		{
 			NcTransformTool	tmp = new NcTransformTool();
 			tmp.SetTransform(m_OriginalPos);
 			tmp.AddTransform(m_ParentGameObject.transform);
 			tmp.CopyToLocalTransform(transform);
 		}
	}
Esempio n. 28
0
 private void Update()
 {
     if (!this.m_bStartDetach)
     {
         this.m_bStartDetach = true;
         if (base.transform.parent != null)
         {
             this.m_ParentGameObject = base.transform.parent.gameObject;
             NcDetachObject.Create(this.m_ParentGameObject, base.transform.gameObject);
         }
         GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();
         if (this.m_bFollowParentTransform)
         {
             this.m_OriginalPos.SetLocalTransform(base.transform);
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
             this.m_OriginalPos.CopyToLocalTransform(base.transform);
         }
         else
         {
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
         }
         if (!this.m_bParentHideToStartDestroy)
         {
             this.StartDestroy();
         }
     }
     if (0f < this.m_fStartDestroyTime)
     {
         if (0f < this.m_fSmoothDestroyTime)
         {
             if (this.m_bSmoothHide)
             {
                 float num = 1f - (NcEffectBehaviour.GetEngineTime() - this.m_fStartDestroyTime) / this.m_fSmoothDestroyTime;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 Renderer[] componentsInChildren = base.transform.GetComponentsInChildren <Renderer>(true);
                 for (int i = 0; i < componentsInChildren.Length; i++)
                 {
                     Renderer renderer          = componentsInChildren[i];
                     string   materialColorName = NcEffectBehaviour.GetMaterialColorName(renderer.material);
                     if (materialColorName != null)
                     {
                         Color color = renderer.material.GetColor(materialColorName);
                         color.a = Mathf.Min(num, color.a);
                         renderer.material.SetColor(materialColorName, color);
                     }
                 }
             }
             if (this.m_fStartDestroyTime + this.m_fSmoothDestroyTime < NcEffectBehaviour.GetEngineTime())
             {
                 DelegateProxy.GameDestory(base.gameObject);
             }
         }
     }
     else if (this.m_bParentHideToStartDestroy && (this.m_ParentGameObject == null || !NcEffectBehaviour.IsActive(this.m_ParentGameObject)))
     {
         this.StartDestroy();
     }
     if (this.m_bFollowParentTransform && this.m_ParentGameObject != null && this.m_ParentGameObject.transform != null)
     {
         NcTransformTool ncTransformTool = new NcTransformTool();
         ncTransformTool.SetTransform(this.m_OriginalPos);
         ncTransformTool.AddTransform(this.m_ParentGameObject.transform);
         ncTransformTool.CopyToLocalTransform(base.transform);
     }
 }
Esempio n. 29
0
	void SaveTransform()
	{
		if (m_SaveTrans == null)
			m_SaveTrans = new NcTransformTool();

		int nGroup = 3;

		for (int n = 0; n < nGroup; n++)
		{
			TRANS_TYPE	nTrans		= (TRANS_TYPE)n;

			if (m_nWorldLocalSelIndex == 0)
			{
				switch (nTrans)
				{
					case TRANS_TYPE.POSITION:	m_SaveTrans.m_vecPos	= m_SelectedTransform.position;			break;
					case TRANS_TYPE.ROTATION:	m_SaveTrans.m_vecRotHint= m_SelectedTransform.eulerAngles;		break;
					case TRANS_TYPE.SCALE:		m_SaveTrans.m_vecScale	= m_SelectedTransform.lossyScale;		break;
				}
			} else {
				switch (nTrans)
				{
					case TRANS_TYPE.POSITION:	m_SaveTrans.m_vecPos	= m_SelectedTransform.localPosition;	break;
					case TRANS_TYPE.ROTATION:	m_SaveTrans.m_vecRotHint= m_SelectedTransform.localEulerAngles;	break;
					case TRANS_TYPE.SCALE:		m_SaveTrans.m_vecScale	= m_SelectedTransform.localScale;		break;
				}
			}
		}
	}
Esempio n. 30
0
 private void Update()
 {
     if (!this.m_bStartDetach)
     {
         this.m_bStartDetach = true;
         if (base.transform.parent != null)
         {
             this.m_ParentGameObject = base.transform.parent.gameObject;
             this.m_ncDetachObject   = NcDetachObject.Create(this.m_ParentGameObject, base.transform.gameObject);
         }
         GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();
         if (this.m_bFollowParentTransform)
         {
             this.m_OriginalPos.SetLocalTransform(base.transform);
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
             this.m_OriginalPos.CopyToLocalTransform(base.transform);
         }
         else
         {
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
         }
         if (!this.m_bParentHideToStartDestroy)
         {
             this.StartDestroy();
         }
     }
     if (0f < this.m_fStartDestroyTime)
     {
         if (0f < this.m_fSmoothDestroyTime)
         {
             if (this.m_bSmoothHide)
             {
                 float num = 1f - (NcEffectBehaviour.GetEngineTime() - this.m_fStartDestroyTime) / this.m_fSmoothDestroyTime;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 if (this.m_bMeshFilterOnlySmoothHide)
                 {
                     MeshFilter[] componentsInChildren = base.transform.GetComponentsInChildren <MeshFilter>(true);
                     for (int i = 0; i < componentsInChildren.Length; i++)
                     {
                         Color[] array = componentsInChildren[i].mesh.colors;
                         if (array.Length == 0)
                         {
                             array = new Color[componentsInChildren[i].mesh.vertices.Length];
                             for (int j = 0; j < array.Length; j++)
                             {
                                 array[j] = Color.white;
                             }
                         }
                         for (int k = 0; k < array.Length; k++)
                         {
                             Color color = array[k];
                             color.a  = Mathf.Min(color.a, num);
                             array[k] = color;
                         }
                         componentsInChildren[i].mesh.colors = array;
                     }
                 }
                 else
                 {
                     Renderer[] componentsInChildren2 = base.transform.GetComponentsInChildren <Renderer>(true);
                     for (int l = 0; l < componentsInChildren2.Length; l++)
                     {
                         Renderer renderer          = componentsInChildren2[l];
                         string   materialColorName = NcEffectBehaviour.GetMaterialColorName(renderer.sharedMaterial);
                         if (materialColorName != null)
                         {
                             Color color2 = renderer.material.GetColor(materialColorName);
                             color2.a = Mathf.Min(color2.a, num);
                             renderer.material.SetColor(materialColorName, color2);
                         }
                     }
                 }
             }
             if (this.m_fStartDestroyTime + this.m_fSmoothDestroyTime < NcEffectBehaviour.GetEngineTime())
             {
                 UnityEngine.Object.Destroy(base.gameObject);
             }
         }
     }
     else if (this.m_bParentHideToStartDestroy && (this.m_ParentGameObject == null || !NcEffectBehaviour.IsActive(this.m_ParentGameObject)))
     {
         this.StartDestroy();
     }
     if (this.m_bFollowParentTransform && this.m_ParentGameObject != null && this.m_ParentGameObject.transform != null)
     {
         NcTransformTool ncTransformTool = new NcTransformTool();
         ncTransformTool.SetTransform(this.m_OriginalPos);
         ncTransformTool.AddTransform(this.m_ParentGameObject.transform);
         ncTransformTool.CopyToLocalTransform(base.transform);
     }
 }
Esempio n. 31
0
	public static GameObject CreateGameObject(Transform parent, GameObject prefabObj, Vector3 pos, Quaternion rot)
	{
		GameObject newChild;

		if (NcSafeTool.IsSafe() == false)
			return null;
		newChild = (GameObject)NcSafeTool.SafeInstantiate(prefabObj, pos, rot);
		if (parent != null)
		{	// 원본 transform을 유지 시켜주자
 			NcTransformTool	trans	= new NcTransformTool(newChild.transform);
			newChild.transform.parent = parent;
 			trans.CopyToLocalTransform(newChild.transform);
		}
		return newChild;
	}
Esempio n. 32
0
 public void SetTransform(NcTransformTool val)
 {
     this.m_vecPos   = val.m_vecPos;
     this.m_vecRot   = val.m_vecRot;
     this.m_vecScale = val.m_vecScale;
 }
Esempio n. 33
0
    void OnRenderObject()
    {
//		if (Camera.main == null || m_meshRenderer == null)
        if (Camera.main == null)
        {
            return;
        }

        if (m_BaseTrans == null)
        {
            // OnDestroy ���� ������ wire
            Destroy(gameObject);
            return;
        }

        if (IsLegacy() || IsShuriken())
        {
            m_LastPparticlePos = GetParticlePostions(true);
        }

        if (m_bWireframe == false)
        {
            return;
        }

        if (IsLegacy() || IsShuriken())
        {
            foreach (Vector4 pos in m_LastPparticlePos)
            {
                RenderParticleWire(pos, pos.w, 0);
            }
        }

        if (m_lines != null)
        {
//			m_meshRenderer.sharedMaterial.color = m_backgroundColor;
            InitLineMaterial();
            m_lineMaterial.SetPass(0);

            Matrix4x4 matrix;
//			if (IsShuriken())
            if (IsLegacy() || IsShuriken())                     // m_bLegacyRuntimeScale
            {
                NcTransformTool.InitWorldTransform(m_CalcBaseTrans);
                m_CalcBaseTrans.position = m_BaseTrans.position;
                m_CalcBaseTrans.rotation = m_BaseTrans.rotation;

                if (m_bScaledParticle)
                {
                    NcTransformTool.CopyLossyToLocalScale(NcTransformTool.GetTransformScaleMeanVector(m_BaseTrans), m_CalcBaseTrans);
                }
                matrix = m_CalcBaseTrans.localToWorldMatrix;
            }
            else
            {
                // model
                matrix = m_BaseTrans.localToWorldMatrix;
            }

            GL.PushMatrix();
            GL.MultMatrix(matrix);
            GL.Begin(GL.LINES);
            GL.Color((m_bRoot ? FXMakerOption.inst.m_ColorRootWireframe : FXMakerOption.inst.m_ColorChildWireframe));

            for (int i = 0; i < m_lines.Length / 3; i++)
            {
                GL.Vertex(m_lines[i * 3]);
                GL.Vertex(m_lines[i * 3 + 1]);

                GL.Vertex(m_lines[i * 3 + 1]);
                GL.Vertex(m_lines[i * 3 + 2]);

                GL.Vertex(m_lines[i * 3 + 2]);
                GL.Vertex(m_lines[i * 3]);
            }

            GL.End();
            GL.PopMatrix();
        }
    }
Esempio n. 34
0
    public static Vector3 GetTransformScaleMeanVector(Transform srcTrans)
    {
        float transformScaleMeanValue = NcTransformTool.GetTransformScaleMeanValue(srcTrans);

        return(new Vector3(transformScaleMeanValue, transformScaleMeanValue, transformScaleMeanValue));
    }
Esempio n. 35
0
    void LegacySetParticle()
    {
        ParticleEmitter  pe = m_pe;
        ParticleAnimator pa = m_pa;
        ParticleRenderer pr = m_pr;

        if (pe == null || pr == null)
        {
            return;
        }

        if (m_bLegacyRuntimeScale)
        {
            Vector3 vecVelScale = Vector3.one * m_fStartSpeedRate;
            float   fVelScale   = m_fStartSpeedRate;

            pe.minSize     *= m_fStartSizeRate;
            pe.maxSize     *= m_fStartSizeRate;
            pe.minEnergy   *= m_fStartLifeTimeRate;
            pe.maxEnergy   *= m_fStartLifeTimeRate;
            pe.minEmission *= m_fStartEmissionRate;
            pe.maxEmission *= m_fStartEmissionRate;

            pe.worldVelocity         = Vector3.Scale(pe.worldVelocity, vecVelScale);
            pe.localVelocity         = Vector3.Scale(pe.localVelocity, vecVelScale);
            pe.rndVelocity           = Vector3.Scale(pe.rndVelocity, vecVelScale);
            pe.angularVelocity      *= fVelScale;
            pe.rndAngularVelocity   *= fVelScale;
            pe.emitterVelocityScale *= fVelScale;

//          NgAssembly.LogFieldsPropertis(pe);

            if (pa != null)
            {
                pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale);
                pa.force    = Vector3.Scale(pa.force, vecVelScale);
//				pa.damping					*= fScale;
            }

//          pr.velocityScale			*= fVelScale;
            pr.lengthScale *= m_fRenderLengthRate;
        }
        else
        {
            Vector3 vecVelScale = (m_bScaleWithTransform ? pe.transform.lossyScale : Vector3.one) * m_fStartSpeedRate;
            float   fVelScale   = (m_bScaleWithTransform ? NcTransformTool.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSpeedRate;
            float   fScale      = (m_bScaleWithTransform ? NcTransformTool.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSizeRate;

            pe.minSize     *= fScale;
            pe.maxSize     *= fScale;
            pe.minEnergy   *= m_fStartLifeTimeRate;
            pe.maxEnergy   *= m_fStartLifeTimeRate;
            pe.minEmission *= m_fStartEmissionRate;
            pe.maxEmission *= m_fStartEmissionRate;

            pe.worldVelocity         = Vector3.Scale(pe.worldVelocity, vecVelScale);
            pe.localVelocity         = Vector3.Scale(pe.localVelocity, vecVelScale);
            pe.rndVelocity           = Vector3.Scale(pe.rndVelocity, vecVelScale);
            pe.angularVelocity      *= fVelScale;
            pe.rndAngularVelocity   *= fVelScale;
            pe.emitterVelocityScale *= fVelScale;

//          NgAssembly.LogFieldsPropertis(pe);

            if (pa != null)
            {
                pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale);
                pa.force    = Vector3.Scale(pa.force, vecVelScale);
//				pa.damping					*= fScale;
            }

//          pr.velocityScale			*= fVelScale;
            pr.lengthScale *= m_fRenderLengthRate;
        }
    }
Esempio n. 36
0
 public static void InitLocalTransform(Transform dst)
 {
     dst.set_localPosition(NcTransformTool.GetZeroVector());
     dst.set_localRotation(NcTransformTool.GetIdenQuaternion());
     dst.set_localScale(NcTransformTool.GetUnitVector());
 }
	// Property -------------------------------------------------------------------------
	// Loop Function --------------------------------------------------------------------
	// Control Function -----------------------------------------------------------------
	public void BackupTransform(Transform targetTrans)
	{
		m_Transform		= targetTrans;
		m_NcTansform	= new NcTransformTool(m_Transform);
	}
Esempio n. 38
0
 public static void InitWorldTransform(Transform dst)
 {
     dst.set_position(NcTransformTool.GetZeroVector());
     dst.set_rotation(NcTransformTool.GetIdenQuaternion());
     NcTransformTool.InitWorldScale(dst);
 }
Esempio n. 39
0
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                m_ncDetachObject   = NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
            }

            // Detach Parent
            GameObject parentObj = GetRootInstanceEffect();

            if (m_bFollowParentTransform)
            {
                m_OriginalPos.SetLocalTransform(transform);
                ChangeParent(parentObj.transform, transform, false, null);
                m_OriginalPos.CopyToLocalTransform(transform);
            }
            else
            {
                ChangeParent(parentObj.transform, transform, false, null);
            }

            if (m_bParentHideToStartDestroy == false)
            {
                StartDestroy();
            }
        }

        // Live time
        if (0 < m_fStartDestroyTime)
        {
            if (0 < m_fSmoothDestroyTime)
            {
                if (m_bSmoothHide)
                {
                    float fAlphaRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
                    if (fAlphaRate < 0)
                    {
                        fAlphaRate = 0;
                    }

                    if (m_bMeshFilterOnlySmoothHide)
                    {
                        // Recursively
                        MeshFilter[] meshFilters = transform.GetComponentsInChildren <MeshFilter>(true);
                        Color        color;
                        for (int n = 0; n < meshFilters.Length; n++)
                        {
                            Color[] colors = meshFilters[n].mesh.colors;
                            if (colors.Length == 0)
                            {
                                colors = new Color[meshFilters[n].mesh.vertices.Length];
                                for (int c = 0; c < colors.Length; c++)
                                {
                                    colors[c] = Color.white;
                                }
                            }
                            for (int c = 0; c < colors.Length; c++)
                            {
                                color     = colors[c];
                                color.a   = Mathf.Min(color.a, fAlphaRate);
                                colors[c] = color;
                            }
                            meshFilters[n].mesh.colors = colors;
                        }
                    }
                    else
                    {
                        // Recursively
                        Renderer[] rens = transform.GetComponentsInChildren <Renderer>(true);
                        for (int n = 0; n < rens.Length; n++)
                        {
                            Renderer ren     = rens[n];
                            string   colName = GetMaterialColorName(ren.sharedMaterial);

                            if (colName != null)
                            {
                                Color col = ren.material.GetColor(colName);
                                col.a = Mathf.Min(col.a, fAlphaRate);
                                ren.material.SetColor(colName, col);
//                              AddRuntimeMaterial(ren.material);
                            }
                        }
                    }
                }
                if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
                {
                    Object.Destroy(gameObject);
                }
            }
        }
        else
        {
            if (m_bParentHideToStartDestroy)
            {
                if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
                {
                    StartDestroy();
                }
            }
        }

        // follow parent transform
        if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
        {
            NcTransformTool tmp = new NcTransformTool();
            tmp.SetTransform(m_OriginalPos);
            tmp.AddTransform(m_ParentGameObject.transform);
            tmp.CopyToLocalTransform(transform);
        }
    }
Esempio n. 40
0
    // Loop Function --------------------------------------------------------------------
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
            }

            // Detach Parent
            GameObject	parentObj = GetRootInstanceEffect();

            if (m_bFollowParentTransform)
            {
                m_OriginalPos.SetLocalTransform(transform);
                ChangeParent(parentObj.transform, transform, false, null);
                m_OriginalPos.CopyToLocalTransform(transform);
            } else {
                ChangeParent(parentObj.transform, transform, false, null);
            }

            if (m_bParentHideToStartDestroy == false)
                StartDestroy();
        }

        // Live time
        if (0 < m_fStartDestroyTime)
        {
            if (0 < m_fSmoothDestroyTime)
            {
                if (m_bSmoothHide)
                {
                    float fRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
                    if (fRate < 0)
                        fRate = 0;

                    // Recursively
                    Renderer[] rens = transform.GetComponentsInChildren<Renderer>(true);
                    for (int n = 0; n < rens.Length; n++)
                    {
                        Renderer	ren		= rens[n];
                        string		colName	= GetMaterialColorName(ren.material);

                        if (colName != null)
                        {
                            Color col = ren.material.GetColor(colName);
                            col.a = Mathf.Min(fRate, col.a);
                            ren.material.SetColor(colName, col);
                        }
                    }
                }
                if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
                    Object.Destroy(gameObject);
            }
        } else {
            if (m_bParentHideToStartDestroy)
                if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
                    StartDestroy();
        }

        // follow parent transform
         		if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
         		{
         			NcTransformTool	tmp = new NcTransformTool();
         			tmp.SetTransform(m_OriginalPos);
         			tmp.AddTransform(m_ParentGameObject.transform);
         			tmp.CopyToLocalTransform(transform);
         		}
    }