本文整理汇总了C#中System.Vector3.TransformNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.TransformNormal方法的具体用法?C# Vector3.TransformNormal怎么用?C# Vector3.TransformNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.TransformNormal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updateDraw
/// <summary>
/// Actualiza la posicion de los vertices que componen las tapas
/// </summary>
private void updateDraw()
{
if (this.vertices == null)
this.vertices = new CustomVertex.PositionColored[END_CAPS_VERTEX_COUNT + 4]; //4 para los bordes laterales
int color = this.color.ToArgb();
Vector3 zeroVector = this.center;
//matriz que vamos a usar para girar el vector de dibujado
float angle = FastMath.TWO_PI / (float)END_CAPS_RESOLUTION;
Vector3 upVector = this.halfHeight;
Matrix rotationMatrix = Matrix.RotationAxis(new Vector3(0, 1, 0), angle);
//vector de dibujado
Vector3 n = new Vector3(this.radius, 0, 0);
//array donde guardamos los puntos dibujados
Vector3[] draw = new Vector3[END_CAPS_VERTEX_COUNT];
for (int i = 0; i < END_CAPS_VERTEX_COUNT / 2; i += 2)
{
//vertice inicial de la tapa superior
draw[i] = zeroVector + upVector + n;
//vertice inicial de la tapa inferior
draw[END_CAPS_VERTEX_COUNT / 2 + i] = zeroVector - upVector + n;
//rotamos el vector de dibujado
n.TransformNormal(rotationMatrix);
//vertice final de la tapa superior
draw[i + 1] = zeroVector + upVector + n;
//vertice final de la tapa inferior
draw[END_CAPS_VERTEX_COUNT / 2 + i + 1] = zeroVector - upVector + n;
}
for (int i = 0; i < END_CAPS_VERTEX_COUNT; i++)
this.vertices[i] = new CustomVertex.PositionColored(draw[i], color);
}
示例2: updateDraw
private void updateDraw()
{
//vectores utilizados para el dibujado
Vector3 upVector = new Vector3(0, 1, 0);
Vector3 n = new Vector3(1, 0, 0);
int capsResolution = END_CAPS_RESOLUTION;
//matriz de rotacion del vector de dibujado
float angleStep = FastMath.TWO_PI / (float)capsResolution;
Matrix rotationMatrix = Matrix.RotationAxis(-upVector, angleStep);
float angle = 0;
//transformacion que se le aplicara a cada vertice
Matrix transformation = this.Transform;
float bcInverseRadius = 1 / this.boundingCylinder.Radius;
//arrays donde guardamos los puntos dibujados
Vector3[] topCapDraw = new Vector3[capsResolution];
Vector3[] bottomCapDraw = new Vector3[capsResolution];
//variables temporales utilizadas para el texture mapping
float u;
for (int i = 0; i < capsResolution; i++)
{
//establecemos los vertices de las tapas
topCapDraw[i] = upVector + (n * this.topRadius * bcInverseRadius);
bottomCapDraw[i] = -upVector + (n * this.bottomRadius * bcInverseRadius);
u = angle / FastMath.TWO_PI;
//triangulos de la cara lateral (strip)
this.sideTrianglesVertices[2 * i] = new CustomVertex.PositionColoredTextured(topCapDraw[i], color, u, 0);
this.sideTrianglesVertices[2 * i + 1] = new CustomVertex.PositionColoredTextured(bottomCapDraw[i], color, u, 1);
//rotamos el vector de dibujado
n.TransformNormal(rotationMatrix);
angle += angleStep;
}
//cerramos la cara lateral
this.sideTrianglesVertices[2 * capsResolution] = new CustomVertex.PositionColoredTextured(topCapDraw[0], color, 1, 0);
this.sideTrianglesVertices[2 * capsResolution + 1] = new CustomVertex.PositionColoredTextured(bottomCapDraw[0], color, 1, 1);
}
示例3: updateDraw
/// <summary>
/// Actualiza la posicion de los vertices que componen las tapas
/// </summary>
private void updateDraw()
{
if (this.vertices == null)
this.vertices = new CustomVertex.PositionColored[END_CAPS_VERTEX_COUNT + 4]; //4 para los bordes laterales
int color = this.color.ToArgb();
//matriz que vamos a usar para girar el vector de dibujado
float angle = FastMath.TWO_PI / (float)END_CAPS_RESOLUTION;
Vector3 upVector = new Vector3(0, 1, 0);
Matrix rotationMatrix = Matrix.RotationAxis(upVector, angle);
//vector de dibujado
Vector3 n = new Vector3(1, 0, 0);
//array donde guardamos los puntos dibujados
Vector3[] draw = new Vector3[this.vertices.Length];
for (int i = 0; i < END_CAPS_VERTEX_COUNT / 2; i += 2)
{
//vertice inicial de la tapa superior
draw[i] = upVector + n;
//vertice inicial de la tapa inferior
draw[END_CAPS_VERTEX_COUNT / 2 + i] = -upVector + n;
//rotamos el vector de dibujado
n.TransformNormal(rotationMatrix);
//vertice final de la tapa superior
draw[i + 1] = upVector + n;
//vertice final de la tapa inferior
draw[END_CAPS_VERTEX_COUNT / 2 + i + 1] = -upVector + n;
}
//rotamos y trasladamos los puntos, y los volcamos al vector de vertices
Matrix transformation = this.transformation;
for (int i = 0; i < END_CAPS_VERTEX_COUNT; i++)
this.vertices[i] = new CustomVertex.PositionColored(Vector3.TransformCoordinate(draw[i], transformation), color);
}
示例4: ExtractModelAsSingleMesh
//.........这里部分代码省略.........
int x = this.PermutationInfo[tx].sceneryIndex;
if ((this.BSPPermutationRawDataMetaChunks[x].RawDataChunkInfo.Length == 0) ||
(this.BSPPermutationRawDataMetaChunks[x].VerticeCount == 0))
{
continue;
}
for (int y = 0; y < this.BSPPermutationRawDataMetaChunks[x].VerticeCount; y++)
{
Vector3 tv3 = new Vector3(
this.BSPPermutationRawDataMetaChunks[x].Vertices[y].X,
this.BSPPermutationRawDataMetaChunks[x].Vertices[y].Y,
this.BSPPermutationRawDataMetaChunks[x].Vertices[y].Z);
tv3.TransformCoordinate(this.PermutationInfo[tx].mat);
string temps = "v " + tv3.X.ToString("R") + " " + tv3.Y.ToString("R") + " " + tv3.Z.ToString("R");
SW.WriteLine(temps);
}
SW.WriteLine("# " + this.BSPPermutationRawDataMetaChunks[x].Vertices.Count + " vertices");
for (int y = 0; y < this.BSPPermutationRawDataMetaChunks[x].VerticeCount; y++)
{
string temps = "vt " + this.BSPPermutationRawDataMetaChunks[x].UVs[y].X.ToString("R") + " " +
this.BSPPermutationRawDataMetaChunks[x].UVs[y].Y.ToString("R");
SW.WriteLine(temps);
}
SW.WriteLine("# " + this.BSPPermutationRawDataMetaChunks[x].Vertices.Count + " texture vertices");
for (int y = 0; y < this.BSPPermutationRawDataMetaChunks[x].VerticeCount; y++)
{
Vector3 tv3 = new Vector3(
this.BSPPermutationRawDataMetaChunks[x].Normals[y].X,
this.BSPPermutationRawDataMetaChunks[x].Normals[y].Y,
this.BSPPermutationRawDataMetaChunks[x].Normals[y].Z);
tv3.TransformNormal(this.PermutationInfo[tx].mat);
string temps = "vn " + tv3.X.ToString("R") + " " + tv3.Y.ToString("R") + " " + tv3.Z.ToString("R");
/*
string temps = "vn " + this.BSPPermutationRawDataMetaChunks[x].Normals[y].X.ToString()
+ " " + this.BSPPermutationRawDataMetaChunks[x].Normals[y].Y.ToString()
+ " " + this.BSPPermutationRawDataMetaChunks[x].Normals[y].Z.ToString();
*/
SW.WriteLine(temps);
}
SW.WriteLine("# " + this.BSPPermutationRawDataMetaChunks[x].Vertices.Count + " normals");
for (int y = 0; y < this.BSPPermutationRawDataMetaChunks[x].SubMeshInfo.Length; y++)
{
SW.WriteLine("g " + tx + "." + y);
SW.WriteLine(
"usemtl " + names[this.BSPPermutationRawDataMetaChunks[x].SubMeshInfo[y].ShaderNumber]);
// int[] shite = new int[100000];
int[] shite = new int[this.BSPPermutationRawDataMetaChunks[x].SubMeshInfo[y].IndiceCount];
int s = 0;
if (this.BSPPermutationRawDataMetaChunks[x].FaceCount * 3 !=
this.BSPPermutationRawDataMetaChunks[x].IndiceCount)
{
int m = this.BSPPermutationRawDataMetaChunks[x].SubMeshInfo[y].IndiceStart;
bool dir = false;
short tempx;
short tempy;
short tempz;
do
{
示例5: Intersect
public override int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace )
{
Matrix myModelSpace = scalingMatrix * rotationMatrix * translationMatrix * worldSpace;
// transform world space to object space
Vector3 pickRayOriginTemp = new Vector3(rayPosition.X, rayPosition.Y, rayPosition.Z);
Vector3 pickRayDirectionTemp = new Vector3(rayDirection.X,rayDirection.Y,rayDirection.Z);
// convert ray from 3d space to model space
pickRayOriginTemp.TransformCoordinate(Matrix.Invert(myModelSpace));
pickRayDirectionTemp.TransformNormal (Matrix.Invert(myModelSpace));
// check to see if I intersect
int zDistance = CheckIntersect(pickRayOriginTemp,pickRayDirectionTemp);
if (zDistance > 0)
{
obj = this;
}
if (_children != null)
{
foreach (Object3DCommon childObj in _children)
{
int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace);
if (newZDistance > zDistance)
{
zDistance = newZDistance;
}
}
}
return zDistance;
}
示例6: updateDraw
private void updateDraw()
{
//vectores utilizados para el dibujado
Vector3 upVector = new Vector3(0, 1, 0);
Vector3 n = new Vector3(1, 0, 0);
int capsResolution = END_CAPS_RESOLUTION;
//matriz de rotacion del vector de dibujado
float angleStep = FastMath.TWO_PI / (float)capsResolution;
Matrix rotationMatrix = Matrix.RotationAxis(-upVector, angleStep);
float angle = 0;
//transformacion que se le aplicara a cada vertice
Matrix transformation = this.Transform;
//arrays donde guardamos los puntos dibujados
Vector3[] topCapDraw = new Vector3[capsResolution];
Vector3[] bottomCapDraw = new Vector3[capsResolution];
//Vector3 topCapCenter = Vector3.TransformCoordinate(upVector, transformation);
//Vector3 bottomCapCenter = Vector3.TransformCoordinate(-upVector, transformation);
Vector3 topCapCenter = upVector;
Vector3 bottomCapCenter = -upVector;
for (int i = 0; i < capsResolution; i++)
{
//establecemos los vertices de las tapas
//topCapDraw[i] = Vector3.TransformCoordinate(upVector + n, transformation);
//bottomCapDraw[i] = Vector3.TransformCoordinate(-upVector + n, transformation);
topCapDraw[i] = upVector + n;
bottomCapDraw[i] = -upVector + n;
float u = angle / FastMath.TWO_PI;
//triangulos de la cara lateral (strip)
this.sideTrianglesVertices[2 * i] = new CustomVertex.PositionColoredTextured(topCapDraw[i], color, u, 0);
this.sideTrianglesVertices[2 * i + 1] = new CustomVertex.PositionColoredTextured(bottomCapDraw[i], color, u, 1);
//triangulos de la tapa superior (list)
if (i > 0) this.capsTrianglesVertices[3 * i] = new CustomVertex.PositionColoredTextured(topCapDraw[i - 1], color, FastMath.Cos(angle - angleStep), FastMath.Sin(angle - angleStep));
this.capsTrianglesVertices[3 * i + 1] = new CustomVertex.PositionColoredTextured(topCapDraw[i], color, FastMath.Cos(angle), FastMath.Sin(angle));
this.capsTrianglesVertices[3 * i + 2] = new CustomVertex.PositionColoredTextured(topCapCenter, color, 0.5f, 0.5f);
//triangulos de la tapa inferior (list)
if (i > 0) this.capsTrianglesVertices[3 * i + 3 * capsResolution] = new CustomVertex.PositionColoredTextured(bottomCapDraw[i - 1], color, FastMath.Cos(angle - angleStep), FastMath.Sin(angle - angleStep));
this.capsTrianglesVertices[3 * i + 1 + 3 * capsResolution] = new CustomVertex.PositionColoredTextured(bottomCapDraw[i], color, FastMath.Cos(angle), FastMath.Sin(angle)); ;
this.capsTrianglesVertices[3 * i + 2 + 3 * capsResolution] = new CustomVertex.PositionColoredTextured(bottomCapCenter, color, 0.5f, 0.5f);
//rotamos el vector de dibujado
n.TransformNormal(rotationMatrix);
angle += angleStep;
}
//cerramos la cara lateral
this.sideTrianglesVertices[2 * capsResolution] = new CustomVertex.PositionColoredTextured(topCapDraw[0], color, 1, 0);
this.sideTrianglesVertices[2 * capsResolution + 1] = new CustomVertex.PositionColoredTextured(bottomCapDraw[0], color, 1, 1);
//cerramos la tapa superior
this.capsTrianglesVertices[0] = new CustomVertex.PositionColoredTextured(topCapDraw[capsResolution - 1], color, FastMath.Cos(-angleStep), FastMath.Sin(-angleStep));
//Cerramos la tapa inferior
this.capsTrianglesVertices[3 * capsResolution] = new CustomVertex.PositionColoredTextured(bottomCapDraw[capsResolution - 1], color, FastMath.Cos(-angleStep), FastMath.Sin(-angleStep));
}