public string[] GetBaseForms(string lemma, string partOfSpeech, Morph.IOperation[] operations) { var baseForms = new List<string>(); foreach (Morph.IOperation operation in operations) { operation.Execute(lemma, partOfSpeech, baseForms); } return baseForms.ToArray(); }
public void MorphConstructorTest() { ICurve a = null; // TODO: инициализация подходящего значения ICurve b = null; // TODO: инициализация подходящего значения double alpha = 0F; // TODO: инициализация подходящего значения Morph target = new Morph(a, b, alpha); }
/// <summary> /// Performs a search based on the parameters setup /// in the Search constructor. /// </summary> /// <param name="doMorphs">Specifies whether to perform a search on morphs. /// This parameter is retrieved in the first /// call from do_search(bool m, string p). If morph searching is specified /// and a morph is found, then on a recursive call to this method /// morphing will be turned off to prevent unnecessary morph searching.</param> internal void Do_search(bool doMorphs) { Findtheinfo(); if (buf.Length > 0) { buf = "\n" + sch.Label + " of " + pos.Key + " " + word + "\n" + buf; } if (!doMorphs) { return; } morphs = new Hashtable(); Morph st = new Morph(word, pos, netData); string morphword; // if there are morphs then perform iterative searches // on each morph, filling the morph tree in the search // object. while ((morphword = st.Next()) != null) { Search s = new Search(morphword, pos, sch, whichsense, netData); s.Do_search(false); // Fill the morphlist - eg. if verb relations of 'drunk' are requested, none are directly // found, but the morph 'drink' will have results. The morph hashtable will be populated // into the search results and should be iterated instead of the returned synset if the // morphs are non-empty morphs[morphword] = s; buf += s.buf; } }
public override void Charseg(ref Intarray outimage, Bytearray inimage) { int swidth = PGeti("swidth"); int sheight = PGeti("sheight"); Bytearray image = new Bytearray(); image.Copy(inimage); OcrRoutine.binarize_simple(image); OcrRoutine.Invert(image); outimage.Copy(image); if (swidth > 0 || sheight > 0) { Morph.binary_close_rect(image, swidth, sheight); } Intarray labels = new Intarray(); labels.Copy(image); ImgLabels.label_components(ref labels); for (int i = 0; i < outimage.Length1d(); i++) { if (outimage.At1d(i) > 0) { outimage.Put1d(i, SegmRoutine.cseg_pixel(labels.At1d(i))); } } SegmRoutine.make_line_segmentation_white(outimage); SegmRoutine.check_line_segmentation(outimage); }
private static Period PeriodFromToken(string t) { if (Morph.HasOneOfLemmas(t, Keywords.Year)) { return(Period.Year); } if (Morph.HasOneOfLemmas(t, Keywords.Month)) { return(Period.Month); } if (Morph.HasOneOfLemmas(t, Keywords.Week)) { return(Period.Week); } if (Morph.HasOneOfLemmas(t, Keywords.Day)) { return(Period.Day); } if (Morph.HasOneOfLemmas(t, Keywords.Hour)) { return(Period.Hour); } if (Morph.HasOneOfLemmas(t, Keywords.Minute)) { return(Period.Minute); } return(Period.None); }
/// <summary> /// Return the segmentation-derived mask for the character. /// This may optionally be grown by some pixels. /// </summary> public override void GetMask(out Rect r, ref Bytearray outmask, int index, int grow) { r = boxes.At1d(index).Grow(grow); r.Intersect(new Rect(0, 0, labels.Dim(0), labels.Dim(1))); if (fullheight) { r.y0 = 0; r.y1 = labels.Dim(1); } int x = r.x0, y = r.y0, w = r.Width(), h = r.Height(); Intarray segs = segments.At1d(index); outmask.Resize(w, h); outmask.Fill(0); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { int label = labels[x + i, y + j]; if (NarrayUtil.first_index_of(segs, label) >= 0) { outmask[i, j] = (byte)255; } } } if (grow > 0) { Morph.binary_dilate_circle(outmask, grow); } }
//Game Code void Awake() { myCharacter = GetComponent <CharacterController>(); anim = GetComponent <Animator>(); morphEmmiter = GetComponent <ParticleSystem>(); manager = FindObjectOfType <gameManager>(); newCheckPoint(transform.position); Slime = transform.Find("Slime").gameObject; RockMonster = transform.Find("RockMonster").gameObject; Hawk = transform.Find("Hawk").gameObject; Human = transform.Find("Human").gameObject; Salmon = transform.Find("Salmon").gameObject; formRay = new formStats[5]; formRay[0] = new formStats(2f, 4f, 10f, .9f, 1, 3, 1, 4, 0.5f); //Slime formRay[1] = new formStats(1.5f, 3f, 10f, .9f, 1, 3, 1, 4, 0.5f); //RockMonster formRay[2] = new formStats(2f, 15f, 10f, .9f, 1, 3, 1, 0, 0.5f); //Hawk formRay[3] = new formStats(2f, 4f, 10f, .9f, 1, 3, 1, 4, 0.5f); //Human formRay[4] = new formStats(1f, 100f, 1f, .95f, 3, 9, .4f, 0, 25f); //Salmon //For the test formInt = 1; formNum = Morph.Rock; newForm = Morph.Slime; currentForm = Slime; activateNew(Morph.Slime); moveSpeed = new Vector3(0f, 0f, 0f); jumpCount = 1; canFlip = false; zAxis = false; }
public override bool AddMorph(string name, Morph morph) { if (morph == null || string.IsNullOrWhiteSpace(name)) { return(false); } if (morphDic.ContainsKey(name)) { return(false); } if (morph.Vertices != null) { var to = morph.Vertices.Max(v => v.Index); if (to > VerticesSize) { VerticesSize = to + 1; } } morphDic.Add(name, new MorphData() { Morph = morph, Rate = 0.0f, //FromIndex = from, //ToIndex = to, }); return(true); }
void runMorph() { morphEmmiter.Emit(45); switch (newForm) { case Morph.Slime: formNum = Morph.Slime; loadSpeeds(formRay[0]); break; case Morph.Rock: formNum = Morph.Rock; loadSpeeds(formRay[1]); break; case Morph.Hawk: formNum = Morph.Hawk; loadSpeeds(formRay[2]); break; case Morph.Human: formNum = Morph.Human; loadSpeeds(formRay[3]); break; case Morph.Salmon: formNum = Morph.Salmon; loadSpeeds(formRay[4]); break; } activateNew(newForm); }
private Morph[] CreateBoneMorphs(PmxMorph <PmxMorphBone>[] bs) { if (bs == null) { return(null); } var list = new List <Morph>(); foreach (var b in bs) { var m = new Morph() { Name = b.Name }; m.Bones = new BoneMorph[b.Data.Length]; for (var i = 0; i < m.Bones.Length; i++) { m.Bones[i] = new BoneMorph(); m.Bones[i].Index = b.Data[i].Index; m.Bones[i].Location = b.Data[i].Translation.ToVec3(true) * ImportScale; m.Bones[i].Rotation = b.Data[i].Quaternion.ToQuaternion(); } list.Add(m); } return(list.ToArray()); }
void activateNew(Morph turnOn) { Slime.SetActive(false); RockMonster.SetActive(false); Hawk.SetActive(false); Human.SetActive(false); Salmon.SetActive(false); switch (turnOn) { case Morph.Slime: Slime.SetActive(true); break; case Morph.Rock: RockMonster.SetActive(true); break; case Morph.Hawk: Hawk.SetActive(true); break; case Morph.Human: Human.SetActive(true); break; case Morph.Salmon: Salmon.SetActive(true); break; } }
private static int NeighbourDaysFromToken(string t) { if (Morph.HasOneOfLemmas(t, Keywords.Tomorrow)) { return(1); } if (Morph.HasOneOfLemmas(t, Keywords.Today)) { return(0); } if (Morph.HasOneOfLemmas(t, Keywords.AfterTomorrow)) { return(2); } if (Morph.HasOneOfLemmas(t, Keywords.Yesterday)) { return(-1); } if (Morph.HasOneOfLemmas(t, Keywords.BeforeYesterday)) { return(-2); } return(int.MinValue); }
protected void DrawImages(List <Bitmap> imageList, Graphics graphics) { if (imageList.Count == 0) { return; } var mergedImage = Image.Clone(imageList[0], PixelFormat.Format24bppRgb); var filter = new Morph(); //merges all images in the list for (var i = 1; i < imageList.Count; i++) { //sets filter parameters filter.OverlayImage = mergedImage; filter.SourcePercent = 1.0 / (i + 1.0); //applies morph (merge) filter var newImage = Image.Clone(imageList[i], PixelFormat.Format24bppRgb); //var newMergedImage = filter.Apply(newImage); //disposes of images created mergedImage.Dispose(); newImage.Dispose(); //mergedImage = newMergedImage; } //draws resulting image in graphics graphics.DrawImage(mergedImage, new Rectangle(new Point(0, 0), this.Size)); mergedImage.Dispose(); }
private static DayTime DaytimeFromToken(string t) { if (Morph.HasOneOfLemmas(t, Keywords.Noon)) { return(DayTime.Noon); } if (Morph.HasOneOfLemmas(t, Keywords.Morning)) { return(DayTime.Morning); } if (Morph.HasOneOfLemmas(t, Keywords.Evening)) { return(DayTime.Evening); } if (Morph.HasOneOfLemmas(t, Keywords.Night)) { return(DayTime.Night); } if (Morph.HasOneOfLemmas(t, Keywords.DaytimeDay)) { return(DayTime.Day); } return(DayTime.None); }
protected override bool ParseMatch(DatesRawData data, Match match, DateTime userDate) { var token = data.Tokens[match.Index]; data.RemoveRange(match.Index, 1); if (Morph.HasLemma(token.Value, Keywords.Holiday[0], Morph.LemmaSearchOptions.OnlySingular)) { // singular var saturday = new TextToken(Keywords.Saturday[0]) { Start = token.Start, End = token.End }; data.ReturnTokens(match.Index, "D", saturday); } else { // plural var holidays = new[] { Keywords.Saturday[0], Keywords.TimeTo[0], Keywords.Sunday[0] } .Select(k => new TextToken(k, token.Start, token.End)) .ToArray(); data.ReturnTokens(match.Index, "DtD", holidays); } return(true); }
public PackedLists <VertexDelta> ConvertToVertexDeltas(int vertexCount, bool[] channelsToInclude) { List <List <VertexDelta> > vertexDeltas = Enumerable.Range(0, vertexCount) .Select(idx => new List <VertexDelta>()) .ToList(); int morphCount = Morphs.Count; for (int morphIdx = 0; morphIdx < morphCount; ++morphIdx) { Morph morph = morphs[morphIdx]; if (channelsToInclude != null && !channelsToInclude[morph.Channel.Index]) { continue; } foreach (var delta in morph.Deltas) { vertexDeltas[delta.VertexIdx].Add(new VertexDelta(morphIdx, delta.PositionOffset)); } } return(PackedLists <VertexDelta> .Pack(vertexDeltas)); }
/* * private Bone CreateBones(PmxBone[] bones, Bone parent = null) * { * if (parent == null) * { * var root = Array.Find(bones, (b) => b.ParentBoneIndex == -1); * parent = new Bone() * { * Name = root.BoneName, * Index = Array.IndexOf(bones, root), * BoneType = BoneType.Standard, * }; * if (root.IsIK) parent.BoneType = BoneType.IK; * * parent.Position = root.Position.ToVec3(true) * ImportScale; * * //if (root.FixedAxis) parent.FixedAxis = root.Axis.ToVec3(true); * if (root.LocalAxis) * { * //parent.AxisX = root.AxisX.ToVec3(true); * //parent.AxisZ = root.AxisZ.ToVec3(true); * } * } * * var child = Array.FindAll(bones, (b) => b.ParentBoneIndex == parent.Index); * if (child != null && child.Length > 0) * { * var children = new Bone[child.Length]; * for (var i = 0; i < child.Length; i++) * { * children[i] = new Bone() * { * Name = child[i].BoneName, * Index = Array.IndexOf(bones, child[i]), * Parent = parent, * BoneType = BoneType.Standard, * }; * if (child[i].IsIK) children[i].BoneType = BoneType.IK; * * children[i].Position = child[i].Position.ToVec3(true) * ImportScale; * * //if (child[i].FixedAxis) children[i].FixedAxis = child[i].Axis.ToVec3(true); * if (child[i].LocalAxis) * { * //children[i].AxisX = child[i].AxisX.ToVec3(true); * //children[i].AxisZ = child[i].AxisZ.ToVec3(true); * } * * CreateBones(bones, children[i]); * } * parent.Children = children; * } * * return parent; * }*/ private Morph[] CreateVertexMorphs(PmxMorph <PmxMorphVertex>[] vs) { if (vs == null) { return(null); } var list = new List <Morph>(); foreach (var v in vs) { var m = new Morph() { Name = v.Name, }; m.Vertices = new VertexMorph[v.Data.Length]; for (var i = 0; i < m.Vertices.Length; i++) { m.Vertices[i] = new VertexMorph(); m.Vertices[i].Index = v.Data[i].Index; m.Vertices[i].Offset = v.Data[i].Position.ToVec3(true) * ImportScale; } list.Add(m); } return(list.ToArray()); }
void LoadWeights(string file) { try { StreamReader reader = new StreamReader(new FileStream(file, FileMode.Open)); string text2 = reader.ReadToEnd().Replace("\r", ""); reader.Close(); string text = text2.Replace(" ", ""); string[] lines = text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); Dictionary <Expression, Dictionary <Morph, double> > buf = new Dictionary <Expression, Dictionary <Morph, double> >(); foreach (string str in lines) { string[] sub = str.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); Expression exp = (Expression)Enum.Parse(typeof(Expression), sub[0]); if (buf.ContainsKey(exp)) { return; } Dictionary <Morph, double> weights = new Dictionary <Morph, double>(); string[] sub2 = sub[1].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str2 in sub2) { string[] sub3 = str2.Split(new char[] { '*' }, StringSplitOptions.RemoveEmptyEntries); double weight = double.Parse(sub3[0]); Morph morph = (Morph)Enum.Parse(typeof(Morph), sub3[1]); if (weights.ContainsKey(morph)) { return; } weights.Add(morph, weight); } buf.Add(exp, weights); } if (buf.Count < 5) { return; } this.weights = buf; lines = text2.Split(new char[] { '\n' }); foreach (string str in lines) { string[] sub = str.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); Expression exp = (Expression)Enum.Parse(typeof(Expression), sub[0]); foreach (ListViewItem item in this.menu.expressionsListView.Items) { Expression exp2 = (Expression)Enum.Parse(typeof(Expression), item.Text); if (exp2 == exp) { item.SubItems[1].Text = sub[1]; break; } } } } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } }
public MorphViewModel(Morph morph) { this.morph = morph; Children = from frame in morph.Frames select new MorphFrameViewModel(frame); }
public override int GetHashCode() { int hash = 486187739; hash = (hash * 16777619) ^ Morph.GetHashCode(); hash = (hash * 16777619) ^ Attributes.GetHashCode(); return(hash); }
public void Setup() { DispatcherCache.Clear(); circle = new Circle(); rect = new Rectangle(); roundedRect = new RoundedRectangle(); morph = new Morph(); ellipse = new Ellipse(); }
private static async Task <List <List <Morph.MorphResultSet> > > MorphAnalysisAsync(string docomoApiKey) { var text = "あらゆる現実を全て自分の方へねじ曲げたのだ"; var client = new Morph(docomoApiKey); Morph.InfoFilter info = Morph.InfoFilter.FORM | Morph.InfoFilter.POS; var results = await client.ExecAsync(text, info); return(results); }
public override string ToString() { StringBuilder res = new StringBuilder((Referent == null ? "Null" : Referent.ToString())); if (Morph != null) { res.AppendFormat(" {0}", Morph.ToString()); } return(res.ToString()); }
private void OnToggled(Morph m, bool b) { try { mc_.Toggle(m, b); } catch (Exception e) { Synergy.LogError(e.ToString()); } }
public override string ToString() { StringBuilder res = new StringBuilder(); res.AppendFormat("{0} {1}", Value, Typ.ToString()); if (Morph != null) { res.AppendFormat(" {0}", Morph.ToString()); } return(res.ToString()); }
private void WriteMorph(uint version, Morph morph) { WriteInt(morph.TargetCount); for (int i = 0; i < morph.TargetInts.Length; i++) { WriteInt(morph.TargetInts[i]); } WriteStringWithHash(version, morph.MaterialName); }
// Process max 200 frames (5 min) in 320x240 resolution. So 76KB memory per frame (grayscale). 1200 frames is max 93 MB of RAM (normally less because of area) private void processFilePart() { int nrofframes = imageStack.Length; int i; int sum; // create filters Morph morphFilter = new Morph(); // filter for adapting background morphFilter.SourcePercent = 0.8; Difference differenceFilter = new Difference(); // filter for subtracting two frames Threshold thresholdFilter = new Threshold(); // filter for thresholding FiltersSequence filters = new FiltersSequence(); // all filters in one filters.Add(morphFilter); filters.Add(differenceFilter); filters.Add(thresholdFilter); thresholdFilter.ThresholdValue = threshold; // Process here for (i = 0; i < nrofframes; i++) { // move background towards current frame morphFilter.OverlayImage = imageStack[i]; Bitmap Temp = morphFilter.Apply(backgroundFrame); backgroundFrame = Temp.Clone(new Rectangle(0, 0, Temp.Width, Temp.Height), Temp.PixelFormat); Temp.Dispose(); // apply rest of the filters differenceFilter.OverlayImage = imageStack[i]; Bitmap Temp2 = filters.Apply(backgroundFrame); sum = 0; // Calculate sum of white pixels for (int j = 0; j < Temp2.Width; j++) { for (int k = 0; k < Temp2.Height; k++) { if (Temp2.GetPixel(j, k) != Color.FromArgb(255, 0, 0, 0)) { sum += 1; } } } Temp2.Dispose(); if (sum > objectsize) { tracker.addFrame(currentFrame); } currentFrame += 1; } // Discard Array for (i = 0; i < nrofframes; i++) { imageStack[i].Dispose(); } }
internal static int FindIndex(string t, IList <string[]> list) { for (var i = 0; i < list.Count; i++) { if (Morph.HasOneOfLemmas(t, list[i])) { return(i); } } return(-1); }
private void CompareMorphs(Morph a, Morph b) { if (a == null || b == null) { Assert.IsTrue(a == null ? (b == null) : (b != null)); return; } Assert.AreEqual(a.TargetCount, b.TargetCount); CollectionAssert.AreEqual(a.TargetInts, b.TargetInts); Assert.AreEqual(a.NodeName, b.NodeName); }
public mCompositeMorph(Bitmap UnderlayBitmap, Bitmap OverlayBitmap, double Parameter) { BitmapUnder = new mSetFormat(UnderlayBitmap, mFilter.BitmapTypes.Rgb24bpp).ModifiedBitmap; BitmapOver = new mSetFormat(OverlayBitmap, mFilter.BitmapTypes.Rgb24bpp).ModifiedBitmap; ModifiedBitmap = BitmapUnder; Effect = new Morph(BitmapOver); Effect.SourcePercent = Parameter; ModifiedBitmap = Effect.Apply(BitmapUnder); }
private static PartTime PartTimeFromToken(string t) { if (Morph.HasOneOfLemmas(t, Keywords.Quarter)) { return(PartTime.Quarter); } if (Morph.HasOneOfLemmas(t, Keywords.Half)) { return(PartTime.Half); } return(PartTime.None); }
public virtual void LoadMesh(string filename) { byte[] buffer = File.ReadAllBytes(filename); BitPack input = new BitPack(buffer, 0); _header = TrimAt0(input.UnpackString(24)); if (!String.Equals(_header, MESH_HEADER)) return; // Populate base mesh variables _hasWeights = (input.UnpackByte() != 0); _hasDetailTexCoords = (input.UnpackByte() != 0); _position = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); _rotationAngles = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); _rotationOrder = input.UnpackByte(); _scale = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); _numVertices = (ushort)input.UnpackUShort(); // Populate the vertex array _vertices = new Vertex[_numVertices]; for (int i = 0; i < _numVertices; i++) _vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); for (int i = 0; i < _numVertices; i++) _vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); for (int i = 0; i < _numVertices; i++) _vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); for (int i = 0; i < _numVertices; i++) _vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat()); if (_hasDetailTexCoords) { for (int i = 0; i < _numVertices; i++) _vertices[i].DetailTexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat()); } if (_hasWeights) { for (int i = 0; i < _numVertices; i++) _vertices[i].Weight = input.UnpackFloat(); } _numFaces = input.UnpackUShort(); _faces = new Face[_numFaces]; for (int i = 0; i < _numFaces; i++) _faces[i].Indices = new short[] { input.UnpackShort(), input.UnpackShort(), input.UnpackShort() }; if (_hasWeights) { _numSkinJoints = input.UnpackUShort(); _skinJoints = new string[_numSkinJoints]; for (int i = 0; i < _numSkinJoints; i++) { _skinJoints[i] = TrimAt0(input.UnpackString(64)); } } else { _numSkinJoints = 0; _skinJoints = new string[0]; } // Grab morphs List<Morph> morphs = new List<Morph>(); string morphName = TrimAt0(input.UnpackString(64)); while (morphName != MORPH_FOOTER) { if (input.BytePos + 48 >= input.Data.Length) throw new FileLoadException("Encountered end of file while parsing morphs"); Morph morph = new Morph(); morph.Name = morphName; morph.NumVertices = input.UnpackInt(); morph.Vertices = new MorphVertex[morph.NumVertices]; for (int i = 0; i < morph.NumVertices; i++) { morph.Vertices[i].VertexIndex = input.UnpackUInt(); morph.Vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); morph.Vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); morph.Vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat()); morph.Vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat()); } morphs.Add(morph); // Grab the next name morphName = TrimAt0(input.UnpackString(64)); } _morphs = morphs.ToArray(); // Check if there are remaps or if we're at the end of the file if (input.BytePos < input.Data.Length - 1) { _numRemaps = input.UnpackInt(); _vertexRemaps = new VertexRemap[_numRemaps]; for (int i = 0; i < _numRemaps; i++) { _vertexRemaps[i].RemapSource = input.UnpackInt(); _vertexRemaps[i].RemapDestination = input.UnpackInt(); } } else { _numRemaps = 0; _vertexRemaps = new VertexRemap[0]; } }
public void morphmesh(Morph morph, float weight) { // Logger.Log(String.Format("Applying morph {0} weight {1}",morph.Name,weight),Helpers.LogLevel.Debug); for (int v = 0; v < morph.NumVertices; v++) { MorphVertex mvx = morph.Vertices[v]; uint i = mvx.VertexIndex; MorphRenderData.Vertices[i * 3] = MorphRenderData.Vertices[i * 3] + mvx.Coord.X * weight; MorphRenderData.Vertices[(i * 3) + 1] = MorphRenderData.Vertices[i * 3 + 1] + mvx.Coord.Y * weight; MorphRenderData.Vertices[(i * 3) + 2] = MorphRenderData.Vertices[i * 3 + 2] + mvx.Coord.Z * weight; MorphRenderData.Normals[i * 3] = MorphRenderData.Normals[i * 3] + mvx.Normal.X * weight; MorphRenderData.Normals[(i * 3) + 1] = MorphRenderData.Normals[(i * 3) + 1] + mvx.Normal.Y * weight; MorphRenderData.Normals[(i * 3) + 2] = MorphRenderData.Normals[(i * 3) + 2] + mvx.Normal.Z * weight; RenderData.TexCoords[i * 2] = OrigRenderData.TexCoords[i * 2] + mvx.TexCoord.X * weight; RenderData.TexCoords[(i * 2) + 1] = OrigRenderData.TexCoords[i * 2 + 1] + mvx.TexCoord.Y * weight; } }
/// <summary> /// Copies a partition from the input phonetic shape to the output phonetic shape. /// </summary> /// <param name="match">The match.</param> /// <param name="input">The input word synthesis.</param> /// <param name="output">The output word synthesis.</param> /// <param name="morpheme">The morpheme info.</param> public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph) { IList<PhoneticShapeNode> nodes = match.GetPartition(m_partition); if (nodes != null && nodes.Count > 0) { Morph morph = null; for (PhoneticShapeNode node = nodes[0]; node != nodes[nodes.Count - 1].Next; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); // mark the reduplicated segments with the gloss partition if (m_redup) { if (allomorph != null) { if (morph == null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } else { newNode.Partition = -1; } } else if (node.Partition != -1) { if (morph == null || morph.Partition != node.Partition) { morph = input.Morphs[node.Partition].Clone(); morph.Shape.Clear(); output.Morphs.Add(morph); } newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } output.Shape.Add(newNode); } } }
/// <summary> /// Applies the simple context to the input partition and copies it over to the output /// phonetic shape. /// </summary> /// <param name="match">The match.</param> /// <param name="input">The input word synthesis.</param> /// <param name="output">The output word synthesis.</param> /// <param name="morpheme">The morpheme info.</param> public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph) { IList<PhoneticShapeNode> nodes = match.GetPartition(m_partition); if (nodes != null && nodes.Count > 0) { Morph morph = null; if (allomorph != null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } for (PhoneticShapeNode node = nodes[0]; node != nodes[nodes.Count - 1].Next; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); if (node.Type == PhoneticShapeNode.NodeType.SEGMENT) { Segment seg = newNode as Segment; // sets the context's features on the segment m_ctxt.Apply(seg, match.VariableValues); seg.IsClean = false; seg.Partition = morph == null ? -1 : morph.Partition; } if (morph != null) morph.Shape.Add(newNode.Clone()); output.Shape.Add(newNode); } } }
/// <summary> /// Inserts a segment based on a simple context to the output. /// </summary> /// <param name="match">The match.</param> /// <param name="input">The input word synthesis.</param> /// <param name="output">The output word synthesis.</param> /// <param name="morpheme">The morpheme info.</param> public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph) { Segment newSeg = m_ctxt.ApplyInsertion(match.VariableValues); if (allomorph != null) { Morph morph = new Morph(allomorph); output.Morphs.Add(morph); morph.Shape.Add(newSeg.Clone()); newSeg.Partition = morph.Partition; } output.Shape.Add(newSeg); }
public void previewMorph(Morph m) { //if(valueType == (int)ValueType.MorphChannels) { for(int i=0;i<m.morph.Count;i++) { if(i >= m.morph.Count) break; m.methodInfo.Invoke(m.component, new object[]{i,m.morph[i]}); } //} // update transform to refresh scene if(!Application.isPlaying) m.obj.transform.position = new Vector3(m.obj.transform.position.x,m.obj.transform.position.y,m.obj.transform.position.z); }
public void addMorph(GameObject obj, MethodInfo methodInfo, Component component, List<float> morph) { foreach(Morph m in morphs) { if(m.obj == obj && m.component == component) { // found morph, blend m.blendMorph(morph); return; } } // add new morph Morph _m = new Morph(obj,methodInfo,component,morph); morphs.Add(_m); }
/// <summary> /// Load the mesh from a stream /// </summary> /// <param name="filename">The filename and path of the file containing the mesh data</param> public virtual void LoadMesh(string filename) { using(FileStream meshData = new FileStream(filename, FileMode.Open, FileAccess.Read)) using (EndianAwareBinaryReader reader = new EndianAwareBinaryReader(meshData)) { Header = TrimAt0(reader.ReadString(24)); if (!String.Equals(Header, MeshHeader)) throw new FileLoadException("Unrecognized mesh format"); // Populate base mesh parameters HasWeights = (reader.ReadByte() != 0); HasDetailTexCoords = (reader.ReadByte() != 0); Position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); RotationAngles = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); /* RotationOrder = */ reader.ReadByte(); Scale = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); // Populate the vertex array NumVertices = reader.ReadUInt16(); Vertices = new Vertex[NumVertices]; for (int i = 0; i < NumVertices; i++) Vertices[i].Coord = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); for (int i = 0; i < NumVertices; i++) Vertices[i].Normal = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); for (int i = 0; i < NumVertices; i++) Vertices[i].BiNormal = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); for (int i = 0; i < NumVertices; i++) Vertices[i].TexCoord = new Vector2(reader.ReadSingle(), reader.ReadSingle()); if (HasDetailTexCoords) { for (int i = 0; i < NumVertices; i++) Vertices[i].DetailTexCoord = new Vector2(reader.ReadSingle(), reader.ReadSingle()); } if (HasWeights) { for (int i = 0; i < NumVertices; i++) Vertices[i].Weight = reader.ReadSingle(); } NumFaces = reader.ReadUInt16(); Faces = new Face[NumFaces]; for (int i = 0; i < NumFaces; i++) Faces[i].Indices = new[] { reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16() }; if (HasWeights) { NumSkinJoints = reader.ReadUInt16(); SkinJoints = new string[NumSkinJoints]; for (int i = 0; i < NumSkinJoints; i++) { SkinJoints[i] = TrimAt0(reader.ReadString(64)); } } else { NumSkinJoints = 0; SkinJoints = new string[0]; } // Grab morphs List<Morph> morphs = new List<Morph>(); string morphName = TrimAt0(reader.ReadString(64)); while (morphName != MorphFooter) { if (reader.BaseStream.Position + 48 >= reader.BaseStream.Length) throw new FileLoadException("Encountered end of file while parsing morphs"); Morph morph = new Morph(); morph.Name = morphName; morph.NumVertices = reader.ReadInt32(); morph.Vertices = new MorphVertex[morph.NumVertices]; for (int i = 0; i < morph.NumVertices; i++) { morph.Vertices[i].VertexIndex = reader.ReadUInt32(); morph.Vertices[i].Coord = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); morph.Vertices[i].Normal = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); morph.Vertices[i].BiNormal = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); morph.Vertices[i].TexCoord = new Vector2(reader.ReadSingle(), reader.ReadSingle()); } morphs.Add(morph); // Grab the next name morphName = TrimAt0(reader.ReadString(64)); } Morphs = morphs.ToArray(); // Check if there are remaps or if we're at the end of the file if (reader.BaseStream.Position < reader.BaseStream.Length - 1) { NumRemaps = reader.ReadInt32(); VertexRemaps = new VertexRemap[NumRemaps]; for (int i = 0; i < NumRemaps; i++) { VertexRemaps[i].RemapSource = reader.ReadInt32(); VertexRemaps[i].RemapDestination = reader.ReadInt32(); } } else { NumRemaps = 0; VertexRemaps = new VertexRemap[0]; } } // uncompress the skin weights if (Skeleton != null) { // some meshes aren't weighted, which doesn't make much sense. // we check for left and right eyeballs, and assign them a 100% // to their respective bone List<string> expandedJointList = Skeleton.BuildExpandedJointList(SkinJoints); if (expandedJointList.Count == 0) { if (Name == "eyeBallLeftMesh") { expandedJointList.AddRange(new[] { "mEyeLeft", "mSkull" }); } else if (Name == "eyeBallRightMesh") { expandedJointList.AddRange(new[] { "mEyeRight", "mSkull" }); } } if (expandedJointList.Count > 0) ExpandCompressedSkinWeights(expandedJointList); } }
/// <summary> /// Inserts the segments and boundaries in to the output phonetic shape. /// </summary> /// <param name="match">The match.</param> /// <param name="input">The input word synthesis.</param> /// <param name="output">The output word synthesis.</param> /// <param name="morpheme">The morpheme info.</param> public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph) { Morph morph = null; if (allomorph != null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } for (PhoneticShapeNode node = m_pshape.Begin; node != m_pshape.Last; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); if (morph != null) { newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } else { newNode.Partition = -1; } output.Shape.Add(newNode); } }
public void morphmesh(Morph morph, float weight) { for (int v = 0; v < morph.NumVertices; v++) { MorphVertex mvx = morph.Vertices[v]; uint i = mvx.VertexIndex; MorphRenderData.Vertices[i * 3] = MorphRenderData.Vertices[i * 3] + mvx.Coord.X * weight; MorphRenderData.Vertices[(i * 3) + 1] = MorphRenderData.Vertices[i * 3 + 1] + mvx.Coord.Y * weight; MorphRenderData.Vertices[(i * 3) + 2] = MorphRenderData.Vertices[i * 3 + 2] + mvx.Coord.Z * weight; //MorphRenderData.Normals[i * 3] = MorphRenderData.Normals[i * 3] + mvx.Normal.X * weight; //MorphRenderData.Normals[(i * 3)+1] = MorphRenderData.Normals[(i * 3)+1] + mvx.Normal.Y * weight; //MorphRenderData.Normals[(i * 3)+2] = MorphRenderData.Normals[(i * 3)+2] + mvx.Normal.Z * weight; RenderData.TexCoords[i * 2] = OrigRenderData.TexCoords[i * 2] + mvx.TexCoord.X * weight; RenderData.TexCoords[(i * 2) + 1] = OrigRenderData.TexCoords[i * 2 + 1] + mvx.TexCoord.Y * weight; } }