本文整理汇总了C#中Matrix4.mutiply方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4.mutiply方法的具体用法?C# Matrix4.mutiply怎么用?C# Matrix4.mutiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4.mutiply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTrianglesGroupDoodads
void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot)
{
float dx = mi.pos.x;
float dy = mi.pos.y;
float dz = mi.pos.z;
rotate(dx, dz, rot + 90f, out dx, out dz);
dx += world_off.x;
dy += world_off.y;
dz += world_off.z;
Quaternion q;
q.x = mi.dir.z;
q.y = mi.dir.x;
q.z = mi.dir.y;
q.w = mi.w;
Matrix4 rotMatrix = new Matrix4();
rotMatrix.makeQuaternionRotate(q);
Model m = mi.model;
if (m.boundingTriangles == null)
{
}
else
{
// We got boiuding stuff, that is better
int nBoundingVertices = m.boundingVertices.Length / 3;
int[] vertices = new int[nBoundingVertices];
for (uint i = 0; i < nBoundingVertices; i++)
{
uint off = i * 3;
float x = m.boundingVertices[off];
float y = m.boundingVertices[off + 2];
float z = m.boundingVertices[off + 1];
x *= mi.sc;
y *= mi.sc;
z *= -mi.sc;
Vector pos;
pos.x = x;
pos.y = y;
pos.z = z;
Vector new_pos = rotMatrix.mutiply(pos);
x = pos.x;
y = pos.y;
z = pos.z;
float dir_x = world_dir.z;
float dir_y = world_dir.y - 90;
float dir_z = -world_dir.x;
rotate(z, y, dir_x, out z, out y);
rotate(x, y, dir_z, out x, out y);
rotate(x, z, dir_y, out x, out z);
float xx = x + dx;
float yy = y + dy;
float zz = -z + dz;
float finalx = ChunkReader.ZEROPOINT - zz;
float finaly = ChunkReader.ZEROPOINT - xx;
float finalz = yy;
vertices[i] = s.AddVertex(finalx, finaly, finalz);
}
int nBoundingTriangles = m.boundingTriangles.Length / 3;
for (uint i = 0; i < nBoundingTriangles; i++)
{
uint off = i * 3;
int v0 = vertices[m.boundingTriangles[off]];
int v1 = vertices[m.boundingTriangles[off + 1]];
int v2 = vertices[m.boundingTriangles[off + 2]];
s.AddTriangle(v0, v2, v1, ChunkedTriangleCollection.TriangleFlagModel);
}
}
}
示例2: AddTrianglesGroupDoodads
void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot)
{
float dx = mi.pos.x;
float dy = mi.pos.y;
float dz = mi.pos.z;
rotate(dx, dz, rot +90f, out dx, out dz);
dx += world_off.x;
dy += world_off.y;
dz += world_off.z;
Quaternion q;
q.x = -mi.dir.z; q.y = mi.dir.x; q.z = mi.dir.y; q.w = mi.w;
Matrix4 rotMatrix = new Matrix4();
rotMatrix.makeQuaternionRotate(q);
Model m = mi.model;
if (m.boundingTriangles == null)
{
/*
// /cry no bouding info, revert to normal vertices
ModelView mv = m.view[0]; // View number 1 ?!?!
int[] vertices = new int[m.vertices.Length / 3];
for (uint i = 0; i < m.vertices.Length / 3; i++)
{
float x = m.vertices[i * 3];
float y = m.vertices[i * 3 + 2];
float z = m.vertices[i * 3 + 1];
x *= mi.sc;
y *= mi.sc;
z *= -mi.sc;
Vector pos; pos.x = x; pos.y = y; pos.z = z;
Vector new_pos = rotMatrix.mutiply(pos);
x = pos.x; y = pos.y; z = pos.z;
rotate(x, z, (world_dir.y - 90), out x, out z);
rotate(y, z, -world_dir.x, out y, out z);
rotate(x, y, world_dir.z, out x, out y);
float xx = x + dx;
float yy = y + dy;
float zz = -z + dz;
float finalx = ChunkReader.ZEROPOINT - zz;
float finaly = ChunkReader.ZEROPOINT - xx;
float finalz = yy;
vertices[i] = s.AddVertex(finalx, finaly, finalz);
}
for (int i = 0; i < mv.triangleList.Length / 3; i++)
{
int off = i * 3;
UInt16 vi0 = mv.triangleList[off];
UInt16 vi1 = mv.triangleList[off + 1];
UInt16 vi2 = mv.triangleList[off + 2];
int ind0 = mv.indexList[vi0];
int ind1 = mv.indexList[vi1];
int ind2 = mv.indexList[vi2];
int v0 = vertices[ind0];
int v1 = vertices[ind1];
int v2 = vertices[ind2];
s.AddTriangle(v0, v1, v2, ChunkedTriangleCollection.TriangleFlagModel);
}
*/
}
else
{
// We got boiuding stuff, that is better
int nBoundingVertices = m.boundingVertices.Length / 3;
int[] vertices = new int[nBoundingVertices];
for (uint i = 0; i < nBoundingVertices; i++)
{
uint off = i * 3;
float x = m.boundingVertices[off];
float y = m.boundingVertices[off + 2];
float z = m.boundingVertices[off + 1];
x *= mi.sc;
y *= mi.sc;
z *= -mi.sc;
Vector pos; pos.x = x; pos.y = y; pos.z = z;
Vector new_pos = rotMatrix.mutiply(pos);
x = pos.x; y = pos.y; z = pos.z;
rotate(x, z, (world_dir.y - 90), out x, out z);
rotate(y, z, -world_dir.x, out y, out z);
rotate(x, y, world_dir.z, out x, out y);
float xx = x + dx;
float yy = y + dy;
float zz = -z + dz;
//.........这里部分代码省略.........