struct for hold four floats
예제 #1
0
    void Update()
    {
        if (_Reader != null)
        {
            var frame = _Reader.AcquireLatestFrame();
            if (frame != null)
            {
                if (_Data == null)
                {
                    _Data = new Body[_Sensor.BodyFrameSource.BodyCount];
                }

                frame.GetAndRefreshBodyData(_Data);

                if (frame != null)
                {
                    _bodyFrameFloor = new Floor(frame.FloorClipPlane);
                    floorVector     = new UnityEngine.Vector4(frame.FloorClipPlane.X, frame.FloorClipPlane.Y, frame.FloorClipPlane.Z, frame.FloorClipPlane.W);
                }

                frame.Dispose();
                frame = null;
            }
        }
    }
예제 #2
0
 /// <summary>
 /// cut mesh by plane
 /// </summary>
 /// <param name="mesh">mesh to cut</param>
 /// <param name="meshTransform">transformation of the mesh</param>
 /// <param name="plane">cutting plane</param>
 /// <param name="triangulateHoles">flag for triangulation of holes</param>
 /// <param name="crossSectionVertexColor">this color will be assigned to cross section, valid only for vertex color shaders</param>
 /// <param name="crossUV">uv mapping area for cross section</param>
 /// <param name="allowOpenMesh">allow cutting of open mesh</param>
 /// <returns>processing time</returns>
 public float Cut(Mesh mesh, Transform meshTransform, Math.Plane plane, bool triangulateHoles, bool allowOpenMesh, ref List<CutterMesh> meshes,
                  Color crossSectionVertexColor, Vector4 crossUV)
 {
     this.crossSectionVertexColour = crossSectionVertexColor;
     this.crossSectionUV = crossUV;
     return Cut(mesh, meshTransform, plane, triangulateHoles, allowOpenMesh, ref meshes);
 }
예제 #3
0
 static public int GetVector(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.String)))
         {
             UnityEngine.Material self = (UnityEngine.Material)checkSelf(l);
             System.String        a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector4 ret = self.GetVector(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(System.Int32)))
         {
             UnityEngine.Material self = (UnityEngine.Material)checkSelf(l);
             System.Int32         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector4 ret = self.GetVector(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static bool Vector4_op_Subtraction__Vector4__Vector4(JSVCall vc, int argc)
 {
     UnityEngine.Vector4 arg0 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     UnityEngine.Vector4 arg1 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     JSMgr.datax.setObject((int)JSApi.SetType.Rval, arg0 - arg1);
     return(true);
 }
예제 #5
0
        public BodyPointPosition ReturnPosition(BodyParts joint)
        {
            BodyPointPosition pos = new BodyPointPosition();

            pos.name = joint;
            if (currentBody == null)
            {
                pos.x = 0;
                pos.y = 0;
                pos.z = 0;
            }
            else
            {
                Windows.Kinect.Joint sourceJoint = currentBody.Joints[bodyPartsTranslation[joint]];
                UnityEngine.Vector4  coord       = new UnityEngine.Vector4(sourceJoint.Position.X, sourceJoint.Position.Y, sourceJoint.Position.Z, 1.0f);
                UnityEngine.Vector4  newCoord    = rotMatrix.inverse * coord;

                if (joint == BodyParts.ElbowLeft)
                {
                    if (oldText)
                    {
                        oldText.text = ("Posicion Old " + joint + ": " + sourceJoint.Position.X + " " + sourceJoint.Position.Y + " " + sourceJoint.Position.Z + " ");
                    }
                }

                pos.x = newCoord.x;
                pos.y = newCoord.y + floor.w;
                pos.z = newCoord.z;
            }
            return(pos);
        }
 static bool Vector4_op_Inequality__Vector4__Vector4(JSVCall vc, int argc)
 {
     UnityEngine.Vector4 arg0 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     UnityEngine.Vector4 arg1 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(arg0 != arg1));
     return(true);
 }
 static bool Vector4_op_Multiply__Single__Vector4(JSVCall vc, int argc)
 {
     System.Single       arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
     UnityEngine.Vector4 arg1 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     JSMgr.datax.setObject((int)JSApi.SetType.Rval, arg0 * arg1);
     return(true);
 }
    static void Vector4_normalized(JSVCall vc)
    {
        UnityEngine.Vector4 _this = (UnityEngine.Vector4)vc.csObj;
        var result = _this.normalized;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
    static void Vector4_sqrMagnitude(JSVCall vc)
    {
        UnityEngine.Vector4 _this = (UnityEngine.Vector4)vc.csObj;
        var result = _this.sqrMagnitude;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
예제 #10
0
 static public int op_Multiply(IntPtr l)
 {
     try{
         if (matchType(l, 1, typeof(UnityEngine.Matrix4x4), typeof(UnityEngine.Matrix4x4)))
         {
             UnityEngine.Matrix4x4 a1;
             checkType(l, 1, out a1);
             UnityEngine.Matrix4x4 a2;
             checkType(l, 2, out a2);
             UnityEngine.Matrix4x4 ret = a1 * a2;
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 1, typeof(UnityEngine.Matrix4x4), typeof(UnityEngine.Vector4)))
         {
             UnityEngine.Matrix4x4 a1;
             checkType(l, 1, out a1);
             UnityEngine.Vector4 a2;
             checkType(l, 2, out a2);
             UnityEngine.Vector4 ret = a1 * a2;
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
예제 #11
0
        private void MoveBones(Body kinectBody)
        {
            int kinectJoint = -1;

            foreach (var bone in AvatarBones)
            {
                if (bone == null)
                {
                    break;
                }
                kinectJoint++;
                bone.transform.localPosition = Vector3.zero;

                if (kinectBody.IsTracked)
                {
                    var kinectPosition = GetVector3FromJoint(kinectBody.Joints[(JointType)kinectJoint]) *
                                         _vrWorldManager.KaveScale;
                    Vector4 tempKinectPosition = kinectPosition;
                    var     tempUnityPosition  = _fromKinecttoUnity * tempKinectPosition;
                    Vector3 unityPosition      = tempUnityPosition;
                    bone.transform.position = _kinectBodySource.transform.position +
                                              _kinectBodySource.transform.rotation * unityPosition;
                }
            }
        }
 public override void changeWebViewSize(string _webViewGUID, Vector4 _paddingSize)
 {
     this.simpleWebViewPlugin.CallStatic("sSimpleWebViewManager_ChangeWebViewSize"
         , _webViewGUID
         , (int)_paddingSize.w, (int)_paddingSize.x
         , (int)_paddingSize.y, (int)_paddingSize.z);
 }
예제 #13
0
        /// <summary>
        /// Returns the projection of this vector onto the given base.
        /// </summary>
        /// <param name="vector"></param>
        /// <param name="baseVector"></param>
        /// <returns></returns>
        public static Vector4 Proj(this Vector4 vector, Vector4 baseVector)
        {
            var direction = baseVector.normalized;
            var magnitude = Vector2.Dot(vector, direction);

            return direction * magnitude;
        }
예제 #14
0
        public static UnityEngine.Matrix4x4 Convert(Matrix4x4 mat)
        {
            UnityEngine.Vector4 v0 = Convert(mat.V0);
            UnityEngine.Vector4 v1 = Convert(mat.V2);
            UnityEngine.Vector4 v2 = Convert(mat.V1);
            UnityEngine.Vector4 v3 = Convert(mat.V3);

            return(new UnityEngine.Matrix4x4
            {
                m00 = v0.x,
                m01 = v0.y,
                m02 = v0.z,
                m03 = 0f,
                m10 = v1.x,
                m11 = v1.y,
                m12 = v1.z,
                m13 = 0f,
                m20 = v2.x,
                m21 = v2.y,
                m22 = v2.z,
                m23 = 0f,
                m30 = v3.x,
                m31 = v3.y,
                m32 = v3.z,
                m33 = 1f,
            });
        }
예제 #15
0
		public void Write(Vector4 vector)
		{
			Write(vector.x);
			Write(vector.y);
			Write(vector.z);
			Write(vector.w);
		}
예제 #16
0
 static public int op_Multiply(IntPtr l)
 {
     try{
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 1, typeof(UnityEngine.Vector4), typeof(float)))
         {
             UnityEngine.Vector4 a1;
             checkType(l, 1, out a1);
             System.Single a2;
             checkType(l, 2, out a2);
             UnityEngine.Vector4 ret = a1 * a2;
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, argc, 1, typeof(float), typeof(UnityEngine.Vector4)))
         {
             System.Single a1;
             checkType(l, 1, out a1);
             UnityEngine.Vector4 a2;
             checkType(l, 2, out a2);
             UnityEngine.Vector4 ret = a1 * a2;
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
예제 #17
0
 /// <summary>
 /// Creates a new double-precision vector with given Vector4.
 /// </summary>
 /// <param name="copy">The Vector4 to copy.</param>
 public DVector4(UnityEngine.Vector4 copy)
 {
     this.x = copy.x;
     this.y = copy.y;
     this.z = copy.z;
     this.w = copy.w;
 }
예제 #18
0
 static void Mesh_tangents(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Mesh _this = (UnityEngine.Mesh)vc.csObj;
         var result             = _this.tangents;
         var arrRet             = result;
         for (int i = 0; arrRet != null && i < arrRet.Length; i++)
         {
             JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
             JSApi.moveSaveID2Arr(i);
         }
         JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
     }
     else
     {
         UnityEngine.Vector4[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.Vector4[]>(() =>
         {
             int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
             int length  = JSApi.getArrayLength(jsObjID);
             var ret     = new UnityEngine.Vector4[length];
             for (var i = 0; i < length; i++)
             {
                 JSApi.getElement(jsObjID, i);
                 ret[i] = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
             }
             return(ret);
         });
         UnityEngine.Mesh _this = (UnityEngine.Mesh)vc.csObj;
         _this.tangents = arg0;
     }
 }
예제 #19
0
 public static void CalcSoftOcclusion(Mesh mesh)
 {
   GameObject gameObject = new GameObject("Test");
   gameObject.layer = 29;
   gameObject.AddComponent<MeshFilter>().mesh = mesh;
   gameObject.AddComponent<MeshCollider>();
   if (TreeAO.directions == null)
     TreeAO.InitializeDirections();
   Vector4[] vector4Array1 = new Vector4[TreeAO.directions.Length];
   for (int index = 0; index < TreeAO.directions.Length; ++index)
     vector4Array1[index] = new Vector4(TreeAO.GetWeight(1, TreeAO.directions[index]), TreeAO.GetWeight(2, TreeAO.directions[index]), TreeAO.GetWeight(3, TreeAO.directions[index]), TreeAO.GetWeight(0, TreeAO.directions[index]));
   Vector3[] vertices = mesh.vertices;
   Vector4[] vector4Array2 = new Vector4[vertices.Length];
   float num1 = 0.0f;
   for (int index1 = 0; index1 < vertices.Length; ++index1)
   {
     Vector4 zero = Vector4.zero;
     Vector3 v = gameObject.transform.TransformPoint(vertices[index1]);
     for (int index2 = 0; index2 < TreeAO.directions.Length; ++index2)
     {
       float num2 = Mathf.Pow(0.5f, (float) TreeAO.CountIntersections(v, gameObject.transform.TransformDirection(TreeAO.directions[index2]), 3f));
       zero += vector4Array1[index2] * num2;
     }
     zero /= (float) TreeAO.directions.Length;
     num1 += zero.w;
     vector4Array2[index1] = zero;
   }
   float num3 = num1 / (float) vertices.Length;
   for (int index = 0; index < vertices.Length; ++index)
     vector4Array2[index].w -= num3;
   mesh.tangents = vector4Array2;
   Object.DestroyImmediate((Object) gameObject);
 }
예제 #20
0
        /// <summary>
        /// Gets 3D points [units = meters] and calculated pf vector
        /// </summary>
        /// <param name="state">State.</param>
        private void PreparePointCloud(HoloProxies.Engine.trackerState state)
        {
            boundingbox = findBoundingBoxFromCurrentState(state);

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    int idx = i * Width + j;

                    // if point is not in the bounding box
                    if (j < boundingbox.x || j >= boundingbox.z || i < boundingbox.y || i >= boundingbox.w)
                    {
                        // mark as not useful
                        Camera3DPoints[idx].X = 0;
                        Camera3DPoints[idx].Y = 0;
                        Camera3DPoints[idx].Z = 0;
                        PfVec[idx]            = defines.OUTSIDE_BB;
                    }
                    else // if it's inside the box
                    {
                        Color pixel = ColorTexture.GetPixel(j, i);
                        PfVec[idx] = GetPf(pixel);
                        // Draw the bounding box region
                        if (drawBox && OnBoxEdge(j, i))
                        {
                            //ColorTextureVisual.SetPixel( j, i, Color.blue );
                            ColorTextureVisual.SetPixel(j, i, Color.Lerp(pixel, Color.blue, 0.3f));
                        }
                    }
                }
            } //end for
        }
예제 #21
0
 /// <summary>
 /// Create new vertex profile
 /// </summary>
 public VertexProfile(Color color, UnityEngine.Vector4 uv, UnityEngine.Vector4 uv2, UnityEngine.Vector4 uv3)
 {
     this.color = color;
     this.uv    = uv;
     this.uv2   = uv2;
     this.uv3   = uv3;
 }
예제 #22
0
 static bool Matrix4x4_op_Multiply__Matrix4x4__Vector4(JSVCall vc, int argc)
 {
     UnityEngine.Matrix4x4 arg0 = (UnityEngine.Matrix4x4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     UnityEngine.Vector4   arg1 = (UnityEngine.Vector4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
     JSMgr.datax.setObject((int)JSApi.SetType.Rval, arg0 * arg1);
     return(true);
 }
예제 #23
0
 public override void OnRecord()
 {
     if (_material = material)
     {
         _original = _material.GetVector(propertyID);
     }
 }
예제 #24
0
 public void SetFromToCurrent()
 {
     if (_material = material)
     {
         from = _material.GetVector(propertyID);
     }
 }
예제 #25
0
    private void Update()
    {
        for (int i = 0; i < currentParticulesCount; i++)
        {
            timeToLive[i] -= Time.deltaTime;
            if (timeToLive[i] <= 0)
            {
                currentParticulesCount--;
                particules[i] = particules[currentParticulesCount];
                timeToLive[i] = timeToLive[currentParticulesCount];
                velocities[i] = velocities[currentParticulesCount];
                colors[i]     = colors[currentParticulesCount];
            }

            if (particules[i].m23 < minZ)
            {
                velocities[i].x *= 1 - (lossOfMomentum * Time.deltaTime);
                velocities[i].y *= 1 - (lossOfMomentum * Time.deltaTime);
                velocities[i].z -= (gravity * Time.deltaTime);
                Vector4 newPosition = new Vector4(
                    particules[i].m03 + (velocities[i].x * Time.deltaTime),
                    particules[i].m13 + (velocities[i].y * Time.deltaTime),
                    particules[i].m23 + (velocities[i].z * Time.deltaTime),
                    particules[i].m33);
                particules[i].SetColumn(3, newPosition);
            }
        }

        if (lawnMower.Mowing && currentParticulesCount != 0)
        {
            colorsProperty = new MaterialPropertyBlock();
            colorsProperty.SetVectorArray("_Colors", colors);
            Graphics.DrawMeshInstanced(quad, 0, particulesMaterial, particules, currentParticulesCount, colorsProperty);
        }
    }
예제 #26
0
 public static void Write(this BinaryWriter writer, Vector4 input)
 {
     writer.Write(input.x);
     writer.Write(input.y);
     writer.Write(input.z);
     writer.Write(input.w);
 }
예제 #27
0
    IEnumerator SpawnRoutine()
    {
        while (lawnMower.Mowing)
        {
            yield return(new WaitForSeconds(spawnRatePerSeconds));

            if (currentParticulesCount < maxParticules)
            {
                particules[currentParticulesCount] = Matrix4x4.Translate(new Vector3(transform.position.x, transform.position.y, .5f));
                velocities[currentParticulesCount] = new Vector4(
                    ((rnd.Next(-50, 50) / 100f) * spread) + (-transform.up.x * initialSpeed),
                    ((rnd.Next(-50, 50) / 100f) * spread) + (-transform.up.y * initialSpeed),
                    -initialUpVelocity,
                    0);
                timeToLive[currentParticulesCount] = particuleLifeTime;
                Color color;
                if (lawnMower.IsStuck)
                {
                    color = gameManager.Map.SampleMap(lawnMower.transform.position);
                }
                else
                {
                    Vector3 front = lawnMower.transform.position + lawnMower.transform.up * 0.5f;

                    color = gameManager.Map.SampleMap(
                        new Vector3(front.x + rnd.Next(-50, 50) / 200f,
                                    front.y + rnd.Next(-50, 50) / 200f,
                                    front.z));
                }

                colors[currentParticulesCount] = color;
                currentParticulesCount++;
            }
        }
    }
 void BakeColor(PaintJob job, BakeChannel bc, Vector4 val, int i)
 {
    switch (bc)
    {
       case BakeChannel.Color:
       {
          job.stream.colors[i] = new Color(val.x, val.y, val.z, val.w); break;
       }
       case BakeChannel.UV0:
       {
          job.stream.uv0[i] = val;
          break;
       }
       case BakeChannel.UV1:
       {
          job.stream.uv1[i] = val;
          break;
       }
       case BakeChannel.UV2:
       {
          job.stream.uv2[i] = val;
          break;
       }
       case BakeChannel.UV3:
       {
          job.stream.uv3[i] = val;
          break;
       }
    }
 }
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.Vector4 vector4 = new UnityEngine.Vector4();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "x":
                    vector4.x = reader.ReadProperty <System.Single> ();
                    break;

                case "y":
                    vector4.y = reader.ReadProperty <System.Single> ();
                    break;

                case "z":
                    vector4.z = reader.ReadProperty <System.Single> ();
                    break;

                case "w":
                    vector4.w = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(vector4);
        }
예제 #30
0
        public static void RefreshJointData(KinectJoint[] buffer, UnityEngine.Vector4 floorClipPlane,
                                            Dictionary <JointType, Windows.Kinect.Joint> joints, Dictionary <JointType, JointOrientation> jointOrientations)
        {
            var correction = KinectHelper.CalculateFloorRotationCorrection(floorClipPlane);
            var index      = 0;

            // Trick: Because SpineShoulder is not the successor of SpineMid in the enum,
            // the loop does the first iteration for SpineShoulder and restarts at index = 0 = SpineBase.
            for (int i = (int)JointType.SpineShoulder; i < buffer.Length; i = index++)
            {
                var jointType        = (JointType)i;
                var joint            = joints[jointType];
                var jointOrientation = jointOrientations[jointType];

                var position = correction * KinectHelper.CameraSpacePointToRealSpace(joint.Position, floorClipPlane);
                var rotation = correction * KinectHelper.OrientationToRealSpace(jointOrientation.Orientation);

                if (rotation.IsZero())
                {
                    var parent = KinectHelper.parentJointTypes[i];
                    rotation = KinectHelper.InferrRotationFromParentPosition(position, buffer[(int)parent].position);
                }

                buffer[i] = new KinectJoint(position, rotation, joint.TrackingState);
            }

            // This is a fix for the head rotation.
            // Normally the rotation should be inferred from the parent spine
            // like other joints but for some reason this does not work correctly.
            var head          = buffer[(int)JointType.Head];
            var neck          = buffer[(int)JointType.Neck];
            var fixedRotation = Quaternion.LookRotation(neck.rotation * Vector3.forward, head.position - neck.position);

            buffer[(int)JointType.Head] = new KinectJoint(head.position, fixedRotation, head.trackingState);
        }
예제 #31
0
        // Update is called once per frame
        private IEnumerator OnPreCull()
        {
            Shader.SetGlobalFloat("_GrassDisplacementBorderArea", borderSmoothingArea);

            //Save original position and set camera to be pixel perfect
            Vector3 realPosition = transform.position;

            float pixelWidth = (2*cam.orthographicSize)/cam.pixelWidth;
            float pixelHeight = (2*cam.orthographicSize)/cam.pixelHeight;

            Vector3 pos = realPosition;
            pos.x -= pos.x%pixelWidth;
            pos.z -= pos.z%pixelHeight;
            transform.position = pos;

            //Update camera rotation
            transform.rotation = Quaternion.Euler(90, 0, 0);

            Vector3 bottomLeft = cam.ScreenToWorldPoint(Vector3.zero);
            float width = (2*cam.orthographicSize)*cam.aspect;
            float height = (2*cam.orthographicSize)/cam.aspect;

            Vector4 renderArea = new Vector4(bottomLeft.x, bottomLeft.z, width, height);

            Shader.SetGlobalVector("_GrassRenderTextureArea", renderArea);

            //Wait for end of frame to reset the actual position
            yield return new WaitForEndOfFrame();
            transform.position = realPosition;
        }
		/*
		 * Vector4
		 */
		public static JSONObject FromVector4(Vector4 v) {
			JSONObject vdata = JSONObject.obj;
			if(v.x != 0)	vdata.AddField("x", v.x);
			if(v.y != 0)	vdata.AddField("y", v.y);
			if(v.z != 0)	vdata.AddField("z", v.z);
			if(v.w != 0)	vdata.AddField("w", v.w);
			return vdata;
		}
예제 #33
0
 public static UnityEngine.Vector4 Round(this UnityEngine.Vector4 vector, int decimalCount = 0)
 {
     vector.x = (float)System.Math.Round(vector.x, decimalCount);
     vector.y = (float)System.Math.Round(vector.y, decimalCount);
     vector.z = (float)System.Math.Round(vector.z, decimalCount);
     vector.w = (float)System.Math.Round(vector.w, decimalCount);
     return(vector);
 }
예제 #34
0
파일: MapCamera.cs 프로젝트: pan4/NewTD
 private void SetBounds(float hightSize)
 {            
     _widthSize = hightSize * _windowaspect;
     float borderX = (_bounds.size.x - _widthSize * 2 ) / 2 ;
     float borderY = (_bounds.size.y - _camera.orthographicSize * 2) / 2 + _bounds.center.y;
     _currentBounds = new Vector4(_bounds.center.x - borderX, _bounds.center.y - borderY,
                                  _bounds.center.x + borderX, _bounds.center.y + borderY);
 }
 public CritDampTweenQuaternion(Quaternion rotation, float omega, float maxSpeed)
 {
     _rotation.v = Vector4.zero; // needed for suppressing warnings
     _rotation.q = rotation;
     velocity = Vector4.zero;
     this.omega = omega;
     this.maxSpeed = maxSpeed;
 }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.Vector4 vector4 = (UnityEngine.Vector4)value;
     writer.WriteProperty("x", vector4.x);
     writer.WriteProperty("y", vector4.y);
     writer.WriteProperty("z", vector4.z);
     writer.WriteProperty("w", vector4.w);
 }
예제 #37
0
		protected override void OnUpdateGUI()
		{
			vector = GetValue<Vector4>();
			input_x.text = vector.x.ToString();
			input_y.text = vector.y.ToString();
			input_z.text = vector.z.ToString();
			input_w.text = vector.w.ToString();
		}
 private static void ApplyMaterialModificationToAnimationRecording(string name, Object target, Vector4 vec)
 {
   UndoPropertyModification[] propertyModifications = MaterialAnimationUtility.CreateUndoPropertyModifications(4, target);
   MaterialAnimationUtility.SetupPropertyModification(name + ".x", vec.x, propertyModifications[0]);
   MaterialAnimationUtility.SetupPropertyModification(name + ".y", vec.y, propertyModifications[1]);
   MaterialAnimationUtility.SetupPropertyModification(name + ".z", vec.z, propertyModifications[2]);
   MaterialAnimationUtility.SetupPropertyModification(name + ".w", vec.w, propertyModifications[3]);
   UndoPropertyModification[] propertyModificationArray = Undo.postprocessModifications(propertyModifications);
 }
예제 #39
0
파일: Items.cs 프로젝트: mengtest/pew
		public Hull(Vector4 color, int mass, int armor, int maxHealth, int cost) : base(color){
			
			this.Mass = mass;
			this.Armor = armor;
			this.MaxHealth = maxHealth;
			
			this.Cost = cost;
			
		}
예제 #40
0
 public Vector4 GetValue(Vector4 from, Vector4 to, float t)
 {
     Vector4 vector4 = new Vector4();
     vector4.x = EasingCurve.GetValue(this.easeType, from.x, to.x, t);
     vector4.y = EasingCurve.GetValue(this.easeType, from.y, to.y, t);
     vector4.z = EasingCurve.GetValue(this.easeType, from.z, to.z, t);
     vector4.w = EasingCurve.GetValue(this.easeType, from.w, to.w, t);
     return vector4;
 }
예제 #41
0
        public int PeformFFT(int startIdx, Vector2[,] data0, Vector4[,] data1, Vector4[,] data2)
        {
            int x; int y; int i;
            int idx = 0; int idx1; int bftIdx;
            int X; int Y;
            Vector2 w;

            int j = startIdx;

            for (i = 0; i < m_passes; i++, j++)
            {
                idx = j % 2;
                idx1 = (j + 1) % 2;

                for (x = 0; x < m_size; x++)
                {
                    for (y = 0; y < m_size; y++)
                    {
                        bftIdx = 4 * (x + i * m_size);

                        X = (int)m_butterflyLookupTable[bftIdx + 0];
                        Y = (int)m_butterflyLookupTable[bftIdx + 1];
                        w.x = m_butterflyLookupTable[bftIdx + 2];
                        w.y = m_butterflyLookupTable[bftIdx + 3];

                        data0[idx, x + y * m_size] = FFT(w, data0[idx1, X + y * m_size], data0[idx1, Y + y * m_size]);
                        data1[idx, x + y * m_size] = FFT(w, data1[idx1, X + y * m_size], data1[idx1, Y + y * m_size]);
                        data2[idx, x + y * m_size] = FFT(w, data2[idx1, X + y * m_size], data2[idx1, Y + y * m_size]);
                    }
                }
            }

            for (i = 0; i < m_passes; i++, j++)
            {
                idx = j % 2;
                idx1 = (j + 1) % 2;

                for (x = 0; x < m_size; x++)
                {
                    for (y = 0; y < m_size; y++)
                    {
                        bftIdx = 4 * (y + i * m_size);

                        X = (int)m_butterflyLookupTable[bftIdx + 0];
                        Y = (int)m_butterflyLookupTable[bftIdx + 1];
                        w.x = m_butterflyLookupTable[bftIdx + 2];
                        w.y = m_butterflyLookupTable[bftIdx + 3];

                        data0[idx, x + y * m_size] = FFT(w, data0[idx1, x + X * m_size], data0[idx1, x + Y * m_size]);
                        data1[idx, x + y * m_size] = FFT(w, data1[idx1, x + X * m_size], data1[idx1, x + Y * m_size]);
                        data2[idx, x + y * m_size] = FFT(w, data2[idx1, x + X * m_size], data2[idx1, x + Y * m_size]);
                    }
                }
            }

            return idx;
        }
예제 #42
0
 private static Vector4 ProjectToCellSpace(Vector4 offset)
 {
     return(new Vector4(
                offset.x * Cellf.CELL_STEP_OFFSET,
                offset.y * Cellf.CELL_ELEVATION_OFFSET,
                offset.z * Cellf.CELL_STEP_OFFSET,
                offset.w
                ));
 }
예제 #43
0
 private UnityEngine.Vector4 ConvertVector(Windows.Kinect.Vector4 toConvert)
 {
     UnityEngine.Vector4 converted = new UnityEngine.Vector4();
     converted.x = (float)toConvert.X;
     converted.y = (float)toConvert.Y;
     converted.z = (float)toConvert.Z;
     converted.w = (float)toConvert.W;
     return(converted);
 }
예제 #44
0
        public static Vector4 Div(this Vector4 vector, Vector4 otherVector, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
            vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
            vector.z = axis.Contains(Axes.Z) ? vector.z / otherVector.z : vector.z;
            vector.w = axis.Contains(Axes.W) ? vector.w / otherVector.w : vector.w;

            return vector;
        }
예제 #45
0
 public static byte[] Vector4ToBytes(UnityEngine.Vector4 vect)
 {
     byte[] buff = new byte[sizeof(float) * 4];
     Buffer.BlockCopy(BitConverter.GetBytes(vect.x), 0, buff, 0 * sizeof(float), sizeof(float));
     Buffer.BlockCopy(BitConverter.GetBytes(vect.y), 0, buff, 1 * sizeof(float), sizeof(float));
     Buffer.BlockCopy(BitConverter.GetBytes(vect.z), 0, buff, 2 * sizeof(float), sizeof(float));
     Buffer.BlockCopy(BitConverter.GetBytes(vect.w), 0, buff, 3 * sizeof(float), sizeof(float));
     return(buff);
 }
예제 #46
0
 static public int set_w(IntPtr l)
 {
     UnityEngine.Vector4 o = (UnityEngine.Vector4)checkSelf(l);
     System.Single       v;
     checkType(l, 2, out v);
     o.w = v;
     setBack(l, o);
     return(0);
 }
예제 #47
0
        public static Vector4 Lerp(this Vector4 vector, Vector4 target, float time, Axis axis)
        {
            vector.x = axis.Contains(Axis.X) ? Mathf.Lerp(vector.x, target.x, time) : vector.x;
            vector.y = axis.Contains(Axis.Y) ? Mathf.Lerp(vector.y, target.y, time) : vector.y;
            vector.z = axis.Contains(Axis.Z) ? Mathf.Lerp(vector.z, target.z, time) : vector.z;
            vector.w = axis.Contains(Axis.W) ? Mathf.Lerp(vector.w, target.w, time) : vector.w;

            return vector;
        }
예제 #48
0
		/**
		 * Rebuild mesh without InUnusedVertices, including shifting the triangle array to compensate.
		 */
		public static void RemoveVertices(List<int> InUnusedVertices, ref Mesh InMesh)
		{
			int vertexCount = InMesh.vertexCount;
			int unusedCount = InUnusedVertices.Count;

			Vector3[] v = InMesh.vertices, v_n = new Vector3[vertexCount - unusedCount];
			Vector3[] n = InMesh.normals, n_n = new Vector3[vertexCount - unusedCount];
			Vector4[] t = InMesh.tangents, t_n = new Vector4[vertexCount - unusedCount];
			Vector2[] u = InMesh.uv, u_n = new Vector2[vertexCount - unusedCount];
			Color[] c 	= InMesh.colors, c_n = new Color[vertexCount - unusedCount];

			InUnusedVertices.Sort();

			int unusedIndex = 0;

			// shift triangles
			for(int submeshIndex = 0; submeshIndex < InMesh.subMeshCount; submeshIndex++)
			{
				int[] tris = InMesh.GetTriangles(submeshIndex);

				for(int i = 0; i < tris.Length; i++)
				{
					unusedIndex = pbUtil.NearestIndexPriorToValue( InUnusedVertices, tris[i] ) + 1;
					tris[i] -= unusedIndex;
				}

				InMesh.SetTriangles(tris, submeshIndex);
			}

			unusedIndex = 0;
			int newIndex = 0;

			// rebuild vertex arrays without duplicate indices
			for(int i = 0; i < vertexCount; i++)
			{
				if(unusedIndex < unusedCount && i >= InUnusedVertices[unusedIndex])
				{
					unusedIndex++;
					continue;
				}

				v_n[newIndex] = v[i];
				n_n[newIndex] = n[i];
				t_n[newIndex] = t[i];
				u_n[newIndex] = u[i];
				c_n[newIndex] = c[i];

				newIndex++;
			}

			InMesh.vertices = v_n;
			InMesh.normals = n_n;
			InMesh.tangents = t_n;
			InMesh.uv = u_n;
			InMesh.colors = c_n;
		}
예제 #49
0
 public static Color ColorHSBToRGB(Vector4 hsbColor)
 {
     float r = hsbColor.z;
     float g = hsbColor.z;
     float b = hsbColor.z;
     if (hsbColor.y != 0)
     {
         float max = hsbColor.z;
         float dif = hsbColor.z * hsbColor.y;
         float min = hsbColor.z - dif;
         float h = hsbColor.x * 360f;
         if (h < 60f)
         {
             r = max;
             g = h * dif / 60f + min;
             b = min;
         }
         else if (h < 120f)
         {
             r = -(h - 120f) * dif / 60f + min;
             g = max;
             b = min;
         }
         else if (h < 180f)
         {
             r = min;
             g = max;
             b = (h - 120f) * dif / 60f + min;
         }
         else if (h < 240f)
         {
             r = min;
             g = -(h - 240f) * dif / 60f + min;
             b = max;
         }
         else if (h < 300f)
         {
             r = (h - 240f) * dif / 60f + min;
             g = min;
             b = max;
         }
         else if (h <= 360f)
         {
             r = max;
             g = min;
             b = -(h - 360f) * dif / 60 + min;
         }
         else
         {
             r = 0;
             g = 0;
             b = 0;
         }
     }
     return new Color(Mathf.Clamp01(r), Mathf.Clamp01(g), Mathf.Clamp01(b), hsbColor.w);
 }
예제 #50
0
 /// <summary>
 /// Transform UV Profile
 /// </summary>
 public static VertexProfile Transform(Matrix4x4 t, VertexProfile profile, UnityEngine.Vector4 center)
 {
     return(new VertexProfile()
     {
         color = profile.color,
         uv = t * profile.uv + center,
         uv2 = t * profile.uv2 + center,
         uv3 = t * profile.uv3 + center,
     });
 }
예제 #51
0
        private void PrepareBloomSampling(RenderTexture bloomTexture, GlareParameters glareParams)
        {
            m_combinationMat.SetTexture("_BloomTexture", bloomTexture);

            Vector4 shaderParams = new Vector4();
            shaderParams.x = glareParams.intensity;
            shaderParams.y = glareParams.brightness;
            shaderParams.z = glareParams.bloomNormalizationTerm;
            m_combinationMat.SetVector("_GlareParameters", shaderParams);
        }
예제 #52
0
파일: Items.cs 프로젝트: mengtest/pew
		public Cannon(Vector4 color, float speed, float reload, float damage, Vector4 ammoColor, int cost) : base(color) {
			
			this.Speed = speed;
			this.ReloadTime = reload;
			this.BaseDamage = damage;
			
			this.ammoColor = ammoColor;
			this.Cost = cost;
			
		}
예제 #53
0
        static Vector4 RGBToYCbCr(Color rgb)
        {
            rgb.a = 1.0f;

            Vector4 RGBToY = new Vector4(0.256789f, 0.50413f, 0.0979057f, 0.0625f);
            Vector4 RGBToCb = new Vector4(0.439215f, -0.367788f, -0.0714272f, 0.5f);
            Vector4 RGBToCr = new Vector4(-0.148223f, -0.290992f, 0.439215f, 0.5f);

            return new Vector4(Vector4.Dot(rgb, RGBToY), Vector4.Dot(rgb, RGBToCb), Vector4.Dot(rgb, RGBToCr), 1.0f);
        }
예제 #54
0
        static Color YCbCrToRGB(Vector4 yCbCr)
        {
            yCbCr.w = 1.0f;

            Vector4 YCbCr2R = new Vector4(1.1643828125f, 1.59602734375f, 0f, -.87078515625f);
            Vector4 YCbCr2G = new Vector4(1.1643828125f, -.81296875f, -.39176171875f, .52959375f);
            Vector4 YCbCr2B = new Vector4(1.1643828125f, 0f, 2.017234375f, -1.081390625f);

            return new Color(Vector4.Dot(yCbCr, YCbCr2R), Vector4.Dot(yCbCr, YCbCr2G), Vector4.Dot(yCbCr, YCbCr2B), 1.0f);
        }
예제 #55
0
        private static void DrawCell(Vector4 position)
        {
            position = ProjectToCellSpace(position);
            var normals = ((int)position.w).GetDirectionsFromByte();

            foreach (var direction in Directionf.Directions())
            {
                DrawWall(position, direction, normals.Contains(direction) ? Color.red : Color.cyan);
            }
        }
예제 #56
0
        public override Material CloneMaterial(Material src, int nth)
        {
            var instance_texture = m_world.GetInstanceTexture();

            Material m = new Material(src);
            m.SetInt("g_batch_begin", nth * m_instances_par_batch);
            m.SetTexture("g_instance_data", instance_texture);

            Vector4 ts = new Vector4(
                1.0f / instance_texture.width,
                1.0f / instance_texture.height,
                instance_texture.width,
                instance_texture.height);
            m.SetVector("g_instance_data_size", ts);

            if (m_hdr)
            {
                m.SetInt("_SrcBlend", (int)BlendMode.One);
                m.SetInt("_DstBlend", (int)BlendMode.One);
            }
            else
            {
                m.SetInt("_SrcBlend", (int)BlendMode.DstColor);
                m.SetInt("_DstBlend", (int)BlendMode.Zero);
            }

            if (m_enable_shadow)
            {
                m.EnableKeyword("ENABLE_SHADOW");
                switch (m_sample)
                {
                    case Sample.Fast:
                        m.EnableKeyword("QUALITY_FAST");
                        m.DisableKeyword("QUALITY_MEDIUM");
                        m.DisableKeyword("QUALITY_HIGH");
                        break;
                    case Sample.Medium:
                        m.DisableKeyword("QUALITY_FAST");
                        m.EnableKeyword("QUALITY_MEDIUM");
                        m.DisableKeyword("QUALITY_HIGH");
                        break;
                    case Sample.High:
                        m.DisableKeyword("QUALITY_FAST");
                        m.DisableKeyword("QUALITY_MEDIUM");
                        m.EnableKeyword("QUALITY_HIGH");
                        break;
                }
            }
            else
            {
                m.DisableKeyword("ENABLE_SHADOW");
            }

            return m;
        }
예제 #57
0
 /// <summary>
 /// Direct speedup of <seealso cref="Vector4.Lerp"/>
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static Vector4 Lerp(Vector4 v1, Vector4 v2, float value)
 {
     if (value > 1.0f)
         return v2;
     if (value < 0.0f)
         return v1;
     return new Vector4(v1.x + (v2.x - v1.x) * value,
                         v1.y + (v2.y - v1.y) * value,
                         v1.z + (v2.z - v1.z) * value,
                         v1.w + (v2.w - v1.w) * value);
 }
예제 #58
0
    // unity vector4 to vec4
    public static Vec4 Vector4ToVec4(UnityEngine.Vector4 v1)
    {
        Vec4 v2 = new Vec4();

        v2.x = v1.x;
        v2.y = v1.y;
        v2.z = v1.z;
        v2.w = v1.w;

        return(v2);
    }
예제 #59
0
파일: DiscMesh.cs 프로젝트: dgkae/Teatro
        public void RebuildMesh()
        {
            if (_mesh == null)
            {
                Debug.LogError("Mesh asset is missing.");
                return;
            }

            _mesh.Clear();

            // vertex and index arrays
            var vtxList = new List<Vector3>();
            var uv0List = new List<Vector2>();
            var uv1List = new List<Vector2>();
            var uv2List = new List<Vector3>();
            var idxList = new List<int>();

            // append segments to the arrays
            for (var ri = 0; ri < _ringCount; ri++)
            {
                var l0 = (ri + 0.0f) / _ringCount;
                var l1 = (ri + 1.0f) / _ringCount;

                for (var ai = 0; ai < _arcCount; ai++)
                {
                    AppendSegmentToVertexArray(
                        l0, l1,
                        Mathf.PI * 2 * (ai + 0) / _arcCount,
                        Mathf.PI * 2 * (ai + 1) / _arcCount,
                        vtxList, uv0List, uv1List, uv2List, idxList);
                }
            }

            // make tangent array
            var tan = new Vector4(1, 0, 0, 1);
            var tanList = new Vector4[vtxList.Count];
            for (var i = 0; i < tanList.Length; i++)
                tanList[i] = tan;

            // create mesh object
            _mesh.SetVertices(vtxList);
            _mesh.SetUVs(0, uv0List);
            _mesh.SetUVs(1, uv1List);
            _mesh.SetUVs(2, uv2List);
            _mesh.tangents = tanList;
            _mesh.SetIndices(idxList.ToArray(), MeshTopology.Triangles, 0);

            _mesh.RecalculateNormals();
            _mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000);

            _mesh.Optimize();
            _mesh.UploadMeshData(true);
        }
예제 #60
0
	public void UpdateValue( object val )
	{
		switch ( fieldType )
		{
			case "System.Single": valueSingle = ( System.Single ) val; break;
			case "System.Boolean": valueBoolean = ( System.Boolean ) val; break;
			case "UnityEngine.Color": valueColor = ( UnityEngine.Color ) val; break;
			case "UnityEngine.Vector2": valueVector2 = ( UnityEngine.Vector2 ) val; break;
			case "UnityEngine.Vector3": valueVector3 = ( UnityEngine.Vector3 ) val; break;
			case "UnityEngine.Vector4": valueVector4 = ( UnityEngine.Vector4 ) val; break;
		}
	}