internal void DrawPointList(List <Vector3> vertices, ref Matrix4 viewProjection) { GL.UseProgram(mProgramId); float[] v = HelperVector.ConvertVector3ToFloatArray(vertices); GL.UniformMatrix4(mUniform_MVP, false, ref viewProjection); GL.Uniform4(mUniform_BaseColor, 1.0f, 1.0f, 1.0f, 1.0f); int tmpVAO = GL.GenVertexArray(); GL.BindVertexArray(tmpVAO); int tmp = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, tmp); GL.BufferData(BufferTarget.ArrayBuffer, v.Length * 4, v, BufferUsageHint.StaticDraw); GL.VertexAttribPointer(mAttribute_vpos, 3, VertexAttribPointerType.Float, false, 0, 0); GL.EnableVertexAttribArray(mAttribute_vpos); GL.DrawArrays(PrimitiveType.Points, 0, v.Length / 3); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.DisableVertexAttribArray(0); GL.DeleteBuffer(tmp); GL.DeleteVertexArray(tmpVAO); GL.UseProgram(0); }
public override void Act(KeyboardState ks, MouseState ms) { if (_moving) { MoveAlongVector(_currentDirection, _speed * KWEngine.DeltaTimeFactor); currentLengthAfterCollision += (_currentDirection.LengthFast * _speed * KWEngine.DeltaTimeFactor); Console.WriteLine(currentLengthAfterCollision); } else { if (ks[Key.Space]) { _moving = true; } } Intersection intersection = GetIntersection(); if (intersection != null) { if (intersection.Object is ReflectPaddle) { if (currentLengthAfterCollision >= COOLDOWN) { MoveOffset(intersection.MTV); SetPositionZ(0); _currentDirection = HelperVector.ReflectVector(_currentDirection, intersection.ColliderSurfaceNormal); _currentDirection.Z = 0; // reset collision cooldown: currentLengthAfterCollision = 0; Console.WriteLine("-------------------------------------"); } } else { MoveOffset(intersection.MTV); SetPositionZ(0); _currentDirection = HelperVector.ReflectVector(_currentDirection, intersection.ColliderSurfaceNormal); _currentDirection.Z = 0; } } }