protected void UpdateTransformWorld(GraphicsDevice graphics, D3DRenderComponent render, GraphicEntity en) { var transform = en.GetComponent <TransformComponent>(); var matrixWorld = transform.MatrixWorld; //var isChanged = false; //if(en.TryGetComponent<MovingComponent>(out var moving)) { // isChanged = true; // matrixWorld *= moving.MovingMatrix; // en.RemoveComponent(moving); // en.UpdateComponent(TransformComponent.Create(matrixWorld)); //} if (!render.TransformWorldBuffer.HasValue) { var tr = TransforStructBuffer.ToTranspose(matrixWorld); if (render.TransformWorldBuffer.HasValue) { var buff = render.TransformWorldBuffer.Get(); graphics.UpdateDynamicBuffer(ref tr, buff); } else { var buff = graphics.CreateDynamicBuffer(ref tr, Unsafe.SizeOf <TransforStructBuffer>()); render.TransformWorldBuffer.Set(buff); } } }
protected void UpdateTransformWorld(GraphicsDevice graphics, ID3DTransformWorldRenderComponent render, TransformComponent transform) { if (transform.IsModified) { var tr = TransforStructBuffer.ToTranspose(transform.MatrixWorld); if (render.TransformWorldBuffer.HasValue) { var buff = render.TransformWorldBuffer.Get(); graphics.UpdateDynamicBuffer(ref tr, buff); } else { var buff = graphics.CreateDynamicBuffer(ref tr, Unsafe.SizeOf <TransforStructBuffer>()); render.TransformWorldBuffer.Set(buff); } transform.IsModified = false; } }
protected SharpDX.Direct3D11.Buffer CreateTransformWorldBuffer(GraphicsDevice graphics, ref TransformComponent transform) { var tr = TransforStructBuffer.ToTranspose(transform.MatrixWorld); return(graphics.CreateDynamicBuffer(ref tr, Unsafe.SizeOf <TransforStructBuffer>())); }