public void FromStreamEx(Stream s, PmxElementFormat f = null) { Position = V3_BytesConvert.FromStream(s); Normal = V3_BytesConvert.FromStream(s); UV = V2_BytesConvert.FromStream(s); for (int i = 0; i < f.UVACount; i++) { Vector4 vector = V4_BytesConvert.FromStream(s); if (0 <= i && i < UVA.Length) { UVA[i] = vector; } } Deform = (DeformType)s.ReadByte(); SDEF = false; switch (Deform) { case DeformType.BDEF1: Weight[0].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[0].Value = 1f; break; case DeformType.BDEF2: Weight[0].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[1].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[0].Value = PmxStreamHelper.ReadElement_Float(s); Weight[1].Value = 1f - Weight[0].Value; break; case DeformType.BDEF4: case DeformType.QDEF: Weight[0].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[1].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[2].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[3].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[0].Value = PmxStreamHelper.ReadElement_Float(s); Weight[1].Value = PmxStreamHelper.ReadElement_Float(s); Weight[2].Value = PmxStreamHelper.ReadElement_Float(s); Weight[3].Value = PmxStreamHelper.ReadElement_Float(s); break; case DeformType.SDEF: Weight[0].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[1].Bone = PmxStreamHelper.ReadElement_Int32(s, f.BoneSize); Weight[0].Value = PmxStreamHelper.ReadElement_Float(s); Weight[1].Value = 1f - Weight[0].Value; C0 = V3_BytesConvert.FromStream(s); R0 = V3_BytesConvert.FromStream(s); R1 = V3_BytesConvert.FromStream(s); CalcSDEF_RW(); SDEF = true; break; } EdgeScale = PmxStreamHelper.ReadElement_Float(s); if (f.WithID) { base.UID = PmxStreamHelper.ReadElement_UInt(s); base.CID = PmxStreamHelper.ReadElement_UInt(s); } }
public void ClearWeight() { ClearWeightBone(); ClearWeightValue(); Deform = DeformType.BDEF1; SDEF = false; }
public void FromPmxVertex(PmxVertex vertex) { Position = vertex.Position; Normal = vertex.Normal; UV = vertex.UV; for (int i = 0; i < 4; i++) { UVA[i] = vertex.UVA[i]; } for (int j = 0; j < 4; j++) { Weight[j] = vertex.Weight[j]; } EdgeScale = vertex.EdgeScale; Deform = vertex.Deform; SDEF = vertex.SDEF; C0 = vertex.C0; R0 = vertex.R0; R1 = vertex.R1; RW = vertex.RW; VertexMorphIndex = vertex.VertexMorphIndex; UVMorphIndex = vertex.UVMorphIndex; for (int k = 0; k < UVAMorphIndex.Length; k++) { UVAMorphIndex[k] = vertex.UVAMorphIndex[k]; } SDEFIndex = vertex.SDEFIndex; QDEFIndex = vertex.QDEFIndex; SoftBodyPosIndex = vertex.SoftBodyPosIndex; SoftBodyNormalIndex = vertex.SoftBodyNormalIndex; FromID(vertex); }
public void ApplyOperations(DeformType type) { System.Type applyType = EnumToType(type); if (applyType != typeof(DeformOperation)) { int completedOperations = 0; int failedOperations = 0; for (int i = 0; i < deformOperations.Count; i++) { if (deformOperations[i].GetType() == applyType) { if (deformOperations[i].ApplyOperation()) { completedOperations++; } else { Debug.LogWarning("FAILED OPERATION: type=" + applyType.ToString() + ", number=" + i + ", params=" + deformOperations[i].ParamsToString()); failedOperations++; } } } Debug.Log("OPERATIONS DONE: type=" + applyType.ToString() + ", success=" + completedOperations + ", failed=" + failedOperations); } else { Debug.LogWarning("INVALID OPERATION TYPE!"); } }
private void OnTubeDeform(DeformType deformType) { if (TubeDeform != null) { TubeDeform(deformType); } }
private System.Type EnumToType(DeformType type) { switch (type) { case DeformType.Mesh: return(typeof(MeshDeform)); case DeformType.Bend: return(typeof(BendDeform)); default: return(typeof(DeformOperation)); } }
public DeformType GetDeformType() { int num = 0; for (int i = 0; i < 4; i++) { if (Weight[i].Value != 0f) { num++; } } if (SDEF && num != 1) { return(DeformType.SDEF); } if (Deform == DeformType.QDEF && num != 1) { return(DeformType.QDEF); } DeformType result = DeformType.BDEF1; switch (num) { case 0: case 1: result = DeformType.BDEF1; break; case 2: result = DeformType.BDEF2; break; case 3: case 4: result = DeformType.BDEF4; break; } return(result); }
protected void CheckCollisionMeshes() { RaycastHit hitInfo; //bool hit = Physics.Raycast(suckingPoint.position, suckingPoint.forward, out hitInfo, suckingDistanceMeshes, 1 << collisionLayerMeshes); bool hit = CheckForCollision(out hitInfo, collisionLayerMeshes); if (hit) { NOS stage = NOS.Stage1; for (int i = 0; i <= (int)currentStage; i++) { if (hitInfo.transform.gameObject.tag == stage.ToString()) { DeformType deformType = (DeformType)i + 1; OnTubeDeform(deformType); PlaySoundAndParticles(currentStage, hitInfo.transform.gameObject); ChangeToMeltMaterial(hitInfo.transform.gameObject); hitInfo.transform.gameObject.SendMessage("IsGettingSuckedIn", currentStage, SendMessageOptions.DontRequireReceiver); } stage++; } } }
private void DeformTube(DeformType deformType) { if (deformAllowed) { deformAllowed = false; StartCoroutine(Cooldown(0.4f)); if (DeformType.Dust == deformType) { StartCoroutine(DeformType.Dust.ToString(), 0.25f); } if (DeformType.Layer1 == deformType || DeformType.Layer2 == deformType) { Debug.Log("layer1"); StartCoroutine(DeformType.Layer1.ToString(), 0.25f); } if (DeformType.Layer3 == deformType) { StartCoroutine(DeformType.Layer3.ToString(), 0.25f); } } }
public void UpdateDeformType() { Deform = GetDeformType(); }
private void Clear() { _description = "<none>"; _renderBump = string.Empty; _contentFlags = ContentFlags.Solid; _surfaceFlags = SurfaceFlags.None; _materialFlags = 0; _sort = (float) MaterialSort.Bad; _coverage = MaterialCoverage.Bad; _cullType = CullType.Front; _deformType = DeformType.None; _deformRegisters = new int[4]; _ops = null; _expressionRegisters = null; _constantRegisters = null; _stages = new MaterialStage[] { }; _stageCount = 0; _ambientStageCount = 0; _registerCount = 0; _lightFalloffImage = null; _entityGui = 0; _shouldCreateBackSides = false; _editorImageName = null; _fogLight = false; _blendLight = false; _ambientLight = false; _noFog = false; _hasSubview = false; _allowOverlays = true; _unsmoothedTangents = false; _userInterface = null; _referenceCount = 0; /*editorAlpha = 1.0;*/ _spectrum = 0; _polygonOffset = 0; _suppressInSubview = false; _portalSky = false; _decalInfo.StayTime = 10000; _decalInfo.FadeTime = 4000; _decalInfo.Start = new float[] { 1, 1, 1, 1 }; _decalInfo.End = new float[] { 0, 0, 0, 0 }; }
private void ParseDeform(idLexer lexer) { idToken token = lexer.ExpectAnyToken(); if(token == null) { return; } string tokenValue = token.ToString(); string tokenLower = tokenValue.ToLower(); if(tokenLower == "sprite") { _deformType = DeformType.Sprite; _cullType = CullType.TwoSided; this.MaterialFlag = MaterialFlags.NoShadows; } else if(tokenLower == "tube") { _deformType = DeformType.Tube; _cullType = CullType.TwoSided; this.MaterialFlag = MaterialFlags.NoShadows; } else if(tokenLower == "flare") { _deformType = DeformType.Flare; _cullType = CullType.TwoSided; _deformRegisters[0] = ParseExpression(lexer); this.MaterialFlag = MaterialFlags.NoShadows; } else if(tokenLower == "expand") { _deformType = DeformType.Expand; _deformRegisters[0] = ParseExpression(lexer); } else if(tokenLower == "move") { _deformType = DeformType.Move; _deformRegisters[0] = ParseExpression(lexer); } else if(tokenLower == "turbulent") { _deformType = DeformType.Turbulent; if((token = lexer.ExpectAnyToken()) == null) { lexer.Warning("deform particle missing particle name"); this.MaterialFlag = MaterialFlags.Defaulted; } else { _deformDecl = idE.DeclManager.FindType(DeclType.Table, token.ToString(), true); _deformRegisters[0] = ParseExpression(lexer); _deformRegisters[1] = ParseExpression(lexer); _deformRegisters[2] = ParseExpression(lexer); } } else if(tokenLower == "eyeball") { _deformType = DeformType.Eyeball; } else if(tokenLower == "particle") { _deformType = DeformType.Particle; if((token = lexer.ExpectAnyToken()) == null) { lexer.Warning("deform particle missing particle name"); this.MaterialFlag = MaterialFlags.Defaulted; } else { _deformDecl = idE.DeclManager.FindType(DeclType.Particle, token.ToString(), true); } } else if(tokenLower == "particle2") { _deformType = DeformType.Particle2; if((token = lexer.ExpectAnyToken()) == null) { lexer.Warning("deform particle missing particle name"); this.MaterialFlag = MaterialFlags.Defaulted; } else { _deformDecl = idE.DeclManager.FindType(DeclType.Table, token.ToString(), true); _deformRegisters[0] = ParseExpression(lexer); _deformRegisters[1] = ParseExpression(lexer); _deformRegisters[2] = ParseExpression(lexer); } } else { lexer.Warning("Bad deform type '{0}'", tokenValue); this.MaterialFlag = MaterialFlags.Defaulted; } }