Has anyone an example code of creating material from image file including the setting of parameters like seen in the materials dialog. I need to set the rotation angle along with the U/V tile and U/V offsets at the same time. This example shows part but does not do rotation.
http://adndevblog.typepad.com/autocad/2012/05/setting-u-and-v-tile-scale-of-a-newly-created-material...
I am trying to make the image fit a rotated face that is usually of the same proportions as the image.
Hi
Did you try setting the mapper matrix to a rotation? In the example it is just set to a scale.
Alternatively you could try retrieving an existing texture info that is already rotated and check how its matrix looks like. Here is some incomplete code that illustrates how to access the texture properties:
[CommandMethod("MaterialInfo")] public void MaterialInfo() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; PromptEntityOptions peo = new PromptEntityOptions( "\nSelect a 3D solid: "); peo.SetRejectMessage("\nInvalid selection..."); peo.AddAllowedClass(typeof(Solid3d), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; using (Transaction Tx = db.TransactionManager.StartTransaction()) { Solid3d solid = Tx.GetObject(per.ObjectId, OpenMode.ForRead) as Solid3d; Material material = Tx.GetObject(solid.MaterialId, OpenMode.ForRead) as Material; MaterialMap map = material.Bump; if(map.Texture is ImageFileTexture) { ImageFileTexture imgTex = map.Texture as ImageFileTexture; ed.WriteMessage("\nSource file: " + imgTex.SourceFileName); } Mapper mapper = map.Mapper; //mapper.Transform is matrix3d... } }
Regards,
Philippe.
Can't find what you're looking for? Ask the community or share your knowledge.