public static void CreateMorphItem(int x, int y, int inactiveItemID, int activeItemID, int range, int hue) { MorphItem item = new MorphItem(inactiveItemID, activeItemID, range); item.Hue = hue; item.MoveToWorld(new Point3D(x, y, -1), Map.Malas); }
Vector3[] morph(Vector3[] startingMesh, List <MorphItem> morphArray) { // The incoming variable is a special array, containing a lot of data. // Morph_Array [grouping number] [0] = morph array // [1] = link array // [2] = power level applied. Vector3[] workMesh = startingMesh; for (int morphItem = 0; morphItem < morphArray.Count; morphItem++) { // okay, we are now going to apply each animation at the proper precentage to the model. MorphItem m = morphArray[morphItem]; Vector3[] shapeMorph = m.ShapeMorph; int[] shapeLink = m.ShapeLink; float shapePower = m.ShapePower; for (int morphVerts = 0; morphVerts < shapeLink.Length; morphVerts++) { // In this case, we're only looping the vertices that MOVE. All the rest are ignored, and this runs faster that way. // You only pay for the parts you morph. workMesh[shapeLink[morphVerts]] += shapeMorph[morphVerts] * shapePower; } } // And here we have the final builtin array with the mesh shape we want! return(workMesh); }
void setShapeSet(string morphName, float morphLevel) { // Morph_Name: Name of the morph to apply. // Morph_Level: How much to apply it. 1.0 is fully. // With this, you can set a morph shape into the default mesh. // This means no FPS cost for it to be visible, but a large cost to set it. // Do NOT call this per frame. Use the mm_Morph set of functions to animate getting to a shape, and then kill the morph while setting the shape. // It stacks, so each new shape added is added to all the previous ones. int Found = FindName(diffMaps, morphName); if (Found != -1) { // group up the data for the morph into an morph item array. MorphItem morphItem = new MorphItem(); morphItem.ShapeMorph = listToArray(morphShapesData[Found]); // section 0 morphItem.ShapeLink = listToArray(morphShapesLinks[Found]); // section 1 morphItem.ShapePower = morphLevel; // section 2 // And drop it into slot zero... List <MorphItem> morphArray = new List <MorphItem> (); morphArray.Add(morphItem); // slot 0 mesh.vertices = morph(modMesh, morphArray); RecalculateNormals(); } }
public static void CreateMorphItem(int x, int y, int z, int inactiveItemID, int activeItemID, int range) { if (FindMorphItem(x, y, z, inactiveItemID, activeItemID)) { return; } MorphItem item = new MorphItem(inactiveItemID, activeItemID, range, 3); item.MoveToWorld(new Point3D(x, y, z), Map.Felucca); m_Count++; }
public static void CreateBigTeleporterItem(int x, int y, bool reverse) { if (FindMorphItem(x, y, 0, reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC)) { return; } MorphItem item = new MorphItem(reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC, 1, 3); item.MoveToWorld(new Point3D(x, y, 0), Map.Felucca); m_Count++; }
public static void CreateApproachLight(int x, int y, int z, int off, int on, LightType light) { if (FindMorphItem(x, y, z, off, on)) { return; } MorphItem item = new MorphItem(off, on, 2, 3); item.Light = light; item.MoveToWorld(new Point3D(x, y, z), Map.Felucca); m_Count++; }
public static void CreateMorphItem(int x, int y, int inactiveItemID, int activeItemID, int range, int hue) { var loc = new Point3D(x, y, -1); var map = Map.Malas; if (!MythikStaticValues.UpdateLoc(ref loc, ref map)) { return; } MorphItem item = new MorphItem(inactiveItemID, activeItemID, range); item.Hue = hue; item.MoveToWorld(loc, map); }
public static void CreateMorphItem(int x, int y, int inactiveItemID, int activeItemID, int range, int hue) { var p = new Point3D(x, y, -1); MorphItem item; if (FindObject(Map.Malas, p, 0, out item)) { item.Delete(); } item = new MorphItem(inactiveItemID, activeItemID, range); item.MoveToWorld(p, Map.Malas); item.Hue = hue; WeakEntityCollection.Add("doom", item); }
List <MorphItem> GroupMorphs(List <MorphItem> morphArray) { // Here is where we make the list of morphs to apply to the mesh from the Morphs currently active. for (int CAMLoop = 0; CAMLoop < currentlyActiveMorphs.Count; CAMLoop++) { int morphNumber = currentlyActiveMorphs[CAMLoop].link; // How much should we morph it? float timeSpot = Mathf.InverseLerp(currentlyActiveMorphs[CAMLoop].CAMStartTime, currentlyActiveMorphs[CAMLoop].CAMStartTime + currentlyActiveMorphs[CAMLoop].CAMTimeFrame, Time.realtimeSinceStartup); var morphShapesPower = Mathf.Lerp(currentlyActiveMorphs[CAMLoop].CAMStartLevel, currentlyActiveMorphs[CAMLoop].CAMEndLevel, timeSpot); if (Mathf.Approximately(morphShapesPower, 0.0f)) { if (currentlyActiveMorphs[CAMLoop].CAMEnd == true) { currentlyActiveMorphs.RemoveAt(CAMLoop); // Watch this! Make sure the for loop is actually looking at the length attribute or you could wander straight into null territory. CAMLoop--; // Oh, and back it up one, we just deleted an entry, so we need to look at this slot number again. meshChanged = 2; } } else { morphShapesPower = morphShapesPower * diffMaps[morphNumber].multiplier; // group up the data for the morph into an morph item array. MorphItem morphItem = new MorphItem(); morphItem.ShapeMorph = listToArray(morphShapesData[morphNumber]); // section 0 morphItem.ShapeLink = listToArray(morphShapesLinks[morphNumber]); // section 1 morphItem.ShapePower = morphShapesPower; // section 2 morphArray.Add(morphItem); meshChanged = 2; } } return(morphArray); }
private void AddMorphItemsToComboList() { var coRepository = m_caches.MainCache.ServiceLocator.GetInstance<ICmObjectRepository>(); ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); MorphItem miPrev = new MorphItem(); m_morphItems.Sort(); foreach (MorphItem mi in m_morphItems) { ITsString tssToDisplay = null; int hvoPrimary = 0; // the key hvo associated with the combo item. tisb.Clear(); var morph = coRepository.GetObject(mi.m_hvoMorph); var le = morph.Owner as ILexEntry; if (mi.m_hvoSense > 0) { int hvoSense = mi.m_hvoSense; tisb.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsAnal); tisb.Append(" "); ITsString tssSense = TsStringUtils.MakeTss(mi.m_nameSense, m_caches.MainCache.DefaultAnalWs); tisb.AppendTsString(tssSense); tisb.Append(", "); string sPos = mi.m_nameMsa; if (sPos == null) sPos = ITextStrings.ksQuestions; // was "??", not "???" tisb.Append(sPos); tisb.Append(", "); // append lex entry form info tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsVern); tisb.AppendTsString(mi.m_name); tssToDisplay = tisb.GetString(); hvoPrimary = mi.m_hvoSense; tisb.Clear(); } else { hvoPrimary = mi.m_hvoMorph; // mi.m_hvoSense == 0 // Make a comboList item for adding a new sense to the LexEntry if (miPrev.m_hvoMorph != 0 && mi.m_hvoMorph == miPrev.m_hvoMorph && miPrev.m_hvoSense > 0) { // "Add New Sense..." // the comboList has already added selections for senses and lexEntry form // thus establishing the LexEntry the user may wish to "Add New Sense..." to. tisb.Clear(); tisb.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsUser); tisb.Append(ITextStrings.ksAddNewSense_); tssToDisplay = tisb.GetString(); } else { // "Add New Sense for {0}" // (EricP) This path means the current form matches an entry that (strangely enough) // doesn't have any senses so we need to add the LexEntry form into the string, // so the user knows what Entry they'll be adding the new sense to. Debug.Assert(le.SensesOS.Count == 0, "Expected LexEntry to have no senses."); string sFmt = ITextStrings.ksAddNewSenseForX_; tisb.Clear(); tisb.SetIntPropValues( (int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvOff); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsUser); tisb.Append(sFmt); ITsString tss = tisb.GetString(); int ich = sFmt.IndexOf("{0}"); if (ich >= 0) { ITsStrBldr tsbT = tss.GetBldr(); tsbT.ReplaceTsString(ich, ich + "{0}".Length, mi.m_name); tss = tsbT.GetString(); } tssToDisplay = tss; } } // keep track of the previous MorphItem to track context. ComboList.Items.Add(new MorphComboItem(mi, tssToDisplay, new EventHandler(HandleSelectMorphComboItem), hvoPrimary)); miPrev = mi; } SyncItemsToMorphItems(); }
internal MorphComboItem(MorphItem mi, ITsString tssDisplay, EventHandler handleMorphComboItem, int hvoPrimary) : base(tssDisplay, handleMorphComboItem, hvoPrimary, 0) { m_mi = mi; }
/// <summary> /// Determines if the two MorphItems are based on the same objects, ignoring string values. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> bool HaveSameObjs(MorphItem x, MorphItem y) { return x.m_hvoSense == y.m_hvoSense && x.m_hvoMainEntryOfVariant == y.m_hvoMainEntryOfVariant && x.m_hvoMorph == y.m_hvoMorph && x.m_hvoMsa == y.m_hvoMsa && x.m_inflType == y.m_inflType && x.m_entryRef == y.m_entryRef; }
List <MorphItem> GroupAnimations(List <MorphItem> morphArray) { // Here is where we make the list of morphs to apply to the mesh from the Animations currently active. for (int CAALoop = 0; CAALoop < currentlyActiveAnimations.Count; CAALoop++) { bool removeanimation = false; int animIndex = currentlyActiveAnimations[CAALoop].link; int Frame = Time2Frame(Time.realtimeSinceStartup - currentlyActiveAnimations[CAALoop].CAAStartTime, currentlyActiveAnimations[CAALoop].CAASpeed); int endFrame = morphAnimationData[animIndex].Count - 4; // Remember Animation styles? This is where we process them. if (Frame > endFrame) { int Style = currentlyActiveAnimations[CAALoop].CAAStyle; if (Style == AnimationStyles.end) { currentlyActiveAnimations[CAALoop].CAAEndTime = Time.realtimeSinceStartup - 0.002f; currentlyActiveAnimations[CAALoop].CAAFadeTime = Time.realtimeSinceStartup - 0.001f; Frame = endFrame; } else if (Style == AnimationStyles.freeze) { Frame = endFrame; } else if (Style == AnimationStyles.loop) { Frame = 0; currentlyActiveAnimations[CAALoop].CAAStartTime = Time.realtimeSinceStartup; } else if (Style == AnimationStyles.pingPong) { if (Frame > endFrame * 2) { Frame = 0; currentlyActiveAnimations[CAALoop].CAAStartTime = Time.realtimeSinceStartup; } Frame = (int)Mathf.Round(Mathf.PingPong(Frame, endFrame)); } } // And the code for stopping an animatio and fading out over time while doing so. float fadeOut = 1.0f; if (currentlyActiveAnimations[CAALoop].CAAEndTime > 0) { fadeOut = Mathf.InverseLerp(currentlyActiveAnimations[CAALoop].CAAFadeTime, currentlyActiveAnimations[CAALoop].CAAEndTime, Time.realtimeSinceStartup); if (Time.realtimeSinceStartup > currentlyActiveAnimations[CAALoop].CAAFadeTime) { removeanimation = true; } } // Grabbing the data for adding to the morph list... List <string> morphIndexes = morphAnimationData[animIndex][1]; // Indexes of the Diffmaps we're using. List <string> morphPowers = morphAnimationData[animIndex][2]; // frames start on line 3 (from line 0)... List <string> morphLevels = morphAnimationData[animIndex][Frame + 3]; // frames start on line 3 (from line 0)... for (int MADLoop = 0; MADLoop < morphIndexes.Count; MADLoop++) { float morphPower = float.Parse(morphPowers[MADLoop]) * float.Parse(morphLevels[MADLoop]) * fadeOut; if (!Mathf.Approximately(morphPower, 0.0f)) { MorphItem morphItem = new MorphItem(); morphItem.ShapeMorph = listToArray(morphShapesData[int.Parse(morphIndexes[MADLoop])]); // section 0 morphItem.ShapeLink = listToArray(morphShapesLinks[int.Parse(morphIndexes[MADLoop])]); // section 1 morphItem.ShapePower = morphPower; // section 2 morphArray.Add(morphItem); meshChanged = 2; } } // Oh, if an animation is done, we take care of it here... if (removeanimation == true) { currentlyActiveAnimations.RemoveAt(CAALoop); // Watch this! Make sure the for loop is actually looking at the length attribute or you could wander straight into null territory. CAALoop--; meshChanged = 2; Frame = 0; } } // Well, were done with the array. return it. return(morphArray); }
/// <summary> /// /// </summary> /// <param name="hvoMorph"></param> /// <param name="le">the entry used in the morph bundle (for sense info). typically /// this is an owner of hvoMorph, but if not, it most likely has hvoMorph linked as its variant.</param> /// <param name="fMorphIsVariantOfEntry">indicates whether the given morph is a variant of the given entry(le) or /// one of its senses</param> private void BuildMorphItemsFromEntry(int hvoMorph, ILexEntry le, ILexEntryRef ler) { IMoForm mf = MoForm.CreateFromDBObject(m_caches.MainCache, hvoMorph); int hvoLexEntry = 0; if (le != null) hvoLexEntry = le.Hvo; ITsString tssName = null; if (le != null) { tssName = InterlinDocChild.GetLexEntryTss(m_caches.MainCache, le.Hvo, m_wsVern, ler); } else { // looks like we're not in a good state, so just use the form for the name. int wsActual; tssName = mf.Form.GetAlternativeOrBestTss(m_wsVern, out wsActual); } string sql2 = string.Format("select SenseId from fnGetSensesInEntry$({0})", hvoLexEntry); List<int> hvoSenses = DbOps.ReadIntsFromCommand(m_caches.MainCache, sql2, null); if (hvoSenses.Count > 0) { // Populate morphItems with Sense/Msa level specifics for (int i = 0; i < hvoSenses.Count; ++i) { int hvoSense = hvoSenses[i]; ITsString tssSense = m_caches.MainCache.MainCacheAccessor.get_MultiStringAlt( (int)hvoSense, (int)LexSense.LexSenseTags.kflidGloss, m_caches.MainCache.DefaultAnalWs); if (tssSense.Length == 0) { // If it doesn't have a gloss (e.g., from Categorised Entry), use the definition. tssSense = m_caches.MainCache.MainCacheAccessor.get_MultiStringAlt( (int)hvoSense, (int)LexSense.LexSenseTags.kflidDefinition, m_caches.MainCache.DefaultAnalWs); } ILexSense sense = LexSense.CreateFromDBObject( m_caches.MainCache, (int)hvoSense); IMoMorphSynAnalysis msa = sense.MorphoSyntaxAnalysisRA; string msaText = null; if (msa != null) msaText = msa.InterlinearName; MorphItem mi = new MorphItem(hvoMorph, ler != null ? hvoLexEntry : 0, tssName, hvoSense, tssSense.Text, sense.MorphoSyntaxAnalysisRAHvo, msaText); m_morphItems.Add(mi); } } // Make a LexEntry level item m_morphItems.Add(new MorphItem(hvoMorph, ler != null ? hvoLexEntry : 0, tssName)); }