i generate 3D model with patch i want to put an image in the floor of the 3d patch. in other word i want to do superimpose

7 views (last 30 days)
overlay 3d patch over an image

Answers (1)

Walter Roberson
Walter Roberson on 20 May 2015
  2 Comments
Walter Roberson
Walter Roberson on 20 May 2015
There are different possibilities about what you mean:
  • if you are trying to make an image part of the patch, as if the image was painted on to the outside of the patch, then you need to use "texture mapping". The above Answer discusses how to do that. You might find it convenient to use this File Exchange Contribution to assist in that.
  • You might be wanting the patch to appear on top of an image when looking "straight down" from above. If so, then just image() the image into place and build the patch object, and make sure your view() is from above. In this special case of looking straight "down" at an image, it will appear properly. Note that if any of the Z coordinates of the patch are negative, the visual effect might depend upon which Renderer is in effect for your figure.
  • You might be wanting the patch to appear on top of the image when looking straight down normally, but you might be wanting the user to be able to rotate the view in 3D and you want the image and patch to keep the same relative positions with the image continuing to be visible but "tilted" as the user moves in 3D. In this case, you have problems: image() objects are defined strictly in 2 dimensions, and can disappear if looked at from any direction other than straight down. If this is the situation, then you need to create a flat 3D patch() or flat 3D surface() object and texture map the image on to it according to the instructions referred to above. Be sure to use 3D coordinates in defining the flat patch() even if it is a constant Z coordinate.
  • You might be wanting the patch to always appear "on top" with the image staying in place as "background" even as the user rotates in 3D. If this is the situation, then you need to use two different axes objects, one to hold the image and the other to hold the patch, with the patch axes being drawn on top (draw it after the image) so that the interactive tools can interact with it. Set the Background property of the patch axes to 'none' so that whatever is underneath it (the image) can show behind it.
You specifically said that your patch was 3D. There is an additional consideration if your patch is defined in 2D coordinates and if you are using the OpenGL Renderer (which would always be the case if you have any Alpha transparency in your figure.) OpenGL has a very specific order of rendering object based upon the type of object rather than upon the order the objects were drawn in; the other two renderers depend upon the order the objects were drawn in. Some graphics drivers implement the defined drawing order for OpenGL exactly backwards. Therefore if you have a 2D patch object mixed in with an image() object, and you are using OpenGL, you cannot be certain which one will appear "on top", and using uistack() or changing the order of the Children of the axes will not have any effect. In such a case, to be sure that the 2D patch will appear above or below the image (as desired), make the 2D patch 3D instead, assigning a Z value that is greater than 0 if you want the patch "above" the image and less than 0 if you want the patch "below" the image.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!