| McNeel Wiki | |||||
| edit · print · help · all topics | |||||
Main Pages
Languages
| QuestionHow can I tell when the user has applied custom texture mapping to an object using the Texture Mapping page in the Object Properties dialog? AnswerCustom texture mappings are specific to each render plug-in. All texture mapping information is stored in an ON_ObjectRenderingAttributes object that is stored in the Rhino object's attributes. You can test for the existance of a render plug-in specific mapping reference as follows: C++
CRhinoGetObject go;
go.SetCommandPrompt( L"Select object" );
go.GetObjects( 1, 1 );
if( go.CommandResult() != success )
return go.CommandResult();
const CRhinoObject* object = go.Object(0).Object();
if( 0 == object )
return failure;
const CRhinoObjectAttributes attributes = object->Attributes();
// See if the default renderer has a mapping reference
ON_UUID render_uuid = RhinoApp().GetDefaultRenderApp();
const ON_MappingRef* mapping_ref = attributes.m_rendering_attributes.MappingRef( render_uuid );
if( mapping_ref )
RhinoApp().Print( L"Object uses custom texture mapping.\n" );
else
RhinoApp().Print( L"Object uses default texture mapping.\n" );
C# (Rhino 4)
MRhinoGetObject go = new MRhinoGetObject();
go.SetCommandPrompt( "Select object" );
go.GetObjects( 1, 1 );
if( go.CommandResult() != IRhinoCommand.result.success )
return go.CommandResult();
IRhinoObject rhObj = go.Object(0).Object();
if( rhObj == null )
return IRhinoCommand.result.failure;
IRhinoObjectAttributes attributes = rhObj.Attributes();
// See if the default renderer has a mapping reference
System.Guid render_uuid = RhUtil.RhinoApp().GetDefaultRenderApp();
IOnMappingRef mapping_ref = attributes.m_rendering_attributes.MappingRef(ref render_uuid);
if( mapping_ref != null )
RhUtil.RhinoApp().Print( "Object uses custom texture mapping.\n" );
else
RhUtil.RhinoApp().Print( "Object uses default texture mapping.\n" );
VB.NET (Rhino 4)
Dim go As New MRhinoGetObject()
go.SetCommandPrompt("Select object")
go.GetObjects(1, 1)
If (go.CommandResult() <> IRhinoCommand.result.success) Then
Return go.CommandResult()
End If
Dim rhObj As IRhinoObject = go.Object(0).Object()
If (rhObj Is Nothing) Then Return IRhinoCommand.result.failure
Dim attributes As IRhinoObjectAttributes = rhObj.Attributes()
' See if the default renderer has a mapping reference
Dim render_uuid As System.Guid = RhUtil.RhinoApp().GetDefaultRenderApp()
Dim mapping_ref As IOnMappingRef = attributes.m_rendering_attributes.MappingRef(render_uuid)
If (mapping_ref IsNot Nothing) Then
RhUtil.RhinoApp().Print("Object uses custom texture mapping." + vbCrLf)
Else
RhUtil.RhinoApp().Print("Object uses default texture mapping." + vbCrLf)
End If
| ||||
| rename · changes · history · subscriptions · lost and found · references · file upload | |||||