本文整理汇总了C#中UnityEngine.Vector4类的典型用法代码示例。如果您正苦于以下问题:C# Vector4类的具体用法?C# Vector4怎么用?C# Vector4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector4类属于UnityEngine命名空间,在下文中一共展示了Vector4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Proj
/// <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;
}
示例2: Write
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);
}
示例3: BakeColor
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;
}
}
}
示例4: CalcSoftOcclusion
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);
}
示例5: OnPreCull
// 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;
}
示例6: Cut
/// <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);
}
示例7: Write
public void Write(Vector4 vector)
{
Write(vector.x);
Write(vector.y);
Write(vector.z);
Write(vector.w);
}
示例8: changeWebViewSize
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);
}
示例9: FromVector4
/*
* 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;
}
示例10: SetBounds
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);
}
示例11: OnUpdateGUI
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();
}
示例12: CritDampTweenQuaternion
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;
}
示例13: PeformFFT
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;
}
示例14: Hull
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;
}
示例15: Div
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;
}