public FloatTween(SceneTime time, EasingType type, Action <float> setter, float duration, float startValue, float finishValue, Action finishCallback) : base(time, type, duration, startValue, finishValue, finishCallback) { Assert.NotNull(setter); _setter = setter; }
public NetGLControl() { if (DesignMode) { AddLabel("3D will be here"); return; } var time = new SceneTime(); Graphics graphics = null; try { graphics = new Graphics(this, time, ShadingTechnique.Forward); } catch (GLException ex) { Log.Exception(ex); AddLabel("Failed to initialize 3D: " + ex.Message); return; } Graphics = graphics; _scene = new Scene.Scene(this, graphics, time); RenderDispatcher = RenderDispatcher.Current; SetStyle(ControlStyles.UserPaint, false); StartRenderLoop(); }
public PositionTween(SceneTime time, EasingType type, float duration, Vector3 finishPosition, Transform transform, Action finishCallback) : base(time, type, duration, 0, 1, finishCallback) { Assert.NotNull(transform); StartPosition = transform.WorldPosition; FinishPosition = finishPosition; Transform = transform; }
public RotationTween(SceneTime time, EasingType type, float duration, Quaternion finishRotation, Transform transform, Action finishCallback) : base(time, type, duration, 0, 1, finishCallback) { Assert.NotNull(transform); StartRotation = transform.WorldRotation; FinishRotation = finishRotation; Transform = transform; }
public ShakeTween(SceneTime time, Transform transform, float speed, Vector3 scale) { Assert.NotNull(transform); Assert.NotNull(time); _time = time; Speed = 1; Transform = transform; Scale = scale; _startPosition = Transform.LocalPosition; }
protected TweenBase(SceneTime time, EasingType type, float duration, float startValue, float finishValue, Action finishCallback) { Assert.NotNull(time); _time = time; _startTime = time.CurrentFloat; _current = 0; _duration = duration; _finishTime = _duration + _startTime; _function = EasingFunctions.Get(type); _state = TweenState.Working; _startValue = startValue; _finishValue = finishValue; _finishCallback = finishCallback; }
public ParticleRenderer(SceneTime time) { if (time == null) { throw new ArgumentNullException("time"); } MaxParticles = 1000; _particleCount = MaxParticles; _time = time; _glContext = GL.GetCurrent(true); _particlePositions = new Vector3Buffer(MaxParticles); _particleColors = new Vector4Buffer(MaxParticles); _particleData1 = new Vector4Buffer(MaxParticles); _particleData2 = new Vector4Buffer(MaxParticles); _particleData3 = new Vector4Buffer(MaxParticles); _computeData = new DataBuffer(); _computeData.Usage = BufferUsage.DynamicDraw; InitBufferValues(); _vertexBufferArray = new VertexArrayObject(); _positionsBuffer = _vertexBufferArray.SetAttributeData(StandardAttribute.Position, _particlePositions, false); _colorsBuffer = _vertexBufferArray.SetAttributeData(StandardAttribute.Color, _particleColors, false); _dataBuffer1 = _vertexBufferArray.SetAttributeData(StandardAttribute.Data1, _particleData1, false); _dataBuffer2 = _vertexBufferArray.SetAttributeData(StandardAttribute.Data2, _particleData2, false); _dataBuffer3 = _vertexBufferArray.SetAttributeData(StandardAttribute.Data3, _particleData3, false); _computeDataBuffer = new BufferObject(BufferObjectTypes.ShaderStorage); _computeShader = ShaderProgram.CreateCompute(Resources.Particles_comp); _computeDataBuffer.BufferData(_computeData); _prevTime = _time.CurrentFloat; _boundSphere = new Sphere(Vector3.Zero, 0.5f); }
public Graphics(UserControl control, SceneTime time, ShadingTechnique technique) { Assert.NotNull(control); Assert.NotNull(time); IsDisposed = false; CurrentShadingTechnique = technique; if (GL.GetCurrent(false) != null || GetCurrent(false) != null) { var error = "Only one NetGL view per thread is now supported. Try launching 3D view in different thread."; Log.Error(error); throw new InvalidOperationException(error); } _control = control; _time = time; try { _glContext = new GL(_control.Handle); } catch { Dispose(); throw; } _currentContext.Value = this; _glContext.Enable(EnableCap.DepthTest); _glContext.Enable(EnableCap.Texture2D); _glContext.Enable(EnableCap.CullFace); _glContext.Enable(EnableCap.ProgramPointSize); _glContext.Enable(EnableCap.PointSprite); _glContext.CullFace(MaterialFace.Back); _glContext.FrontFace(FrontFaceDirection.CounterClockwise); _glContext.BlendEquation(BlendEquations.FuncAdd); _glContext.BlendFunc(BlendMode.SrcAlpha, BlendMode.OneMinusSrcAlpha); _glContext.SwapInterval(_swapInterval); _globalUniforms = new GlobalUniformsBufferObject(); _standartUniforms = new StandardUniformsBufferObject(); _defaultMaterial = new Material(MaterialType.DiffuseColor); _blankTexture = new Texture2(); _blankTexture.SetImage(new byte[4] { 255, 0, 255, 255 }, new Size(1, 1), Core.PixelFormat.Rgba, Core.PixelInternalFormat.Rgba8); _quadShader = new QuadShader(); _displayQuadVao = CreateDisplayQuadVao(); switch (CurrentShadingTechnique) { case ShadingTechnique.Forward: _renderTechnique = new ForwardRender(); break; case ShadingTechnique.Deferred: _renderTechnique = new DeferredRender(); break; default: throw new NotSupportedException(CurrentShadingTechnique.ToString()); } ScreenSize = _control.ClientSize; }