You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.I have a function that needs to display other wpf Windows on a plane surface,I did this by generating a png image(writeablebitmap) of the wpf window and using this image as the texture map,when ui changed,I have to keep creating textures ,My question is how to efficiently generate materials using writeablebimap?
key code:
var mashModel = new MeshGeometryModel3D();
MeshBuilder mb = new MeshBuilder();
mb.AddQuad(p1,p2,p3,p4);
mashModel .Geometry = mb.ToMesh();
if (mWriteableBitmap != null)
{
mWriteableBitmap.Changed -= Img_Changed;
}
mWriteableBitmap = service.GetImg(width, height);
if (mWriteableBitmap != null)
{
mWriteableBitmap.Changed += Img_Changed;
mDiffuseMaterial.DiffuseMap = new TextureModel((IntPtr)mWriteableBitmap.BackBuffer, SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb, (int)mWriteableBitmap.Width, (int)mWriteableBitmap.Height);
mashModel .Material = mDiffuseMaterial;
}
private void Img_Changed(object sender, EventArgs e)
{
Debug.WriteLine($"imagerefresh:{DateTime.Now.ToString("HH:mm:ss fff")}");
if (mDiffuseMaterial != null)
{
mDiffuseMaterial.DiffuseMap = new TextureModel((IntPtr)mWriteableBitmap.BackBuffer, SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb, (int)mWriteableBitmap.Width, (int)mWriteableBitmap.Height);;
}
}
you can see I have to keep creating TextureModel,is there a way to just update the TextureModel by mWriteableBitmap ??
Can i set the back face map uv(DiffuseMap)?
2.when i change the PerspectiveCamera to OrthographicCamera or OrthographicCamera to PerspectiveCamera,How do I calculate the relevant parameters(fov,width,position etc) to ensure that the 3d object remains the same size after switching?
The text was updated successfully, but these errors were encountered:
MichaelCHF
changed the title
some questions a boat sharpdx
some questions aboat sharpdx
Feb 18, 2024
Could you create a sample project for question 1? You probably will need to create your own texture loader to upload new bitmap data into texture object instead of creating new material in each frame.
1.I have a function that needs to display other wpf Windows on a plane surface,I did this by generating a png image(writeablebitmap) of the wpf window and using this image as the texture map,when ui changed,I have to keep creating textures ,My question is how to efficiently generate materials using writeablebimap?
key code:
you can see I have to keep creating TextureModel,is there a way to just update the TextureModel by mWriteableBitmap ??
Can i set the back face map uv(DiffuseMap)?
2.when i change the PerspectiveCamera to OrthographicCamera or OrthographicCamera to PerspectiveCamera,How do I calculate the relevant parameters(fov,width,position etc) to ensure that the 3d object remains the same size after switching?
The text was updated successfully, but these errors were encountered: