本文整理汇总了C#中VRageMath.Vector3类的典型用法代码示例。如果您正苦于以下问题:C# Vector3类的具体用法?C# Vector3怎么用?C# Vector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3类属于VRageMath命名空间,在下文中一共展示了Vector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTriangle
internal static void DrawTriangle(Vector3 v0, Vector3 v1, Vector3 v2, Color color)
{
var distance = ((v0 + v1 + v2) / 3f - MyEnvironment.CameraPosition).LengthSquared();
m_triangleSortDistance.Add(distance);
m_vertexList.Add(new MyVertexFormatPositionColor(v0, color));
m_vertexList.Add(new MyVertexFormatPositionColor(v1, color));
m_vertexList.Add(new MyVertexFormatPositionColor(v2, color));
}
示例2: AddBillboardOriented
internal static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, int customViewProjection = -1)
{
Debug.Assert(material != null);
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = SpawnBillboard();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin);
}
示例3: AddBillboardOriented
// Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
// This billboard isn't facing the camera. It's always oriented in specified direction. May be used as thrusts, or inner light of reflector.
// It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
public static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, bool colorize = false, int customViewProjection = -1)
{
Debug.Assert(material != null);
if (!IsEnabled) return;
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = m_billboardOncePool.Allocate();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize);
m_billboardsOnce.Add(billboard);
}
示例4: LoadAnimationData
public void LoadAnimationData()
{
if (m_loadedData) return;
lock (this)
{
VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyModel::LoadAnimationData");
MyLog.Default.WriteLine("MyModel.LoadData -> START", LoggingOptions.LOADING_MODELS);
MyLog.Default.IncreaseIndent(LoggingOptions.LOADING_MODELS);
MyLog.Default.WriteLine("m_assetName: " + m_assetName, LoggingOptions.LOADING_MODELS);
// Read data from model TAG parameter. There are stored vertex positions, triangle indices, vectors, ... everything we need.
VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Model - load data - import data");
MyLog.Default.WriteLine(String.Format("Importing asset {0}, path: {1}", m_assetName, AssetName), LoggingOptions.LOADING_MODELS);
try
{
m_importer.ImportData(AssetName);
}
catch
{
MyLog.Default.WriteLine(String.Format("Importing asset failed {0}", m_assetName));
throw;
}
VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Model - load data - load tag data");
Dictionary<string, object> tagData = m_importer.GetTagData();
if (tagData.Count == 0)
{
throw new Exception(String.Format("Uncompleted tagData for asset: {0}, path: {1}", m_assetName, AssetName));
}
DataVersion = m_importer.DataVersion;
Animations = (ModelAnimations)tagData[MyImporterConstants.TAG_ANIMATIONS];
Bones = (MyModelBone[])tagData[MyImporterConstants.TAG_BONES];
BoundingBox = (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX];
BoundingSphere = (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE];
BoundingBoxSize = BoundingBox.Max - BoundingBox.Min;
BoundingBoxSizeHalf = BoundingBoxSize / 2.0f;
Dummies = tagData[MyImporterConstants.TAG_DUMMIES] as Dictionary<string, MyModelDummy>;
BoneMapping = tagData[MyImporterConstants.TAG_BONE_MAPPING] as VRageMath.Vector3I[];
if (BoneMapping.Length == 0)
BoneMapping = null;
VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
ModelInfo = new MyModelInfo(GetTrianglesCount(), GetVerticesCount(), BoundingBoxSize);
m_loadedData = true;
MyLog.Default.DecreaseIndent(LoggingOptions.LOADING_MODELS);
MyLog.Default.WriteLine("MyModel.LoadAnimationData -> END", LoggingOptions.LOADING_MODELS);
VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
}
}
示例5: GetVertex
public void GetVertex(int vertexIndex1, int vertexIndex2, int vertexIndex3, out Vector3 v1, out Vector3 v2, out Vector3 v3)
{
v1 = GetVertex(vertexIndex1);
v2 = GetVertex(vertexIndex2);
v3 = GetVertex(vertexIndex3);
}
示例6: UpdatePointlight
internal static void UpdatePointlight(LightId light, bool enabled, float range, Vector3 color, float falloff)
{
Pointlights[light.Index].Range = range;
Pointlights[light.Index].Color = color;
Pointlights[light.Index].Falloff = falloff;
Pointlights[light.Index].Enabled = enabled;
var proxy = Pointlights[light.Index].BvhProxyId;
var difference = Vector3D.RectangularDistance(ref Pointlights[light.Index].LastBvhUpdatePosition, ref Lights.Data[light.Index].PositionWithOffset);
bool dirty = (enabled && ((proxy == -1) || (difference > MOVE_TOLERANCE))) || (!enabled && proxy != -1);
if(dirty)
{
DirtyPointlights.Add(light);
}
else
{
DirtyPointlights.Remove(light);
}
}
示例7: MyVertexFormatPositionH4
internal MyVertexFormatPositionH4(Vector3 position)
{
Position = VF_Packer.PackPosition(ref position);
}
示例8: MyVertexFormatPositionColor
internal MyVertexFormatPositionColor(Vector3 position, Byte4 color)
{
Position = position;
Color = color;
}
示例9: Draw6FacedConvexZ
// Assuming engine order (+Z first)
internal static unsafe void Draw6FacedConvexZ(Vector3* vertices, Color color, float alpha)
{
Color c = color;
c.A = (byte)(alpha * 255);
DrawQuadClockWise(vertices[0], vertices[1], vertices[2], vertices[3], c);
DrawQuadClockWise(vertices[4], vertices[5], vertices[6], vertices[7], c);
/* top left bottom right */
DrawQuadClockWise(vertices[0], vertices[1], vertices[5], vertices[4], c);
DrawQuadClockWise(vertices[0], vertices[3], vertices[7], vertices[4], c);
DrawQuadClockWise(vertices[3], vertices[2], vertices[6], vertices[7], c);
DrawQuadClockWise(vertices[2], vertices[1], vertices[5], vertices[6], c);
}
示例10: UpdateVectors
static void UpdateVectors()
{
MatrixD invertedViewMatrix;
MatrixD.Invert(ref ViewMatrix, out invertedViewMatrix);
ForwardVector = (Vector3)invertedViewMatrix.Forward;
LeftVector = (Vector3)invertedViewMatrix.Left;
UpVector = (Vector3)invertedViewMatrix.Up;
}
示例11: DrawNormalGlare
internal static void DrawNormalGlare(LightId light, ref MyGlareDesc glare, Vector3 L, float distance)
{
//if (m_occlusionRatio <= MyMathConstants.EPSILON)
// return;
var intensity = glare.Intensity;
var maxDistance = glare.MaxDistance;
//float alpha = m_occlusionRatio * intensity;
float alpha = intensity;
const float minGlareRadius = 0.2f;
const float maxGlareRadius = 10;
float radius = MathHelper.Clamp(glare.Range * 20, minGlareRadius, maxGlareRadius);
float drawingRadius = radius * glare.Size;
if (glare.Type == MyGlareTypeEnum.Directional)
{
float dot = Vector3.Dot(L, glare.Direction);
alpha *= dot;
}
if (alpha <= MyMathConstants.EPSILON)
return;
if (distance > maxDistance * .5f)
{
// distance falloff
float falloff = (distance - .5f * maxDistance) / (.5f * maxDistance);
falloff = (float)Math.Max(0, 1 - falloff);
drawingRadius *= falloff;
alpha *= falloff;
}
if (drawingRadius <= float.Epsilon)
return;
var color = glare.Color;
color.A = 0;
MyBillboardsHelper.AddBillboardOriented(glare.Material.ToString(),
color * alpha, light.Position, MyEnvironment.InvView.Left, MyEnvironment.InvView.Up, drawingRadius);
}
示例12: SetViewMatrix
public void SetViewMatrix(MatrixD value)
{
ViewMatrix = value;
MatrixD.Invert(ref ViewMatrix, out WorldMatrix);
Position = WorldMatrix.Translation;
InversePositionTranslationMatrix = MatrixD.CreateTranslation(-Position);
PreviousPosition = Position;
ForwardVector = (Vector3)WorldMatrix.Forward;
UpVector = (Vector3)WorldMatrix.Up;
LeftVector = (Vector3)WorldMatrix.Left;
// Projection matrix according to zoom level
ProjectionMatrix = MatrixD.CreatePerspectiveFieldOfView(FovWithZoom, ForwardAspectRatio,
GetSafeNear(),
FarPlaneDistance);
ViewProjectionMatrix = ViewMatrix * ProjectionMatrix;
// Projection matrix according to zoom level
float near = System.Math.Min(NearPlaneDistance, NearForNearObjects); //minimum cockpit distance
ProjectionMatrixForNearObjects = MatrixD.CreatePerspectiveFieldOfView(FovWithZoomForNearObjects, ForwardAspectRatio,
near,
FarForNearObjects);
float safenear = System.Math.Min(4, NearPlaneDistance); //minimum cockpit distance
ViewMatrixAtZero = value;
ViewMatrixAtZero.M14 = 0;
ViewMatrixAtZero.M24 = 0;
ViewMatrixAtZero.M34 = 0;
ViewMatrixAtZero.M41 = 0;
ViewMatrixAtZero.M42 = 0;
ViewMatrixAtZero.M43 = 0;
ViewMatrixAtZero.M44 = 1;
UpdateBoundingFrustum();
VRageRender.MyRenderProxy.SetCameraViewMatrix(
value,
ProjectionMatrix,
ProjectionMatrixForNearObjects,
safenear,
Zoom.GetFOVForNearObjects(),
Zoom.GetFOV(),
NearPlaneDistance,
FarPlaneDistance,
NearForNearObjects,
FarForNearObjects,
Position);
}
示例13: MyVertexFormatPositionPackedColor
internal MyVertexFormatPositionPackedColor(Vector3 position, Byte4 color)
{
Position = new HalfVector4(position.X, position.Y, position.Z, 1);
Color = color;
}
示例14: DrawQuadRowWise
internal static void DrawQuadRowWise(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
{
DrawTriangle(v0, v1, v2, color);
DrawTriangle(v1, v3, v2, color);
}
示例15: Translate
internal void Translate(Vector3 v)
{
m_row0.W += v.X;
m_row1.W += v.Y;
m_row2.W += v.Z;
}