public void Initialize(HeadPoints headPoints, List <Vector3> facialFeatures, Vector2 topPoint) { if (facialFeatures.Count < headPoints.Points.Count) { return; } if (headPoints.Points.Count <= RootIndex) { return; } if (headPoints.Points.Count <= HelperIndex) { return; } rootPointWorld = headPoints.GetWorldPoint(RootIndex); var helperPointWorld = headPoints.GetWorldPoint(HelperIndex); rootPointPhoto = facialFeatures[RootIndex]; var helperPointPhoto = facialFeatures[HelperIndex]; float distWorld = rootPointWorld.X - helperPointWorld.X; float distPhoto = rootPointPhoto.X - helperPointPhoto.X; scale = distWorld / distPhoto; Initialize(facialFeatures, topPoint); }
//=================================== OLD =================================== public void ProcessPoints_old(ProjectedDots dots, HeadPoints points) { projectedDots = dots; headPoints = points; headIndices.Clear(); for (int i = 0; i < dots.Points.Count; ++i) { headIndices.Add(i); } var rotaionMatrix = ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.RotationMatrix; Matrix4.Invert(ref rotaionMatrix, out RotationMatrix); rightPower = 1.0f - Math.Abs(ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.HeadAngle) * 2.0f / (float)Math.PI; //rightPower = Math.Min(1.0f, Math.Max(rightPower, 0.0f)); // (float)Math.Cos(headPoints.HeadMesh.HeadAngle); rightVector = headPoints.GetWorldPoint(new Vector3(1.0f, 0.0f, 0.0f)); forwardVector = headPoints.GetWorldPoint(new Vector3(0.0f, 0.0f, 1.0f)); ProcessHeadPoints_old(); //SpecialAlignment(); // выравниваем точки рта-глаз-носа по центру лица // MirrorPoints(headPoints.HeadMesh.HeadAngle > 0.0f); // отразить форму лица зеркально }
private Vector3 ProcessHeadPoint(int index, Vector2 targetPoint) { Vector3 current = headPoints.GetWorldPoint(headPoints.OriginalPoints[index]); var point0 = new Vector3(targetPoint.X, targetPoint.Y, -1000.0f); var point1 = new Vector3(targetPoint.X, targetPoint.Y, 1000.0f); point0 = Vector4.Transform(new Vector4(point0), RotationMatrix).Xyz; point1 = Vector4.Transform(new Vector4(point1), RotationMatrix).Xyz; var p = point1 - point0; var t = current - point0; p.Normalize(); var dot = Vector3.Dot(t, p); var point3 = point0 + p * dot; return(point3); /*if (index == headIndices[44]) * { * Point0 = headPoints.GetWorldPoint(point0); * Point1 = headPoints.GetWorldPoint(point1); * * Point2 = current; * Point3 = headPoints.GetWorldPoint(point3); * }*/ }
public void DrawTriangles(HeadPoints headPoints) { GL.Begin(PrimitiveType.Triangles); GL.Color4(0.0f, 1.0f, 0.0f, 0.3f); foreach (var triangle in TrianglesFront) { var a = headPoints.GetWorldPoint(triangle.A); var b = headPoints.GetWorldPoint(triangle.B); var c = headPoints.GetWorldPoint(triangle.C); GL.Vertex3(a); GL.Vertex3(b); GL.Vertex3(c); } GL.End(); }
public void DrawTriangles(bool useProfilePoints) { GL.Begin(PrimitiveType.Triangles); GL.Color4(0.0f, 1.0f, 0.0f, 0.3f); var points = useProfilePoints ? TrianglesRight : TrianglesFront; foreach (var triangle in points) { var a = headPoints.GetWorldPoint(triangle.A); var b = headPoints.GetWorldPoint(triangle.B); var c = headPoints.GetWorldPoint(triangle.C); GL.Vertex3(a); GL.Vertex3(b); GL.Vertex3(c); } GL.End(); }
public void ProcessPoints(ProjectedDots dots, HeadPoints points) { projectedDots = dots; headPoints = points; rightVector = headPoints.GetWorldPoint(new Vector3(1.0f, 0.0f, 0.0f)); forwardVector = headPoints.GetWorldPoint(new Vector3(0.0f, 0.0f, 1.0f)); upVector = headPoints.GetWorldPoint(new Vector3(0.0f, 1.0f, 0.0f)); headIndices.Clear(); for (int i = 0; i < dots.Points.Count; ++i) { headIndices.Add(i); } var rotationMatrix = ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh.RotationMatrix; Matrix4.Invert(ref rotationMatrix, out RotationMatrix); ProcessHeadPoints(); FixLipsPoints(); }