public RopeData(UltimateRope rope) { m_rope = rope; m_hashFieldName2Value = new Dictionary<string, object>(); m_aLinkTransformInfo = new TransformInfo[rope.TotalLinks]; m_transformInfoSegments = new TransformInfo[rope.RopeNodes.Count]; m_bSkin = rope.GetComponent<SkinnedMeshRenderer>() != null; if(m_bSkin) { SkinnedMeshRenderer skin = rope.GetComponent<SkinnedMeshRenderer>(); Mesh skinMesh = skin.sharedMesh; int nVertices = skin.sharedMesh.vertexCount; int nTrianglesRope = skin.sharedMesh.GetTriangles(0).Length; int nTrianglesSections = skin.sharedMesh.GetTriangles(1).Length; m_av3SkinVertices = new Vector3 [nVertices]; m_av2SkinMapping = new Vector2 [nVertices]; m_av4SkinTangents = skinMesh.tangents != null ? new Vector4[skinMesh.tangents.Length] : null; m_aSkinBoneWeights = new BoneWeight[nVertices]; m_anSkinTrianglesRope = new int [nTrianglesRope]; m_anSkinTrianglesSections = new int [nTrianglesSections]; m_amtxSkinBindPoses = new Matrix4x4 [skin.sharedMesh.bindposes.Length]; MakeSkinDeepCopy(skinMesh.vertices, skinMesh.uv, skinMesh.tangents, skinMesh.boneWeights, skinMesh.GetTriangles(0), skinMesh.GetTriangles(1), skinMesh.bindposes, m_av3SkinVertices, m_av2SkinMapping, m_av4SkinTangents, m_aSkinBoneWeights, m_anSkinTrianglesRope, m_anSkinTrianglesSections, m_amtxSkinBindPoses); } }
//When player comes to the room, add userTransformInfo. void OnPhotonPlayerConnected(PhotonPlayer newPlayer) { TransformInfo transformInfo = new TransformInfo(); if (userTransformInfo.ContainsKey(newPlayer.ID) == false) { userTransformInfo.Add(newPlayer.ID, transformInfo); } }
public void AddTransformRegex(string regex, string replaceText, string regexOptions) { Regex rx = new Regex(regex, ParseOptions(regexOptions)); TransformInfo ri = new TransformInfo(); ri.Regex = rx; ri.ReplaceText = replaceText; transforms.Add(ri); }
protected override float Score(EntityContext context) { TransformInfo info = context.agent.transformInfo; TransformInfo otherInfo = context.other.transformInfo; Vector3 toMe = otherInfo.DirectionTo(info); return(Vector3.Dot(otherInfo.forward, toMe)); }
IEnumerator Generate() { length = length; string newString = ""; char[] stringCharacters = currentString.ToCharArray(); for (int i = 0; i < stringCharacters.Length; i++) { char currentCharacter = stringCharacters[i]; if (rules.ContainsKey(currentCharacter)) { newString += rules[currentCharacter]; } else { newString += currentCharacter; } } currentString = newString; Debug.Log(currentString); stringCharacters = currentString.ToCharArray(); for (int i = 0; i < stringCharacters.Length; i++) { char currentCharacter = stringCharacters[i]; if (currentCharacter == 'F') { Vector3 initialPosition = transform.position; transform.Translate(Vector3.forward * length); Debug.DrawLine(initialPosition, transform.position, Color.white, 10000f, false); yield return(null); } else if (currentCharacter == '+') { transform.Rotate((angle * Vector3.up) + (distance * strength)); } else if (currentCharacter == '-') { transform.Rotate((-angle * Vector3.up) + (distance * strength)); } else if (currentCharacter == '[') { TransformInfo ti = new TransformInfo(); ti.position = transform.position; ti.rotation = transform.rotation; transformStack.Push(ti); } else if (currentCharacter == ']') { TransformInfo ti = transformStack.Pop(); transform.position = ti.position; transform.rotation = ti.rotation; } } isGenerating = false; }
public void SetTransformInfo(TransformInfo info) { var transform1 = transform; transform1.position = info.position; transform1.eulerAngles = info.rotation; transform1.localScale = info.scale; Init(); }
public static void SetTransformInfo(this Transform destination, ref TransformInfo transformInfo) { destination.parent = transformInfo.Parent; destination.position = transformInfo.Position; destination.rotation = transformInfo.Rotation; destination.localPosition = transformInfo.LocalPosition; destination.localRotation = transformInfo.LocalRotation; destination.localScale = transformInfo.Scale; }
void Init() { nodes = new List <TransformInfo>(); foreach (Transform child in transform) { TransformInfo nodeTransform = new TransformInfo(child, levelRoot); nodes.Add(nodeTransform); } }
// Start is called before the first frame update void Start() { numberOfBones = 6; // init bone references for (int i = 1; i <= numberOfBones; i++) { GameObject t = GameObject.Find("Bone_" + i); bones.Add(t); Transform tr = t.GetComponent <Transform>(); TransformInfo ti = new TransformInfo { pos = tr.localPosition, rotate = tr.localRotation, scale = tr.localScale }; originalTransform.Add(ti); } gBoneState = BoneState.ShowAll; // slider enable/disable slider = GameObject.Find("PinchSlider"); slider2 = GameObject.Find("PinchSliderHor"); // scale functions gScaleState = ScaleState.Original; // menus nearMenu = GameObject.Find("NearMenu"); handMenu = GameObject.Find("HandMenu"); //document slate docSlate = GameObject.Find("Slate"); Material firstPage = docSlate.transform.Find("ContentQuad").gameObject.GetComponent <Pages>().getMat(); docSlate.transform.Find("ContentQuad").gameObject.GetComponent <Renderer>().material = firstPage; docSlate.SetActive(false); GameObject bone_1_ref = GameObject.Find("Bone_1"); // bone manipulation components boneBoundingBox = bone_1_ref.transform.Find("BoneGroup").gameObject.GetComponent <BoundingBox>(); boneManipulationHandler = bone_1_ref.transform.Find("BoneGroup").gameObject.GetComponent <ManipulationHandler>(); // CT manipulation components ctBoundingBox = bone_1_ref.transform.Find("CTGroup").gameObject.GetComponent <BoundingBox>(); ctManipulationHandler = bone_1_ref.transform.Find("CTGroup").gameObject.GetComponent <ManipulationHandler>(); // group manipulation components allBoundingBox = bone_1_ref.GetComponent <BoundingBox>(); allManipulationHandler = bone_1_ref.GetComponent <ManipulationHandler>(); handMenu.SetActive(false); }
public override bool Tick() { TransformInfo trasformInfo = context.agent.transformInfo; TransformInfo targetTransformInfo = context.other.transformInfo; Vector3 toTarget = trasformInfo.DirectionTo(targetTransformInfo); context.agent.FlightSystem.SetTargetDirection(toTarget, ApproachType.Attack); context.agent.WeaponSystem.Fire(); return(false); }
public static void SaveTransform(ref Dictionary <string, object> dictionary, Transform transform, string key = "transform") { TransformInfo transformInfo = new TransformInfo { pos = transform.position, rot = transform.rotation, scale = transform.localScale, enabled = transform.gameObject.activeInHierarchy }; SaveValueToDictionary(ref dictionary, key, transformInfo); }
IEnumerator Generate() { length /= 2.0f; string newString = ""; for (int i = 0; i < currentString.Length; i++) { if (rules.ContainsKey(currentString[i])) { newString += rules[currentString[i]]; } else { newString += currentString[i]; } } currentString = newString; Debug.Log(currentString); for (int i = 0; i < currentString.Length; i++) { yield return(null); if (currentString[i] == 'F') { Vector3 InitialPos = transform.position; transform.Translate(Vector3.up * length); Debug.DrawLine(InitialPos, transform.position, Color.white, 10000f, false); } else if (currentString[i] == '+') { transform.Rotate(Vector3.forward * angle); } else if (currentString[i] == '-') { transform.Rotate(Vector3.forward * -angle); } else if (currentString[i] == '[') { TransformInfo ti = new TransformInfo(); ti.rotation = transform.rotation; ti.position = transform.position; transformStack.Push(ti); } else if (currentString[i] == ']') { TransformInfo ti = transformStack.Pop(); transform.position = ti.position; transform.rotation = ti.rotation; } } StartCoroutine(Generate()); }
//void DrawTree () { IEnumerator DrawTree() { Node currentNode = NodeToDraw; float currentBranchLength = branchLength; TransformInfo originalTransform = new TransformInfo(gameObject.transform.position, gameObject.transform.rotation); foreach (char c in encodedTree) { if (c == 'F' || c == 'G') { Vector3 initialPosition = gameObject.transform.position; gameObject.transform.Translate(Vector3.up * currentBranchLength); //Debug.DrawLine (initialPosition, gameObject.transform.position, Color.white, 100000f, false); currentNode.EndNode = gameObject.transform.position; currentNode = new Node(gameObject.transform.position, currentNode); } else if (c == '+') { gameObject.transform.Rotate(Vector3.right * (Random.value * (maxTurnAngle - minTurnAngle) + minTurnAngle)); } else if (c == '-') { gameObject.transform.Rotate(Vector3.right * -(Random.value * (maxTurnAngle - minTurnAngle) + minTurnAngle)); } else if (c == '[') { currentBranchLength *= lenghtMultiplier; transformStack.Push(new TransformInfo(gameObject.transform.position, gameObject.transform.rotation)); nodeStack.Push(new Node(gameObject.transform.position, currentNode)); } else if (c == ']') { currentBranchLength /= lenghtMultiplier; TransformInfo ti = transformStack.Pop(); gameObject.transform.position = ti.position; gameObject.transform.rotation = ti.rotation; currentNode = nodeStack.Pop(); } } Debug.Log("Depth: " + NodeToDraw.Depth()); Debug.Log("Nodes: " + NodeToDraw.NumberOfNodes()); gameObject.transform.position = originalTransform.position; gameObject.transform.rotation = originalTransform.rotation; //lineraze the node tree initDrawTreeLines(); //Draw it DrawTreeLines(); Debug.Log("total points: " + Node.totalNode(MainPointsList)); yield return(0); }
public void updateImage(TransformInfo transformInfo) { updateImage(); Vector3 pos = (currentSprite.pivot + currentSprite.offset); pos.x *= transformInfo.scale.x + transformInfo.offset.x; pos.y *= transformInfo.scale.y + transformInfo.offset.y; pos.z = imageReference.gameObject.transform.position.z; //imageReference.gameObject.transform.localPosition = pos; //imageReference.gameObject.transform.localScale = transformInfo.scale; }
TransformInfo[] BufferToInfo(MultiplayerFrameBufferObject frame) { TransformInfo[] info = new TransformInfo[replayController.playbackTransforms.Count]; for (int i = 0; i < info.Length; i++) { info[i] = new TransformInfo(this.skater.transform); info[i].position = frame.vectors[i]; info[i].rotation = frame.quaternions[i]; } return(info); }
internal Containers(BasicTransformContext context, int count) { for (int i = 0; i < count; i++) { TransformInfo ti = context.InputStack[i]; IStatement inputElement = ti.inputElement as IStatement; if (IsContainer(inputElement) && !context.InputAttributes.Has <ConvergenceLoop>(inputElement)) { inputs.Add(CreateContainer(inputElement)); outputs.Add((IStatement)ti.PrimaryOutput); } } }
private void OnEntityArriving(Evt_EntityArriving evt) { TransformInfo transformInfo = GameData.Instance.transformInfoMap[evt.entityId]; Vector3 position = transformInfo.position; Vector3 offset = (-transformInfo.forward * arrivalHyperspaceDistance); arrivals.Add(new Arrival(evt.entityId, position + offset)); GameData.Instance.transformInfoMap[evt.entityId] = new TransformInfo( transformInfo.entityId, position + offset, transformInfo.rotation ); }
TransformInfo[] CreateInfoArray(Vector3[] vectors, Quaternion[] quaternions) { TransformInfo[] info = new TransformInfo[replayController.playbackTransforms.Count]; for (int i = 0; i < info.Length; i++) { info[i] = new TransformInfo(this.skater.transform); info[i].position = vectors[i]; info[i].rotation = quaternions[i]; } return(info); }
// Start is called before the first frame update void Start() { numberOfBones = 6; numberOfAdjustedBones = 7; Debug.Log("Number of bones loaded: " + numberOfBones); Debug.Log("Number of adjusted bones loaded: " + numberOfAdjustedBones); // store the initial trasformations of bone fragements for (int i = 1; i <= numberOfBones; i++) { GameObject t = GameObject.Find("Bone_" + i); bones.Add(t); Transform tr = t.GetComponent <Transform>(); TransformInfo ti = new TransformInfo { pos = tr.localPosition, rotate = tr.localRotation, scale = tr.localScale }; originalTransform.Add(ti); } // store the initial trasformations of adjusted bone fragments for (int i = 1; i <= numberOfAdjustedBones; i++) { GameObject t = GameObject.Find("Bone_" + i + "_aligned"); adjustedBones.Add(t); Transform tr = t.GetComponent <Transform>(); TransformInfo ti = new TransformInfo { pos = tr.localPosition, rotate = tr.localRotation, scale = tr.localScale }; originalTransformAdjusted.Add(ti); } gBoneState = BoneState.ShowAll; // color mode init gColorState = ColorState.Select; // slider enable/disable slider = GameObject.Find("PinchSlider"); slider2 = GameObject.Find("PinchSliderHor"); // scale functions gScaleState = ScaleState.Original; }
Widget _buildItem(BuildContext context, int index) { return(new AnimatedBuilder( animation: _pageController, builder: (BuildContext c, Widget w) => { int renderIndex = _pageController.getRenderIndexFromRealIndex(index); Widget child = null; if (widget.itemBuilder != null) { child = widget.itemBuilder(context, renderIndex); } if (child == null) { child = new Container(); } if (_size == null) { return child ?? new Container(); } float position; float page = _pageController.realPage; if (_transformer.reverse) { position = page - index; } else { position = index - page; } position *= widget.viewportFraction; TransformInfo info = new TransformInfo( index: renderIndex, width: _size.width, height: _size.height, position: Mathf.Clamp(position, -1.0f, 1.0f), activeIndex: _pageController.getRenderIndexFromRealIndex(_activeIndex), fromIndex: _fromIndex, forward: _pageController.position.pixels - _currentPixels >= 0, done: _done, scrollDirection: widget.scrollDirection, viewportFraction: widget.viewportFraction); return _transformer.transformm(child, info); })); }
private void OnEntityDeparting(Evt_EntityDeparting evt) { int idx = actives.IndexOf(evt.entityId); if (idx >= 0) { actives.RemoveAt(idx); } TransformInfo transformInfo = GameData.Instance.transformInfoMap[evt.entityId]; Vector3 offset = (transformInfo.forward * departureHyperspaceDistance); departures.Add(new Departure(evt.entityId, transformInfo.position + offset)); }
void Yourinfo(Message message) //受け取った情報を格納 { TransformInfo datas = (TransformInfo)message; cnt = datas.image_num; px = datas.position_x; py = datas.position_y; pz = datas.position_z; rx = datas.rotation_x; ry = datas.rotation_y; rz = datas.rotation_z; no_check_topic = true; }
/// <summary> /// The containers of the current transform context. /// </summary> /// <param name="context"></param> /// <param name="loopVarsHaveOneContainer"></param> internal Containers(BasicTransformContext context, bool loopVarsHaveOneContainer = true) // : this(FindContainers(context)) { if (loopVarsHaveOneContainer) { int ancIndex2 = Recognizer.GetAncestorIndexOfLoopBeingInitialized(context); if (ancIndex2 != -1) { // For a loop variable, the loop is the only container. // This is needed to allow re-ordering nested loops. Otherwise, the inner loop variable would always require the outer loop around it. // It is also useful for ignoring conditioned loops. TransformInfo ti = context.InputStack[ancIndex2]; IForStatement ifs = (IForStatement)ti.inputElement; IStatement container = CreateContainer(ifs); inputs.Add(container); #if ignoreOutput outputs.Add(container); #else outputs.Add((IStatement)ti.PrimaryOutput); #endif var loopVar = Recognizer.LoopVariable(ifs); bool mustRemove = false; if (!context.InputAttributes.Has <Containers>(loopVar)) { context.InputAttributes.Set(loopVar, this); mustRemove = true; } var initExpr = ((IExpressionStatement)ifs.Initializer).Expression; this.AddContainersNeededForExpression(context, initExpr); this.AddContainersNeededForExpression(context, ifs.Condition); if (mustRemove) { context.InputAttributes.Remove <Containers>(loopVar); } return; } } // exclude the current statement. int ancIndex = context.FindAncestorIndex <IStatement>(); for (int i = 0; i < ancIndex; i++) { TransformInfo ti = context.InputStack[i]; IStatement inputElement = ti.inputElement as IStatement; if (IsContainer(inputElement) && !context.InputAttributes.Has <ConvergenceLoop>(inputElement)) { inputs.Add(CreateContainer(inputElement)); outputs.Add((IStatement)ti.PrimaryOutput); } } }
public static void LoadTransform(ref Dictionary <string, object> dictionary, Transform transform, string key = "transform") { TransformInfo transformInfo = GetValueFromDictionary <TransformInfo>(ref dictionary, key); if (transformInfo != null) { transform.position = transformInfo.pos; transform.rotation = transformInfo.rot; transform.localScale = transformInfo.scale; if (!transformInfo.enabled) { Debug.Log("Test"); } transform.gameObject.SetActive(transformInfo.enabled); } }
void Awake() { this.transformation = GetComponent <TransformInfo>(); spriteRenderer = GetComponent <SpriteRenderer>(); //Se convierten en una lista de frames las secuencias for (int i = 0; i < sequences.Count; i++) { sequences[i].imageReference = spriteRenderer; sequences[i].FPSUpdate(); sequences[i].readAndFillFrames(); } //Inicializamos la imagen con el primer frame de la primer secuencia this.sequences[currentSequenceIndex].updateImage(this.transformation); }
private RffTransform(IHost host, ModelLoadContext ctx, IDataView input) : base(host, ctx, input, TestColumnType) { // *** Binary format *** // <prefix handled in static Create method> // <base> // transformInfos Host.AssertNonEmpty(Infos); _transformInfos = new TransformInfo[Infos.Length]; for (int i = 0; i < Infos.Length; i++) { _transformInfos[i] = new TransformInfo(Host, ctx, Infos[i].TypeSrc.ValueCount, string.Format("MatrixGenerator{0}", i)); } _types = InitColumnTypes(); }
internal static Containers InsideOf(BasicTransformContext context, int exclude) { Containers containers = new Containers(); for (int i = exclude + 1; i < context.InputStack.Count; i++) { TransformInfo ti = context.InputStack[i]; IStatement inputElement = ti.inputElement as IStatement; if (IsContainer(inputElement) && !context.InputAttributes.Has <ConvergenceLoop>(inputElement)) { containers.inputs.Add(CreateContainer(inputElement)); containers.outputs.Add((IStatement)ti.PrimaryOutput); } } return(containers); }
public void PlayForLevel(Levels level) { if (levelPaths.ContainsKey(level)) { currentlyPlayingLevel = level; timeSinceStateChange = 0f; initialCameraTransform = new TransformInfo(flythroughCamera.transform); levelPaths[level].Play(); flythroughCameraAnimator.enabled = true; flythroughCameraAnimator.SetBool(level.ToName(), true); } else { Debug.LogWarning($"Attempting to play for scene with no CameraFlythrough set: {level}"); } }
private PcaTransformer(IHost host, ModelLoadContext ctx) : base(host, ctx) { Host.AssertValue(ctx); // *** Binary format *** // <prefix handled in static Create method> // <base> // transformInfos Host.AssertNonEmpty(ColumnPairs); _numColumns = ColumnPairs.Length; _transformInfos = new TransformInfo[_numColumns]; for (int i = 0; i < _numColumns; i++) { _transformInfos[i] = new TransformInfo(ctx); } }
private PcaTransform(IHost host, ModelLoadContext ctx, IDataView input) : base(host, ctx, input, TestIsFloatItem) { Host.AssertValue(ctx); // *** Binary format *** // <prefix handled in static Create method> // <base> // transformInfos Host.AssertNonEmpty(Infos); _transformInfos = new TransformInfo[Infos.Length]; for (int i = 0; i < Infos.Length; i++) { _transformInfos[i] = new TransformInfo(ctx, Infos[i].TypeSrc.ValueCount); } _types = InitColumnTypes(); }
private void ApplyForceSub(GameObject part, Vector3 center, Vector3 dir, float factor) { TransformInfo info = new TransformInfo(); info.pos = part.transform.position; info.angle = part.transform.eulerAngles; info.scale = part.transform.localScale; Vector3 pos = part.transform.position; //pos.x += UnityEngine.Random.Range(-0.5f,0.5f); pos.y += UnityEngine.Random.Range(0.0f, 1.0f); //pos.z += UnityEngine.Random.Range(-0.5f,0.5f); part.transform.SetPosition(pos); Rigidbody rb = part.GetComponent <Rigidbody>(); if (rb == null) { rb = part.AddComponent <Rigidbody>(); } // rb.constraints=RigidbodyConstraints.FreezePositionX | // RigidbodyConstraints.FreezePositionY | // RigidbodyConstraints.FreezePositionZ; //A low Drag value makes an object seem heavy. A high one makes it seem light. Typical values for Drag are between .001 (solid block of metal) and 10 (feather). //阻力越大,物体看起来越轻,阻力越小,物体看起来越重。阻力的典型值在0.001(砖头)到10(羽毛)之间。 //rb.drag = 1000000.0f; //rb.angularDrag = 1000000.0f; //rb.useGravity = false; info.oldcollider = part.GetComponent <Collider>(); if (info.oldcollider != null) { info.oldcolliderenable = info.oldcollider.enabled; info.oldcollider.enabled = false; } SphereCollider collider = part.AddComponent <SphereCollider>(); collider.radius *= factor; info.newcollider = collider; AnimParts[part] = info; rb.AddForce(dir); }
public void AddTransformRegex (string regex, string replaceText, string regexOptions) { Regex rx = new Regex (regex, ParseOptions (regexOptions)); TransformInfo ri = new TransformInfo (); ri.Regex = rx; ri.ReplaceText = replaceText; transforms.Add (ri); }
void Start() { //Reconnect network. PhotonNetwork.isMessageQueueRunning = true; //isServer? create server object : create client object. isServer = (bool)PhotonNetwork.player.customProperties ["ISSERVER"]; if (isServer == true) { Debug.Log ("I am SERVER"); PhotonNetwork.Instantiate ("ServerObject", new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity, 0); } else { StartCoroutine (this.CreateLeaf ()); } //For playing background music audioSource = gameObject.GetComponent<AudioSource> (); //To save each object's position. //If it's not my object, refer to userTransformInfo[] and change each position. userTransformInfo=new Dictionary<int, TransformInfo>(); PhotonPlayer[] players = PhotonNetwork.playerList; foreach (PhotonPlayer player in players) { TransformInfo transformInfo = new TransformInfo (); if(userTransformInfo.ContainsKey(player.ID)==false) userTransformInfo.Add (player.ID, transformInfo); } }
//When player comes to the room, add userTransformInfo. void OnPhotonPlayerConnected(PhotonPlayer newPlayer) { TransformInfo transformInfo = new TransformInfo (); if(userTransformInfo.ContainsKey(newPlayer.ID)==false) userTransformInfo.Add (newPlayer.ID, transformInfo); }