private static UserViewModel CreateUser(ColorGenerator generator, Random rand, int i) { string color = generator.NextColorString(); float r = 1f/255*int.Parse(color.Substring(0, 2), NumberStyles.HexNumber); float g = 1f/255*int.Parse(color.Substring(2, 2), NumberStyles.HexNumber); float b = 1f/255*int.Parse(color.Substring(4, 2), NumberStyles.HexNumber); Point3D point = GetPoint3DCoordinates(i, rand.NextDouble(), rand.NextDouble(), rand.NextDouble()); return new UserViewModel(i) { Brush = new RadialGradientBrush(Color.FromScRgb(0.85f, r, g, b), Color.FromScRgb(0.85f, r/2, g/2, b/2)), Head = new Point3D(point.X, point.Y - 100, point.Z), ShoulderCenter = new Point3D(point.X, point.Y - 60, point.Z), ShoulderLeft = new Point3D(point.X - 35, point.Y - 60, point.Z), ShoulderRight = new Point3D(point.X + 35, point.Y - 60, point.Z), ElbowLeft = new Point3D(point.X - 55, point.Y, point.Z), ElbowRight = new Point3D(point.X + 55, point.Y, point.Z), HandLeft = new Point3D(point.X - 50, point.Y + 65, point.Z), HandRight = new Point3D(point.X + 50, point.Y + 65, point.Z), Spine = point, HipLeft = new Point3D(point.X - 30, point.Y + 50, point.Z), HipRight = new Point3D(point.X + 30, point.Y + 50, point.Z), KneeLeft = new Point3D(point.X - 35, point.Y + 130, point.Z), KneeRight = new Point3D(point.X + 35, point.Y + 130, point.Z), FootLeft = new Point3D(point.X - 40, point.Y + 210, point.Z), FootRight = new Point3D(point.X + 40, point.Y + 210, point.Z), }; }
private void CreateUsers() { //Users = new ObservableCollection<UserViewModel>(); var generator = new ColorGenerator(); var rand = new Random((int) DateTime.Now.Ticks); //User = CreateUser(generator, rand, 1); for (int i = 1; i < 6; i++) { Users.Add(CreateUser(generator, rand, i)); } }
private static UserViewModel CreateUser(ColorGenerator generator, User user) { float r = 1f/255*user.Color.R; float g = 1f/255*user.Color.G; float b = 1f/255*user.Color.B; Point3D point = GetPoint3DCoordinates(user.Id, user.Spine.X, user.Spine.Y, user.Spine.Z); return new UserViewModel(user) { Color = Color.FromArgb((byte) 0.85f, (byte) r, (byte) g, (byte) b), Brush = new RadialGradientBrush(Color.FromScRgb(0.85f, r, g, b), Color.FromScRgb(0.85f, r/2, g/2, b/2)), Spine = point }; }
/// <summary> /// Initializes the specified usergenerator. /// </summary> internal void Initialize() { var generator = new ColorGenerator(); for (int i = 0; i < _colors.Length; i++) { _colors[i] = generator.NextColor(); } Context.DepthFrameReady += Context_DepthFrameReady; Context.VideoFrameReady += Context_VideoFrameReady; }