![]() |
|
changing material/texture at runtime - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Viewer3ds and Ab3d.Reader3ds (https://forum.ab4d.com/forumdisplay.php?fid=5) +--- Thread: changing material/texture at runtime (/showthread.php?tid=51) |
changing material/texture at runtime - glindo - 07-29-2010 Hello. I am new to WPF and am evaluating the reader3ds library for use with a mixed 2d/3d application. I have a 3d object which i was able to import from a 3ds file, with animation, using reader3ds - very easy! What I want to do now is to swap out the uvmapped texture on the fly, as a response to certain user input. Any help I could get with this would be very much appreciated! P.S. - I understand that this might be a WPF question, not specifically related to your product. If so, I apologize if this thread is inappropriate. RE: changing material/texture at runtime - abenedik - 08-11-2010 Hi, Sorry for not answering for so long. If I understand you correctly you would like to show the texture image with the lines that would represent the unwrapped uv maps at runtime from shown 3d model. The texture image can be get from the object's Model - it should be a DifffuseModel with ImageBrush. The lines of the unwrapped uv maps can be get from the TexureCoordinates. For example if the TexureCoordinates[0] == (0.5, 0.5) andTexureCoordinates[1] == (1.0, 1.0) this means that the first Position (from Positions collection) will use the middle pixel (0.5, 0.5 is in relative coordinates) from the texture image. The second Position will use the bottom right pixel of the texture. So you can simply add lines to the texture image based on the TexureCoordinates. A good description of using TextureCoordinates can be found on http://blogs.msdn.com/b/danlehen/archive/2005/11/06/489627.aspx |