/// <summary> /// Projects this vertex into camera space /// </summary> /// <param name="vertexProjection"></param> /// <param name="normalProjection"></param> /// <param name="camera"></param> public void Project(Matrix vertexProjection, Matrix normalProjection, Camera camera) { pos2 = pos.Transform(vertexProjection); n2 = n.Transform(normalProjection); fact = camera.screenscale / camera.fovfact / ((pos2.Z > 0.1) ? pos2.Z : 0.1f); X = (int)(pos2.X * fact + (camera.screenwidth >> 1)); Y = (int)(-pos2.Y * fact + (camera.screenheight >> 1)); Z = (int)(65536f * pos2.Z); nx = (int)(n2.X * 127 + 127); ny = (int)(n2.Y * 127 + 127); var sceneObject = getParent(); var materialTexture = sceneObject.material?.texture; if (materialTexture == null) { return; } tx = (int)(materialTexture.width * Tu); ty = (int)(materialTexture.height * Tv); }
public void Project(Matrix normalProjection) { n2 = n.Transform(normalProjection); dist = getDist(); }
// MATRIX MODIFIERS public void shift(float dx, float dy, float dz) { pos = pos.Transform(Matrix.shiftMatrix(dx, dy, dz)); lookat = lookat.Transform(Matrix.shiftMatrix(dx, dy, dz)); needsRebuild = true; }