Exemple #1
0
#Copyright 2021 Intel Corporation
#SPDX-License-Identifier: Apache-2.0

import sys
import pysg as sg
from pysg import Any, vec3f, Data, FileName, Importer, MaterialRegistry, ArcballCamera, vec2i, box3f

files  = sg.init(sys.argv)

W = 1920
H = 1080

window_size = vec2i(W, H)
aspect = Any(float(W) / H)

frame = sg.Frame()
frame.createChild("windowSize", "vec2i", Any(window_size))
world = frame.child("world")

lightsMan = frame.child("lights")
baseMaterialRegistry = frame.child("baseMaterialRegistry")

if len(files) > 0:
    for file in files:
        importer = sg.getImporter(world, FileName(file))
        importer.setLightsManager(lightsMan)
        importer.setMaterialRegistry(baseMaterialRegistry)
        importer.importScene()

world.render()
bounds = world.bounds()
Exemple #2
0
#Copyright 2021-2022 Intel Corporation
#SPDX-License-Identifier: Apache-2.0
"""
An example of using python to benchmark studio rendering of vtk data files.
Example use:
 python3 studiobench1.py -numFrames 200 -colors 2 0 0 0 1 1 1 data_32.vti
"""

import sys, numpy, math, time, atexit, resource
import pysg as sg
from pysg import Any, vec3f, Data, FileName, Importer, MaterialRegistry, ArcballCamera, vec2i, box3f, vec2f

args = sg.init(sys.argv)

sg.loadPlugin("vtk")

#optional command line arguments
scalarRange = None
colors = None
opacities = None
W = 1024
H = 768
numFrames = 100

for idx in range(0, len(args)):
    a = args[idx]
    if a == "-range":
        scalarRange = vec2f(float(args[idx + 1]), float(args[idx + 2]))
    if a == "-colors":
        nc = int(args[idx + 1])
        colors = []
Exemple #3
0
#Copyright 2021 Intel Corporation
#SPDX-License-Identifier: Apache-2.0

import sys, numpy
import pysg as sg
from pysg import Any, vec3f, Data, vec2i

sg.init(sys.argv)

# specific rkcommon::math types needed for SG
pos = Any(vec3f(0.0, 0.0, 10.0))
dir = Any(vec3f(0.0, 0.0, -1.0))
up = Any(vec3f(0.0, 1.0, 0.0))

W = 1024
H = 768

window_size = Any(vec2i(W, H))
aspect = Any(float(W) / H)

vertex = numpy.array(
    [[-1.0, -1.0, 3.0], [-1.0, 1.0, 3.0], [1.0, -1.0, 3.0], [0.1, 0.1, 0.3]],
    dtype=numpy.float32)

color = numpy.array([[0.9, 0.5, 0.5, 1.0], [0.8, 0.8, 0.8, 1.0],
                     [0.8, 0.8, 0.8, 1.0], [0.5, 0.9, 0.5, 1.0]],
                    dtype=numpy.float32)

index = numpy.array([[0, 1, 2], [1, 2, 3]], dtype=numpy.uint32)

mat = numpy.array([0], dtype=numpy.uint32)