static void TransferDataCustomProjections() { var mapping = MyMapping.MapDiscard(RC, m_cbCustomProjections); for (int i = 0; i < MyRenderProxy.BillboardsViewProjectionRead.Count; i++) { MyBillboardViewProjection viewprojection = MyRenderProxy.BillboardsViewProjectionRead[i]; var scaleX = viewprojection.Viewport.Width / (float)MyRender11.ViewportResolution.X; var scaleY = viewprojection.Viewport.Height / (float)MyRender11.ViewportResolution.Y; var offsetX = viewprojection.Viewport.OffsetX / (float)MyRender11.ViewportResolution.X; var offsetY = (MyRender11.ViewportResolution.Y - viewprojection.Viewport.OffsetY - viewprojection.Viewport.Height) / (float)MyRender11.ViewportResolution.Y; var viewportTransformation = new Matrix( scaleX, 0, 0, 0, 0, scaleY, 0, 0, 0, 0, 1, 0, offsetX, offsetY, 0, 1 ); var transpose = Matrix.Transpose(viewprojection.ViewAtZero * viewprojection.Projection * viewportTransformation); mapping.WriteAndPosition(ref transpose); } for (int i = MyRenderProxy.BillboardsViewProjectionRead.Count; i < MAX_CUSTOM_PROJECTIONS_SIZE; i++) { mapping.WriteAndPosition(ref Matrix.Identity); } mapping.Unmap(); }
public static void AddBillboardViewProjection(int id, MyBillboardViewProjection billboardViewProjection) { MyBillboardViewProjection existingBillboardViewProjection; if (!BillboardsViewProjectionWrite.TryGetValue(id, out existingBillboardViewProjection)) { BillboardsViewProjectionWrite.Add(id, billboardViewProjection); } else { BillboardsViewProjectionWrite[id] = billboardViewProjection; } }