private void PlaceRegionFurnitures(Region r, RegionFurnitures furnitures, int amount = -1) { /*if (furnitures.prefab == null || furnitures.spawnTransforms == null || furnitures.spawnTransforms.Count == 0) * throw new Exception("Place Region Furnitures - " + "No furniture prefab or spawn transforms have been assigned! " + furnitures.ToString()); */ GameObject prefab = furnitures.prefab; if (prefab == null) { prefab = new GameObject(furnitures.name); } Vector3 basePos = r.innerBounds.center; List <LocalTransform> localTransforms = new List <LocalTransform>(furnitures.spawnTransforms); while (localTransforms.Count > 0 && (amount > 0 || amount == -1)) { LocalTransform lt = localTransforms[Random.Range(0, localTransforms.Count)]; localTransforms.Remove(lt); GameObject placedFurniture = Instantiate(prefab, basePos + lt.position, lt.rotation, furnitureParent.transform); placedFurniture.transform.localScale = lt.scale; r.placedFurnitures.Add(placedFurniture); if (amount > 0) { amount--; } } }
public static LocalTransform Lerp(LocalTransform a, LocalTransform b, float t) { LocalTransform result = new LocalTransform(); result.position = Vector3.Lerp(a.position, b.position, t); result.scale = Vector3.Lerp(a.scale, b.scale, t); result.rotation = Quaternion.Lerp(a.rotation, b.rotation, t); return result; }
//-------------------------------------------------------------------------------- #region MonoBehaviour Events void Update() { if (mode == Mode.Done) { return; } float t = (Time.time - startTime) / transitionTime; if (transitionTime <= 0) { t = 1; } if (mode == Mode.GoingAtoB) { LocalTransform.LerpAndApply(transformA, transformB, t, transform); } else { LocalTransform.LerpAndApply(transformB, transformA, t, transform); } if (t >= 1) { mode = Mode.Done; } }
/// <summary> /// 描画関係の初期化を行います。 /// </summary> private void InitializeDraw() { InitializeBounds(); InitializePieceMesh(); // ハンドラの設定を行います。 AddPropertyChangedHandler("BoardBitmap", BoardBitmapUpdated); AddPropertyChangedHandler("PieceBitmap", PieceBitmapUpdated); AddPropertyChangedHandler("PieceBoxBitmap", PieceBoxBitmapUpdated); // デフォルトのプロパティ値も設定します。 BoardBitmap = DefaultBoardBitmap; PieceBoxBitmap = DefaultPieceBoxBitmap; PieceBitmap = DefaultPieceBitmap; IsTimeVisible = true; TebanPlayerNameBackgroundColor = Color.FromArgb(128, Color.White); UnTebanPlayerNameBackgroundColor = Color.FromArgb(32, Color.White); TimeBackgroundColor = Color.FromArgb(128, Color.Black); IsArrowVisible = true; ArrowMoveList = new List <Move>(); AutoPlayColor = Color.FromArgb(96, 0, 24, 86); AutoPlayOpacity = 0.0; BoardOpacity = 1.0; LocalTransform.Scale(1.0 / 640.0, 1.0 / 360.0, 1.0); }
public static LocalTransform Lerp(LocalTransform a, LocalTransform b, float t) { LocalTransform result = new LocalTransform(); result.position = Vector3.Lerp(a.position, b.position, t); result.scale = Vector3.Lerp(a.scale, b.scale, t); result.rotation = Quaternion.Lerp(a.rotation, b.rotation, t); return(result); }
virtual public void AddPosition(Vector3 localPosition, Quaternion localRotation, Vector3 localScale) { LocalTransform transform = new LocalTransform(); transform.position = localPosition; transform.rotation = localRotation; transform.scale = localScale; spawnTransforms.Add(transform); }
void Start() { LocalTransform local = new LocalTransform(); tf = transform; foreach (var component in listOfComponents.availableComponents) { var preview = Instantiate(previewPrefab, scrollViewContent); component.GenerateSampleComponent(preview.GetComponent <ComponentPreview>()); } }
public override void Save(SaveContext saveContext) { var utility = saveContext.Utility; // Update the internal OriginalOffset; we'll need this to resolve the reference bones later OriginalOffset = utility.GetWritePosition(); // Unlike most objects loaded from a DICT, bones DO NOT use the stndard // Type/Magic/Revision/Name/MetaData header and instead do their own thing... // (in short, not calling base.Save() here!!) saveContext.StringTable.EnqueueAndWriteTempRel(Name); utility.Write((uint)Flags); utility.Write(Index); // Fix ParentIndex in case it's wrong (note that Indexes MUST be correct before Save()!) ParentIndex = Parent?.Index ?? -1; // -1 is used if null (root bone) utility.Write(ParentIndex); saveContext.WritePointerPlaceholder(Parent); saveContext.WritePointerPlaceholder(Child); saveContext.WritePointerPlaceholder(PrevSibling); saveContext.WritePointerPlaceholder(NextSibling); Scale.Write(utility); Rotation.Write(utility); Translation.Write(utility); LocalTransform.Write(utility); WorldTransform.Write(utility); InvWorldTransform.Write(utility); utility.Write((uint)BillboardMode); saveContext.WriteDICTPointerPlaceholder(MetaDatas); ///////////////////////////// // Begin saving dependent data saveContext.SaveAndMarkReference(MetaDatas); MetaDatas?.SaveEntries(saveContext); }
/// <summary> /// Efetuar uma transformação local utilizando vizinhança Von Neumann (4-conexa). /// Mais performática, mas possível custo de qualidade. /// </summary> /// <param name="x">Coordenada X do ponto central.</param> /// <param name="y">Coordenada Y do ponto central.</param> /// <param name="heights">Mapa de alturas a ser transformado.</param> /// <param name="transform">Função de transformação.</param> protected void VonNeumannTransform(int x, int y, float[,] heights, LocalTransform transform) { if (x != 0) { transform(ref heights[x, y], ref heights[x - 1, y]); } if (y != 0) { transform(ref heights[x, y], ref heights[x, y - 1]); } if (x != heights.GetLength(0) - 1) { transform(ref heights[x, y], ref heights[x + 1, y]); } if (y != heights.GetLength(1) - 1) { transform(ref heights[x, y], ref heights[x, y + 1]); } }
public NodeAsset(string id) : base(id) { Transform = new LocalTransform(); }
public static void LerpAndApply(LocalTransform a, LocalTransform b, float t, Transform applyTo) { applyTo.localPosition = Vector3.Lerp(a.position, b.position, t); applyTo.localScale = Vector3.Lerp(a.scale, b.scale, t); applyTo.localRotation = Quaternion.Lerp(a.rotation, b.rotation, t); }
public void ComputeWorldTransform(Transform parent) { _worldTransform = LocalTransform.Combine(parent); _isWorldTransformDirty = false; }
private void GlobalToLocal() { LocalTransform.SetPosition(GlobalTransform.Position); LocalTransform.SetRotation(GlobalTransform.Rotation); LocalTransform.SetVelocity(GlobalTransform.Velocity); }