Show Edges and Wireframe

This example includes two related examples:

The difference between Wireframe and ShowEdges is illustrated in the figure below, which shows how the two examples render the same mesh.

Comparison of Wireframe and ShowEdges

Example Files

Location
ShowEdges
show_edges.spdl
show_edges.cpp
show_edges.h
show_edges_dll.cpp
show_edges.vcproj
GNUmakefile
WireFrame Files
WireframeOp.cpp
WireframeShader.cpp
WireframeShader.spdl
Wireframe.vcproj
GNUmakefile

Running the Example

To run the ShowEdges example

  1. In a script editor, run this demo script:

    // [ Jscript ] Demo script for ShowEdges
    
    NewScene( null, false );
    var oSphere = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" );
    SelectObj( oSphere );
    
    var oMaterial = oSphere.AddMaterial( "show_edges.Preset",false,"ShowEdges");
    InspectObj( oMaterial.Parameters("Surface").Source );
    
  2. Draw a render region.

To run the Wireframe example

  1. In a script editor, run this demo script:

    '[VBScript] Demo program for the Wireframe Softimage shader example
    
    NewScene , false
    
    ' Create test sphere
    set object = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )
    
    SetupObject object
    
    'Shadow effect
    set oGrid = ActiveSceneRoot.AddGeometry( "Grid", "MeshSurface" )
    Translate oGrid, 0, -5, 0, siAbsolute, siParent, siObj, siY
    oGrid.ulength = 100
    oGrid.vlength = 100
    SetValue "light.light.soft_light.shadow", True
    
    sub SetupObject( in_obj )
    
            ' Add the UserDataBlob property and set it renderable
            ' The UserDataID must be set to the specific ID that
            ' the shader is expecting
    
            set prop = in_obj.AddProperty( "UserDataBlob" )
            prop.RenderData = True
            prop.UserDataID = 6789
    
            on error resume next
            prop.AddCustomOp "WireframeOp",in_obj.ActivePrimitive
    
            if ( err <> 0 ) then
                    MsgBox "Failed to create WriteframeOp Custom Operator" & vbCrLf & _
                                    "Please make sure the example is fully installed"
                    exit sub
            end if
    
            on error goto 0
    
            ' Add wireframe shader to an empty material
            set material = in_obj.AddMaterial
            set oSurfParam = material.Parameters( "surface" )
    
            set oSpriteShader = oSurfParam.connectfrompreset( "Sprite", siMaterialShaderFamily )
    
            material.Parameters("Shadow").Connect( oSpriteShader )
    
    
            set inputParam = oSpriteShader.Parameters( "input" )
    
            on error resume next
            set oWireShader = inputParam.connectfrompreset( "WireframeShader", siTextureShaderFamily )
    
            if ( err <> 0 ) then
                    MsgBox "Failed to create WriteframeShader " & vbCrLf & _
                                    "Please make sure the example is fully installed"
                    exit sub
            end if
    
            oWireShader.Parameters("wire_width").value = 0.1
            oWireShader.Parameters("base_color").Parameters("red").value = 1
            oWireShader.Parameters("base_color").Parameters("green").value = 1
            oWireShader.Parameters("base_color").Parameters("blue").value = 1
            oWireShader.Parameters("base_color").Parameters("alpha").value = 0
    
            InspectObj oWireShader
    end sub
    
  2. Draw a render region.

Building the C++ Example

The Softimage SDK includes a compiled version of ShowEdges. If you want to modify the code, you can rebuild the shader by following these instructions.

To build ShowEdges on Windows

  1. Open an Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from an Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the show_edges project from the command line, type:

    devenv cppsrc_ShowEdges\show_edges.vcproj
    
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Release or Debug) and build the DLL.

To build Wireframe on Windows

  1. Open an Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from an Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the Wireframe project from the command line, type:

    devenv cppsrc_Wireframe\Wireframe.vcproj
    
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Release or Debug) and build the DLL.

To build the example on Linux

  1. In a shell (tcsh) window, type:

    source $XSI_HOME/.xsi_<xsi_version>
    
  2. Change directories to

    cppsrc_ShowEdges
    
  3. To remove all intermediate files before building the example, run this command:

    gmake clean
    
  4. To compile the example, run this command:

    gmake
    

Keywords

This example uses the following keywords:

mental ray, shader, tessellated, geometry, edges, polygon, C++ example, operator, Update, InputPort, OutputPort, UserData, UserDataBlob, GetUserData, user data, segments, CSegmentRefArray, GetSegments, CPointRefArray, MATH, CVector3, miQ_FUNC_USERPTR, miQ_INST_DATA, miQ_DATA_LABEL, miQ_DATA_PARAM