working on it ...

Filters

Explore Public Snippets

Sort by

Found 2 snippets matching: ".net 3d component"

    public by sherazam  184659  0  5  0

    How to Render an Image of 3D Model from the Camera inside .NET Application

    This Technical tip explains how .NET developers can render an image of 3D model from the camera inside their .NET applications. Using Aspose.3D for .NET, developers can render an image to view a realistic image of 3D model, with or without the enhanced background, textures, shadows and also adjust the image size. The Render method exposed by the Sc
    // Enter here the actual content of the snippet.            // this code example creates a camera in a 3D scene, sets its target and render an image.
    
    // [C# Code Sample]
    
    // For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    // The path to the documents directory.
    string MyDir = RunExamples.GetDataDir();
    
    // Load scene from file
    Scene scene = new Scene(MyDir + "camera.3ds");
    // Create a camera at (10,10,10) and look at the origin point for rendering,
    // it must be attached to the scene before render
    Camera camera = new Camera();
    scene.RootNode.CreateChildNode("camera", camera);
    camera.ParentNode.Transform.Translation = new Vector3(10, 10, 10);
    camera.LookAt = Vector3.Origin;
    
    // Specify the image render option
    ImageRenderOptions opt = new ImageRenderOptions();
    // Set the background color
    opt.BackgroundColor = Color.AliceBlue;
    // Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir + "textures");
    // Turn on shadow
    opt.EnableShadows = true;
    // Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir + "Render3DModelImageFromCamera_out_.png", new Size(1024, 1024), ImageFormat.Png, opt);
    
    //[VB.NET Code Sample]
    
    ' For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    ' The path to the documents directory.
    Dim MyDir As String = RunExamples.GetDataDir()
    
    ' Load scene from file
    Dim scene As New Scene(MyDir & Convert.ToString("camera.3ds"))
    ' Create a camera at (10,10,10) and look at the origin point for rendering,
    ' it must be attached to the scene before render
    Dim camera As New Camera()
    scene.RootNode.CreateChildNode("camera", camera)
    camera.ParentNode.Transform.Translation = New Vector3(10, 10, 10)
    camera.LookAt = Vector3.Origin
    
    ' Specify the image render option
    Dim opt As New ImageRenderOptions()
    ' Set the background color
    opt.BackgroundColor = Color.AliceBlue
    ' Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir & Convert.ToString("textures"))
    ' Turn on shadow
    opt.EnableShadows = True
    ' Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir & Convert.ToString("Render3DModelImageFromCamera_out_.png"), New Size(1024, 1024), ImageFormat.Png, opt)
    

    public by sherazam  2313  0  6  0

    How to Add Animation Property to 3D Scene Document inside .NET Application

    // Enter here the actual content of the snippet.            
    // [C# Code Sample]
    
    // For complete examples and data files, please go to https://github.com/aspose3d/Aspose_3D_NET
    // Initialize scene object
    Scene scene = new Scene();
    
    // Call Common class create mesh using polygon builder method to set mesh instance 
    Mesh mesh = Common.CreateMeshUsingPolygonBuilder();             
    
    // Each cube node has their own translation
    Node cube1 = scene.RootNode.CreateChildNode("cube1", mesh);
    
    // Find translation property on node's transform object
    Property translation = cube1.Transform.FindProperty("Translation");
                
    // Create a curve mapping based on translation property
    CurveMapping mapping = new CurveMapping(scene, translation);
                
    // Create curve on channel X and Z
    Curve curveX = mapping.CreateCurve("X");
    Curve curveZ = mapping.CreateCurve("Z");
                
    // Move node's translation to (10, 0, 10) at 0 sec using bezier interpolation
    curveX.CreateKeyFrame(0, 10.0f, Interpolation.Bezier);
    curveZ.CreateKeyFrame(0, 10.0f, Interpolation.Bezier);
                
    // Move node's translation to (20, 0, -10) at 3 sec
    curveX.CreateKeyFrame(3, 20.0f, Interpolation.Bezier);
    curveZ.CreateKeyFrame(3, -10.0f, Interpolation.Bezier);
                
    // Move node's translation to (30, 0, 0) at 5 sec
    curveX.CreateKeyFrame(5, 30.0f, Interpolation.Linear);
    curveZ.CreateKeyFrame(5, 0.0f, Interpolation.Bezier);            
    
    // The path to the documents directory.
    string MyDir = RunExamples.GetDataDir();
    MyDir = MyDir + RunExamples.GetOutputFilePath("PropertyToDocument.fbx");            
    
    // Save 3D scene in the supported file formats
    scene.Save(MyDir, FileFormat.FBX7400ASCII);
    
    //[VB.NET Code Sample]
    
    ' For complete examples and data files, please go to https://github.com/aspose3d/Aspose_3D_NET
    ' Initialize scene object
    Dim scene As New Scene()
    
    ' Call Common class create mesh using polygon builder method to set mesh instance 
    Dim mesh As Mesh = Common.CreateMeshUsingPolygonBuilder()
    
    ' Each cube node has their own translation
    Dim cube1 As Node = scene.RootNode.CreateChildNode("cube1", mesh)
    
    ' Find translation property on node's transform object
    Dim translation As [Property] = cube1.Transform.FindProperty("Translation")
    
    ' Create a curve mapping based on translation property
    Dim mapping As New CurveMapping(scene, translation)
    
    ' Create curve on channel X and Z
    Dim curveX As Curve = mapping.CreateCurve("X")
    Dim curveZ As Curve = mapping.CreateCurve("Z")
    
    ' Move node's translation to (10, 0, 10) at 0 sec using bezier interpolation
    curveX.CreateKeyFrame(0, 10.0F, Interpolation.Bezier)
    curveZ.CreateKeyFrame(0, 10.0F, Interpolation.Bezier)
    
    ' Move node's translation to (20, 0, -10) at 3 sec
    curveX.CreateKeyFrame(3, 20.0F, Interpolation.Bezier)
    curveZ.CreateKeyFrame(3, -10.0F, Interpolation.Bezier)
    
    ' Move node's translation to (30, 0, 0) at 5 sec
    curveX.CreateKeyFrame(5, 30.0F, Interpolation.Linear)
    curveZ.CreateKeyFrame(5, 0.0F, Interpolation.Bezier)
    
    ' The path to the documents directory.
    Dim MyDir As String = RunExamples.GetDataDir()
    MyDir = MyDir & RunExamples.GetOutputFilePath("PropertyToDocument.fbx")
              
    ' Save 3D scene in the supported file formats
    scene.Save(MyDir, FileFormat.FBX7400ASCII)
    

    List Complete ( 2 snippets total )

    Cannot find what you were looking for?
    Ask the Snip2Code Community

    • Public Snippets
    • Channels Snippets