Here are the examples of the csharp api System.Func.Invoke(Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
13 Examples
19
Source : CollisionMeshData.cs
with Apache License 2.0
from Algoryx
with Apache License 2.0
from Algoryx
public agxCollide.Mesh CreateShape( Func<Vector3, Vector3> transformer,
CollisionMeshOptions.MeshMode mode )
{
// The transformer will return the vertex in left handed frame since
// it has been scaled.
var vertices = new agx.Vec3Vector( Vertices.Select( v => transformer( v ).ToHandedVec3() ).ToArray() );
var indices = new agx.UInt32Vector( Indices.Select( i => (uint)i ).ToArray() );
return mode == CollisionMeshOptions.MeshMode.Trimesh ?
new agxCollide.Trimesh( vertices, indices, "AGXUnity.Mesh: Trimesh" ) :
new agxCollide.Convex( vertices, indices, "AGXUnity.Mesh: " + mode.ToString() );
}
19
Source : Perturb.cs
with Apache License 2.0
from CyanCode
with Apache License 2.0
from CyanCode
public override float GetValue(float x, float y, float z)
{
Vector3 displacement = m_DisplacementSource(new Vector3(x, y, z));
return m_Source.GetValue(x + displacement.x, y + displacement.y, z + displacement.z);
}
19
Source : CameraController2D.cs
with MIT License
from FuzzySlipper
with MIT License
from FuzzySlipper
private void ApplyMovement() {
Vector3 position = transform.position;
if (!ExclusiveModeEnabled) {
CameraSeekTarget.position = IdealCameraPosition() + TotalInfluence();
}
Vector3 idealPosition = CameraSeekPosition;
Vector3 targetPosition = idealPosition + CalculatePushBackOffset(idealPosition);
Vector3 targetViewportPoint = cameraToUse.WorldToViewportPoint(targetPosition);
bool targetWithinMoveBox = TargetViewportPointWithinMoveBox(targetViewportPoint);
if (panningToNewTarget || !targetWithinMoveBox) {
float maxSpeed = maxMoveSpeedPerSecond;
if (panningToNewTarget) {
maxSpeed = panningToNewTargetSpeed;
}
if (!targetWithinMoveBox && !panningToNewTarget) {
var topLeftPoint = new Vector2(pushBox.x - (pushBox.width / 2), pushBox.y + (pushBox.height / 2));
var bottomRightPoint = new Vector2(pushBox.x + (pushBox.width / 2), pushBox.y - (pushBox.height / 2));
// move unit to edge of move box instead of moving as far as we are able to based on deltaTime
// to avoid having a 3 no move, 1 move update stuttering pattern
float xDifference = 0f;
float yDifference = 0f;
if (targetViewportPoint.x < topLeftPoint.x || targetViewportPoint.x > bottomRightPoint.x) {
xDifference = Mathf.Abs(targetViewportPoint.x - pushBox.x) / (pushBox.width / 2);
}
if (targetViewportPoint.y > topLeftPoint.y || targetViewportPoint.y < bottomRightPoint.y) {
yDifference = Mathf.Abs(targetViewportPoint.y - pushBox.y) / (pushBox.height / 2);
}
float scaleFactor;
if (xDifference > yDifference) {
scaleFactor = 1 - (1 / xDifference);
}
else {
scaleFactor = 1 - (1 / yDifference);
}
targetPosition = transform.position + ((targetPosition - position) * scaleFactor);
}
Vector3 vectorToTarget = targetPosition - position;
Vector3 vectorToTargetAlongPlane = GetHorizontalComponent(vectorToTarget) +
GetVerticalComponent(vectorToTarget);
Vector3 interpolatedPosition = Vector3.zero;
float xDelta = Mathf.Abs(vectorToTargetAlongPlane.x);
float yDelta = Mathf.Abs(vectorToTargetAlongPlane.y);
float zDelta = Mathf.Abs(vectorToTargetAlongPlane.z);
float xyzTotal = xDelta + yDelta + zDelta;
interpolatedPosition.x = Mathf.SmoothDamp(position.x, targetPosition.x, ref velocity.x, damping,
maxSpeed * (xDelta / xyzTotal));
interpolatedPosition.y = Mathf.SmoothDamp(position.y, targetPosition.y, ref velocity.y, damping,
maxSpeed * (yDelta / xyzTotal));
interpolatedPosition.z = Mathf.SmoothDamp(position.z, targetPosition.z, ref velocity.z, damping,
maxSpeed * (zDelta / xyzTotal));
transform.position = interpolatedPosition;
}
else {
velocity = Vector3.zero;
}
#if UNITY_EDITOR
if (drawDebugLines) {
lastCalculatedPosition = transform.position;
lastCalculatedIdealPosition = IdealCameraPosition();
lastCalculatedInfluence = TotalInfluence();
influencesForGizmoRendering = new Vector3[influences.Count];
influences.CopyTo(influencesForGizmoRendering);
}
#endif
if (!arrivalNotificationSent && panningToNewTarget &&
(targetPosition - position).sqrMagnitude <= arrivalNotificationDistanceSquared) {
if (OnNewTargetReached != null) {
OnNewTargetReached();
}
if (arrivedAtNewTargetCallback != null) {
arrivedAtNewTargetCallback();
arrivedAtNewTargetCallback = null;
}
arrivalNotificationSent = true;
panningToNewTarget = false;
}
influences.Clear();
}
19
Source : CameraController2D.cs
with MIT License
from FuzzySlipper
with MIT License
from FuzzySlipper
private Vector3 CalculatePushBackOffset(Vector3 idealPosition) {
Vector3 idealCenterPointAtPlayerHeight = idealPosition + HeightOffset();
Vector3 horizontalVector = GetHorizontalComponent(Vector3.one).normalized;
Vector3 verticalVector = GetVerticalComponent(Vector3.one).normalized;
int horizontalFacing = 0;
int verticalFacing = 0;
float horizontalPushBack = 0f;
float verticalPushBack = 0f;
float rightHorizontalPushBack = 0f;
float leftHorizontalPushBack = 0f;
float upVerticalPushBack = 0f;
float downVerticalPushBack = 0f;
rightHorizontalPushBack = CalculatePushback(rightRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalPositive);
if (rightHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = rightHorizontalPushBack;
horizontalFacing = 1;
}
if (0 == rightHorizontalPushBack) {
upVerticalPushBack = CalculatePushback(rightUpRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalPositive);
if (upVerticalPushBack > verticalPushBack) {
verticalPushBack = upVerticalPushBack;
verticalFacing = 1;
}
downVerticalPushBack = CalculatePushback(rightDownRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalNegative);
if (downVerticalPushBack > verticalPushBack) {
verticalPushBack = downVerticalPushBack;
verticalFacing = -1;
}
}
leftHorizontalPushBack = CalculatePushback(leftRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalNegative);
if (leftHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = leftHorizontalPushBack;
horizontalFacing = -1;
}
if (0 == leftHorizontalPushBack) {
upVerticalPushBack = CalculatePushback(leftUpRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalPositive);
if (upVerticalPushBack > verticalPushBack) {
verticalPushBack = upVerticalPushBack;
verticalFacing = 1;
}
downVerticalPushBack = CalculatePushback(leftDownRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalNegative);
if (downVerticalPushBack > verticalPushBack) {
verticalPushBack = downVerticalPushBack;
verticalFacing = -1;
}
}
upVerticalPushBack = CalculatePushback(upRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalPositive);
if (upVerticalPushBack > verticalPushBack) {
verticalPushBack = upVerticalPushBack;
verticalFacing = 1;
}
if (0 == upVerticalPushBack) {
rightHorizontalPushBack = CalculatePushback(upperRightRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalPositive);
if (rightHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = rightHorizontalPushBack;
horizontalFacing = 1;
}
leftHorizontalPushBack = CalculatePushback(upperLeftRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalNegative);
if (leftHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = leftHorizontalPushBack;
horizontalFacing = -1;
}
}
downVerticalPushBack = CalculatePushback(downRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.VerticalNegative);
if (downVerticalPushBack > verticalPushBack) {
verticalPushBack = downVerticalPushBack;
verticalFacing = -1;
}
if (0 == downVerticalPushBack) {
rightHorizontalPushBack = CalculatePushback(lowerRightRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalPositive);
if (rightHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = rightHorizontalPushBack;
horizontalFacing = 1;
}
leftHorizontalPushBack = CalculatePushback(lowerLeftRaycastPoint, idealCenterPointAtPlayerHeight,
BumperDirection.HorizontalNegative);
if (leftHorizontalPushBack > horizontalPushBack) {
horizontalPushBack = leftHorizontalPushBack;
horizontalFacing = -1;
}
}
return (verticalVector * -verticalPushBack * verticalFacing) +
(horizontalVector * -horizontalPushBack * horizontalFacing);
}
19
Source : CameraController2D.cs
with MIT License
from FuzzySlipper
with MIT License
from FuzzySlipper
private Vector3 IdealCameraPosition() {
for (int i = TargetStack.Count - 1; i >= 0; i--) {
if (TargetStack[i] == null) {
TargetStack.RemoveAt(i);
}
}
if (TargetStack.Count == 0) {
return Vector3.zero;
}
if (TargetStack.Count == 1) {
return TargetStack[0].position - HeightOffset();
}
float minHorizontal = float.MaxValue;
float maxHorizontal = float.MinValue;
float minVertical = float.MaxValue;
float maxVertical = float.MinValue;
for (int i = 0; i < TargetStack.Count; i++) {
var horizontal = GetHorizontalValue(TargetStack[i].position);
if (horizontal < minHorizontal) {
minHorizontal = horizontal;
}
if (horizontal > maxHorizontal) {
maxHorizontal = horizontal;
}
var vertical = GetVerticalValue(TargetStack[i].position);
if (vertical < minVertical) {
minVertical = vertical;
}
if (vertical > maxVertical) {
maxVertical = vertical;
}
}
float horizontalOffset = (maxHorizontal - minHorizontal) * 0.5f;
float verticalOffset = (maxVertical - minVertical) * 0.5f;
return (GetHorizontalComponent(Vector3.one) * (minHorizontal + horizontalOffset)) +
(GetVerticalComponent(Vector3.one) * (minVertical + verticalOffset)) - HeightOffset();
}
19
Source : VoxelParticleSystem.cs
with MIT License
from GarethIW
with MIT License
from GarethIW
public void SpawnBatch(Batch batch, Func<Vector3, Vector3> velocityFunction)
{
int step = batch.Voxels.Count/(MaxBatchParticles >= 0 ? MaxBatchParticles : 100);
if (step < 1) step = 1;
for (int i = 0; i < batch.Voxels.Count; i += step)
{
SpawnSingle(batch.Voxels[i].WorldPosition, batch.Voxels[i].Voxel, batch.VoxelObject.VoxelSize,
velocityFunction(batch.Voxels[i].WorldPosition));
}
}
19
Source : AnalysisMesh.cs
with MIT License
from hypar-io
with MIT License
from hypar-io
public virtual void replacedyze()
{
var bounds = new BBox3(new[] { this.Perimeter });
var w = bounds.Max.X - bounds.Min.X;
var h = bounds.Max.Y - bounds.Min.Y;
var x = bounds.Min.X;
var y = bounds.Min.Y;
while (x <= bounds.Min.X + w)
{
while (y <= bounds.Min.Y + h)
{
var cell = new BBox3(new Vector3(x, y), new Vector3(x + this.ULength, y + this.VLength));
var result = this._replacedyze(cell.Center());
this._min = Math.Min(this._min, result);
this._max = Math.Max(this._max, result);
this._results.Add((cell, result));
y += this.VLength;
}
y = bounds.Min.Y;
x += this.ULength;
}
}
19
Source : SelectableCollider.cs
with MIT License
from LeLocTai
with MIT License
from LeLocTai
public void InvalidateScreenPosition(Func<Vector3, Vector2> worldToScreenPoint)
{
for (var i = 0; i < verticesScreenSpace.Length; i++)
{
verticesScreenSpace[i] = worldToScreenPoint(vertices[i]);
}
}
19
Source : Net3dBoolExtend.cs
with MIT License
from LONEStudio
with MIT License
from LONEStudio
public static Solid ToSolid(this Mesh mesh, Func<Vector3, Vector3Double> transFunc)
{
using (var meshVs = CollectionPool<Vector3>.ListCell.Create())
{
mesh.GetVertices(meshVs);
using (var meshTs = CollectionPool<int>.ListCell.Create())
{
mesh.GetTriangles(meshTs, 0);
using (var solidVs =
CollectionPool<Vector3Double>.ListCell.Create(
from c in meshVs select transFunc(c)))
{
return new Solid(solidVs, meshTs);
}
}
}
}
19
Source : UISketch.cs
with GNU General Public License v3.0
from mzandvliet
with GNU General Public License v3.0
from mzandvliet
public static int MoveControllerIndex(Func<Vector3, Vector3> world2ScreenPoint, IList<GameObject> availableItems,
int currenreplacedemIndex, Vector2 inputDirection) {
if (inputDirection == Vector2.zero) {
return currenreplacedemIndex;
}
var currenreplacedem = availableItems[currenreplacedemIndex];
inputDirection = inputDirection.normalized;
var currentPoint = RelativeScreenPoint(world2ScreenPoint(currenreplacedem.transform.position));
int? selectedItemIndex = null;
float selectedItemCloseness = 0;
for (int i = 0; i < availableItems.Count; i++) {
var item = availableItems[i];
if (i != currenreplacedemIndex && item.activeInHierarchy) {
var itemPoint = RelativeScreenPoint(world2ScreenPoint(item.transform.position));
var itemDistance = Vector3.Magnitude(itemPoint - currentPoint);
var itemDirection = (itemPoint - currentPoint).normalized;
var angle = Vector2.Angle(inputDirection, itemDirection);
var isCloseEnough = angle <= 90f;
var closeness = itemDistance * 4.2f + (angle / 90f);
GameObject newSelectedItem = null;
if (isCloseEnough) {
if (!selectedItemIndex.HasValue) {
newSelectedItem = item;
} else if (closeness < selectedItemCloseness) {
newSelectedItem = item;
}
}
if (newSelectedItem != null) {
selectedItemIndex = i;
selectedItemCloseness = closeness;
}
}
}
return selectedItemIndex ?? currenreplacedemIndex;
}
19
Source : Spline.cs
with MIT License
from tomkail
with MIT License
from tomkail
public bool RoughEstimateBestCurveT (System.Func<Vector3, float> scoringFunction, ref SplineBezierCurve bestCurve, ref float bestT, ref float bestScore) {
bool changed = false;
foreach(var curve in curves) {
for (int i = 0; i < curve._points.Length; i++) {
var curvePoint = curve._points[i];
float score = scoringFunction(curvePoint);
if(score > bestScore) {
bestScore = score;
bestCurve = curve;
bestT = i * curve.numArcLengthsForArcLengthToTCalculationReciprocal;
changed = true;
}
}
}
return changed;
}
19
Source : Quad.cs
with MIT License
from vimaec
with MIT License
from vimaec
public Quad Map(Func<Vector3, Vector3> f) => new Quad(f(A), f(B), f(C), f(D));
19
Source : Triangle.cs
with MIT License
from vimaec
with MIT License
from vimaec
public Triangle Map(Func<Vector3, Vector3> f) => new Triangle(f(A), f(B), f(C));