本文整理汇总了C#中Vector3f类的典型用法代码示例。如果您正苦于以下问题:C# Vector3f类的具体用法?C# Vector3f怎么用?C# Vector3f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector3f类属于命名空间,在下文中一共展示了Vector3f类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BrickShader
public BrickShader(GraphicsInterface gi)
: base(gi)
{
//Console.WriteLine("BrickShader Link Log: \n{0}", InfoLog);
GLSLVertexShader vShader = new GLSLVertexShader(gi, Brick_VertexSource);
AttachShader(vShader);
GLSLFragmentShader fShader = new GLSLFragmentShader(gi, Brick_FragmentSource);
AttachShader(fShader);
Link();
// Do an initial selection so that all the variables can be located
Bind();
BrickColor_Pos = GetUniformLocation("BrickColor");
MortarColor_Pos = GetUniformLocation("MortarColor");
BrickSize_Pos = GetUniformLocation("BrickSize");
BrickPct_Pos = GetUniformLocation("BrickPct");
// From the Vertex Shader
LightPosition_Pos = GetUniformLocation("LightPosition");
// Set some initial values
BrickColor = new ColorRGBA(1.0f, 0.3f, 0.2f);
MortarColor = new ColorRGBA(0.85f, 0.86f, 0.84f);
BrickSize = new float2(0.30f, 0.15f);
BrickPct = new float2(0.90f, 0.85f);
LightPosition = new Vector3f(0.0f, 0.0f, 4.0f);
// Unselect so we start in an unselected state
Unbind();
}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:34,代码来源:BrickShader.cs
示例2: Raycast
public int Raycast(Ray ray, uint[] triangles, Vector3f[] vertices, List<int> triangleMap)
{
double closestDist = double.MaxValue;
int closestHit = -1;
for (int i = 0; i < triangles.Length; i += 3)
{
Vector3 p0 = (Vector3)vertices[triangles[i+0]];
Vector3 p1 = (Vector3)vertices[triangles[i+1]];
Vector3 p2 = (Vector3)vertices[triangles[i+2]];
Plane plane = new Plane(p0, p1, p2);
//Console.WriteLine(i+" "+plane);
double dist;
if (plane.Raycast(ray, out dist))
{
Vector3 hitPoint = ray.origin+ray.direction*dist;
Vector3 bary = MathUtil.Barycentric(p0, p1, p2, hitPoint);
if (MathUtil.BarycentricIsInside(bary))
{
if (dist < closestDist)
{
closestDist = dist;
closestHit = triangleMap[i/3];
}
}
}
}
return closestHit;
}
开发者ID:KurtLoeffler,项目名称:EnvyEngine,代码行数:31,代码来源:PolyMesh.cs
示例3: Vector4f
public Vector4f(Vector3f source, float w)
{
X = source.X;
Y = source.Y;
Z = source.Z;
W = w;
}
开发者ID:koush,项目名称:OpenGLESTest,代码行数:7,代码来源:Vector4f.cs
示例4: Bone
internal Bone(string name, int parent, ImmutableArray<int> boneControllers,
Vector3f position, Quaternionf quaternion, Vector3f rotation, Vector3f positionScale, Vector3f rotationScale,
Matrix4x4f poseToBone, Quaternionf alignment,
int flags, int procType, int procIndex, int physicsBone, int surfacePropIdx, int contents)
{
Name = name;
Parent = parent;
BoneControllers = boneControllers;
Position = position;
Quaternion = quaternion;
Rotation = rotation;
PositionScale = positionScale;
RotationScale = rotationScale;
PoseToBone = poseToBone;
Alignment = alignment;
Flags = flags;
ProcType = procType;
ProcIndex = procIndex;
PhysicsBone = physicsBone;
SurfacePropIdx = surfacePropIdx;
Contents = contents;
}
开发者ID:Frassle,项目名称:Ibasa,代码行数:25,代码来源:Mdl.cs
示例5: MDXSubmesh
public MDXSubmesh(byte[] data)
{
using (MemoryStream ms = new MemoryStream(data))
{
using (BinaryReader br = new BinaryReader(ms))
{
this.PartID = br.ReadUInt32();
this.StartVertexIndex = br.ReadUInt16();
this.VertexCount = br.ReadUInt16();
this.StartTriangleIndex = br.ReadUInt16();
this.TriangleCount = br.ReadUInt16();
this.BoneCount = br.ReadUInt16();
this.StartBoneIndex = br.ReadUInt16();
this.InfluencingBonesIndex = br.ReadUInt16();
this.RootBoneIndex = br.ReadUInt16();
this.SubmeshMedianPoint = br.ReadVector3f();
if (br.BaseStream.Length > 32)
{
this.BoundingShellMedianPoint = br.ReadVector3f();
this.BoundingSphereRadius = br.ReadSingle();
}
}
}
}
开发者ID:Nihlus,项目名称:libwarcraft,代码行数:25,代码来源:MDXSubmesh.cs
示例6: Cylinder3f
public Cylinder3f( Vector3f origin, Vector3f axis, float radius, float height )
{
this.origin = origin;
this.axis = axis;
this.radius = radius;
this.height = height;
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:7,代码来源:Cylinder3f.cs
示例7: ExtractBackgroundColor
public static Vector4f ExtractBackgroundColor( Vector4f composite, Vector4f foreground )
{
// c = composite, f = foreground, b = background
// red channel:
// c_r = f_a * f_r + ( 1 - f_a ) * b_r
// ==> b_r = ( c_r - f_a * f_r ) / ( 1 - f_a )
//
// alpha channel:
// c_a = f_a + b_a * ( 1 - f_a )
// ==> b_a = ( c_a - f_a ) / ( 1 - f_a )
Vector3f compositeRGB = composite.XYZ;
Vector3f foregroundRGB = foreground.XYZ;
float ca = composite.w;
float fa = foreground.w;
if( fa > 0 && fa < 1 ) // partially transparent
{
var backgroundRGB = new Vector3f( compositeRGB - fa * foregroundRGB ) / ( 1.0f - fa );
var ba = ( ca - fa ) / ( 1 - fa );
return new Vector4f( backgroundRGB, ba ).Saturate();
}
else if( fa < 0.5f ) // foreground is fully transparent: background = input
{
return composite;
}
else // fa == 1, foreground is completely opaque, have no idea what the background is, return opaque black
{
// return new Vector4f( 0, 0, 0, 1 );
return Vector4f.Zero;
}
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:33,代码来源:Compositing.cs
示例8: LoadBinaryData
public void LoadBinaryData(byte[] inData)
{
using (MemoryStream ms = new MemoryStream(inData))
{
using (BinaryReader br = new BinaryReader(ms))
{
this.WidthVertices = br.ReadUInt32();
this.HeightVertices = br.ReadUInt32();
this.WidthTileFlags = br.ReadUInt32();
this.HeightTileFlags = br.ReadUInt32();
this.Location = br.ReadVector3f();
this.MaterialIndex = br.ReadUInt16();
uint vertexCount = this.WidthVertices * this.HeightVertices;
for (int i = 0; i < vertexCount; ++i)
{
this.LiquidVertices.Add(new LiquidVertex(br.ReadBytes(LiquidVertex.GetSize())));
}
uint tileFlagCount = this.WidthTileFlags * this.HeightTileFlags;
for (int i = 0; i < tileFlagCount; ++i)
{
this.LiquidTileFlags.Add((LiquidFlags)br.ReadByte());
}
}
}
}
开发者ID:Nihlus,项目名称:libwarcraft,代码行数:29,代码来源:ModelLiquids.cs
示例9: mapToSphere
public void mapToSphere(Point point, Vector3f vector)
{
//Copy paramter into temp point
Point2f tempPoint = new Point2f(point.X, point.Y);
//Adjust point coords and scale down to range of [-1 ... 1]
tempPoint.x = (tempPoint.x * this.adjustWidth) - 1.0f;
tempPoint.y = 1.0f - (tempPoint.y * this.adjustHeight);
//Compute the square of the length of the vector to the point from the center
float length = (tempPoint.x * tempPoint.x) + (tempPoint.y * tempPoint.y);
//If the point is mapped outside of the sphere... (length > radius squared)
if (length > 1.0f)
{
//Compute a normalizing factor (radius / sqrt(length))
float norm = (float) (1.0 / Math.Sqrt(length));
//Return the "normalized" vector, a point on the sphere
vector.x = tempPoint.x * norm;
vector.y = tempPoint.y * norm;
vector.z = 0.0f;
}
else //Else it's on the inside
{
//Return a vector to a point mapped inside the sphere sqrt(radius squared - length)
vector.x = tempPoint.x;
vector.y = tempPoint.y;
vector.z = (float) Math.Sqrt(1.0f - length);
}
}
开发者ID:jesantana,项目名称:RSAGenerator,代码行数:31,代码来源:ArcBall.cs
示例10: RotateAxis
public static Matrix3f RotateAxis( Vector3f axis, float radians )
{
var normalizedAxis = axis.Normalized();
float cosTheta = ( float )( Math.Cos( radians ) );
float sinTheta = ( float )( Math.Sin( radians ) );
float x = normalizedAxis.x;
float y = normalizedAxis.y;
float z = normalizedAxis.z;
var m = new Matrix3f();
m[ 0, 0 ] = x * x * ( 1.0f - cosTheta ) + cosTheta;
m[ 0, 1 ] = y * x * ( 1.0f - cosTheta ) - z * sinTheta;
m[ 0, 2 ] = z * x * ( 1.0f - cosTheta ) + y * sinTheta;
m[ 1, 0 ] = x * y * ( 1.0f - cosTheta ) + z * sinTheta;
m[ 1, 1 ] = y * y * ( 1.0f - cosTheta ) + cosTheta;
m[ 1, 2 ] = z * y * ( 1.0f - cosTheta ) - x * sinTheta;
m[ 2, 0 ] = x * z * ( 1.0f - cosTheta ) - y * sinTheta;
m[ 2, 1 ] = y * z * ( 1.0f - cosTheta ) + x * sinTheta;
m[ 2, 2 ] = z * z * ( 1.0f - cosTheta ) + cosTheta;
return m;
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:26,代码来源:Matrix3f.cs
示例11: SolidSphereHollowBox
public static bool SolidSphereHollowBox( Vector3f sphereCenter, float sphereRadius,
Vector3f boxCorner, Vector3f boxSize )
{
float dmin = 0;
var boxMax = boxCorner + boxSize;
bool face = false;
for( int i = 0; i < 3; ++i )
{
if( sphereCenter[ i ] < boxCorner[ i ] )
{
face = true;
dmin += ( sphereCenter[ i ] - boxCorner[ i ] ) * ( sphereCenter[ i ] - boxCorner[ i ] );
}
else if( sphereCenter[ i ] > boxMax[ i ] )
{
face = true;
dmin += ( sphereCenter[ i ] - boxMax[ i ] ) * ( sphereCenter[ i ] - boxMax[ i ] );
}
else if( sphereCenter[ i ] - boxCorner[ i ] <= sphereRadius )
{
face = true;
}
else if( boxMax[ i ] - sphereCenter[ i ] <= sphereRadius )
{
face = true;
}
}
return ( face && ( dmin <= sphereRadius * sphereRadius ) );
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:29,代码来源:BoxSphereIntersection.cs
示例12: SetParameter
public void SetParameter(string Parameter, Vector3f[] vec3array)
{
for (int i = 0; i < vec3array.Length; i++)
{
this.SetParameter(Parameter + i, vec3array[i]);
}
}
开发者ID:MSylvia,项目名称:space-station-14,代码行数:7,代码来源:GLSLShader.cs
示例13: Transformation
public Transformation ()
{
translation = new Vector3f(0,0,0);
scale = new Vector3f(1,1,1);
rotation = Matrix3f.Identity();
transformation = Matrix4f.Identity();
}
开发者ID:jwmarsden,项目名称:Kinetic3,代码行数:7,代码来源:Transformation.cs
示例14: CrossProduct
public static Vector3f CrossProduct(Vector3f left, Vector3f right)
{
return new Vector3f(
left.Y * right.Z - left.Z * right.Y,
left.Z * right.X - left.X * right.Z,
left.X * right.Y - left.Y * right.X);
}
开发者ID:FrenchData,项目名称:dotnetsamples,代码行数:7,代码来源:Util.cs
示例15: Draw
/// <summary>
/// 绘制风扇
/// </summary>
/// <param name="dxf"></param>
/// <param name="startPoint">风扇起点,如果为横置,由左向右;如果为竖置,由下到上</param>
/// <param name="endPoint">风扇终点,如果为横置,由左向右;如果为竖置,由下到上</param>
/// <param name="pointerLocation">箭头位置,默认=0为无,=1代表箭头在中间,=2代表箭头在底部</param>
public static void Draw(DxfDocument dxf, Vector3f startPoint, Vector3f endPoint,int pointerLocation=0)
{
Layer layer = new Layer("line");
Line line = new Line(startPoint, endPoint);
line.Layer = layer;
dxf.AddEntity(line);
//如果为横置
if (startPoint.Y == endPoint.Y)
{
float segment = (endPoint.X - startPoint.X) / 4;
Slash.Draw(dxf, new Location(startPoint.X + segment, startPoint.Y, startPoint.Z));
Slash.Draw(dxf, new Location(startPoint.X + 2 * segment, startPoint.Y, startPoint.Z));
Slash.Draw(dxf, new Location(startPoint.X + 3 * segment, startPoint.Y, startPoint.Z));
}
//如果为竖置
else if (startPoint.X == endPoint.X)
{
float segment = (endPoint.Y - startPoint.Y) / 5;
Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + segment, startPoint.Z));
Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 2 * segment, startPoint.Z));
Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 3 * segment, startPoint.Z));
Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 4 * segment, startPoint.Z));
if (pointerLocation == 1)
{
LinePointer.Draw(dxf,new Location(startPoint.X,(startPoint.Y+endPoint.Y)/2,startPoint.Z));
}
else if(pointerLocation==2)
{
LinePointer.Draw(dxf, new Location(startPoint.X, startPoint.Y, startPoint.Z));
}
}
}
开发者ID:Spritutu,项目名称:ntxx,代码行数:40,代码来源:Fan.cs
示例16: SetVertices
public void SetVertices(Vector3f[] verts)
{
if (fVertexBufferObject != null)
{
fVertexBufferObject.Dispose();
fVertexBufferObject = null;
}
// Write the vertex data to the buffer
GCHandle dataPtr = GCHandle.Alloc(verts, GCHandleType.Pinned);
int dataSize = Marshal.SizeOf(typeof(Vector3f)) * verts.Length;
fVertexBufferObject = new VertexBufferObject(GI);
fVertexBufferObject.Bind();
fVertexBufferObject.Size = dataSize;
try
{
fVertexBufferObject.Bind();
fVertexBufferObject.Write(dataPtr.AddrOfPinnedObject(), 0, dataSize);
}
finally
{
fVertexBufferObject.Unbind();
dataPtr.Free();
}
}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:27,代码来源:Mesh3D.cs
示例17: AddStore
public Vector3f AddStore(Vector3f other)
{
this.x += other.x;
this.y += other.y;
this.z += other.z;
return this;
}
开发者ID:ajmd17,项目名称:apexengine-sharp,代码行数:7,代码来源:Vector3f.cs
示例18: RotateBetween
public static Matrix3f RotateBetween( Vector3f from, Vector3f to )
{
from.Normalize();
to.Normalize();
var crossProduct = Vector3f.Cross( from, to );
var normalizedAxis = crossProduct.Normalized();
float sinTheta = crossProduct.Norm();
float cosTheta = Vector3f.Dot( from, to );
float x = normalizedAxis.x;
float y = normalizedAxis.y;
float z = normalizedAxis.z;
var m = new Matrix3f();
m[ 0, 0 ] = x * x * ( 1.0f - cosTheta ) + cosTheta;
m[ 0, 1 ] = y * x * ( 1.0f - cosTheta ) - z * sinTheta;
m[ 0, 2 ] = z * x * ( 1.0f - cosTheta ) + y * sinTheta;
m[ 1, 0 ] = x * y * ( 1.0f - cosTheta ) + z * sinTheta;
m[ 1, 1 ] = y * y * ( 1.0f - cosTheta ) + cosTheta;
m[ 1, 2 ] = z * y * ( 1.0f - cosTheta ) - x * sinTheta;
m[ 2, 0 ] = x * z * ( 1.0f - cosTheta ) - y * sinTheta;
m[ 2, 1 ] = y * z * ( 1.0f - cosTheta ) + x * sinTheta;
m[ 2, 2 ] = z * z * ( 1.0f - cosTheta ) + cosTheta;
return m;
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:30,代码来源:Matrix3f.cs
示例19: Camera
// TODO: get rid of ComputeProjectionMatrix()
public Camera( Vector3f position, Vector3f forward, Vector3f up,
float fovYDegrees,
int screenWidth, int screenHeight )
{
FieldOfView = Arithmetic.DegreesToRadians( fovYDegrees );
// interpolationKeyFrames = new KeyFrameInterpolator
Frame = new ManipulatedCameraFrame();
SceneRadius = 1.0f;
orthoCoeff = ( float ) ( Math.Tan( FieldOfView / 2.0 ) );
SceneCenter = Vector3f.Zero;
CameraType = CameraType.PERSPECTIVE;
ZNearCoefficient = 0.005f;
ZClippingCoefficient = ( float ) ( Math.Sqrt( 3.0 ) );
// dummy values
screenSize = new Vector2i( screenWidth, screenHeight );
Position = position;
UpVector = up;
ViewDirection = forward;
ComputeViewMatrix();
ComputeProjectionMatrix();
}
开发者ID:jiawen,项目名称:libcgt.net,代码行数:30,代码来源:Camera.cs
示例20: drag
//Mouse drag, calculate rotation
public void drag(Point NewPt, Quat4f NewRot)
{
//Map the point to the sphere
this.mapToSphere(NewPt, EnVec);
//Return the quaternion equivalent to the rotation
if (NewRot != null)
{
Vector3f Perp = new Vector3f();
//Compute the vector perpendicular to the begin and end vectors
Vector3f.cross(Perp, StVec, EnVec);
//Compute the length of the perpendicular vector
if (Perp.length() > Epsilon) //if its non-zero
{
//We're ok, so return the perpendicular vector as the transform after all
NewRot.x = Perp.x;
NewRot.y = Perp.y;
NewRot.z = Perp.z;
//In the quaternion values, w is cosine (theta / 2), where theta is rotation angle
NewRot.w = Vector3f.dot(StVec, EnVec);
}
else //if its zero
{
//The begin and end vectors coincide, so return an identity transform
NewRot.x = NewRot.y = NewRot.z = NewRot.w = 0.0f;
}
}
}
开发者ID:jesantana,项目名称:RSAGenerator,代码行数:31,代码来源:ArcBall.cs
注:本文中的Vector3f类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论