Beispiel #1
0
def main():
    # Creates a VectorVolume
    vecVolumeRef = CreateVectorVolume(maxon.Vector32(100.0))

    # Inserts these vector volume into a VolumeObject
    vecVolumeObj = CreateVectorObject(vecVolumeRef, "Vector Volume")

    # Mixes both vector volume together using cross product
    fogVolumeRef = volume.VolumeToolsInterface.ConvertVectorToFog(
        vecVolumeRef, maxon.ThreadRef())

    # Inserts the mixed volume into the scene
    fogVolumeObj = CreateVectorObject(fogVolumeRef, "Fog Volume")

    # Creates a VolumeMesher and adds the volumeObject
    volumeMesher = c4d.BaseObject(c4d.Ovolumemesher)
    if volumeMesher is None:
        raise MemoryError("Failed to create a volume mesher object.")

    # Inserts the fog volume object under the volume mesher
    fogVolumeObj.InsertUnder(volumeMesher)

    # Inserts the volume mesher within the scene
    doc.InsertObject(volumeMesher, None, None)

    # Pushes an update event to Cinema 4D
    c4d.EventAdd()
def CreateVectorVolume(vectorValue):
    """Creates a VolumeRef defined as a vector volume, with a cube of 100 cm (10* 10) filled with the vector passed.

    Args:
        vectorValue (maxon.Vector32): The vector value to set.

    Returns:
        maxon.frameworks.volume.VolumeRef: The created Vector volume with the value defined inside.
    """
    # Creates volume
    volumeRef = maxon.frameworks.volume.VolumeToolsInterface.CreateNewVector32Volume(
        maxon.Vector32(0.0))
    if volumeRef is None:
        raise MemoryError("Failed to create a float32 volume.")

    # Creates accessor
    access = maxon.frameworks.volume.GridAccessorInterface.Create(
        maxon.Vector32)
    if access is None:
        raise RuntimeError("Failed to retrieve the grid accessor.")

    # Initializes the grid for write access
    access.InitWithWriteAccess(volumeRef)

    # Sets values
    size = 10
    step = 10.0
    for x in range(size):
        for y in range(size):
            for z in range(size):
                pos = maxon.IntVector32(x * step, y * step, z * step)
                access.SetValue(pos, vectorValue)

    return volumeRef
Beispiel #3
0
def CreateVectorVolume(vectorValue):
    """
    Creates a VolumeRef defined as a vector volume, with a cube of 20 cm filled with the vector value passed.

    :param vectorValue: The vector value to set.
    :type vectorValue: maxon.Vector32
    :return: The created Vector volume with the value defined inside.
    :rtype: maxon.frameworks.volume.VolumeRef
    """
    # Creates volume
    volumeRef = maxon.frameworks.volume.VolumeToolsInterface.CreateNewVector32Volume(
        maxon.Vector32(0.0))
    if volumeRef is None:
        raise MemoryError("Failed to create a float32 volume.")

    # Creates accessor
    access = maxon.frameworks.volume.GridAccessorInterface.Create(
        maxon.Vector32)
    if access is None:
        raise RuntimeError("Failed to retrieve the grid accessor.")

    # Initializes the grid for write access
    access.InitWithWriteAccess(volumeRef)

    # Sets values
    size = 20
    for x in range(size):
        for y in range(size):
            for z in range(size):
                pos = maxon.IntVector32(x, y, z)
                access.SetValue(pos, vectorValue)

    return volumeRef
Beispiel #4
0
def main():
    # Creates a VectorVolume
    volumeRefA = CreateVectorVolume(maxon.Vector32(0, 0, 10))
    volumeRefB = CreateVectorVolume(maxon.Vector32(10.0, 0, 0))

    # Inserts these vector volume into the scene
    CreateVectorObject(volumeRefA, "Volume A")
    CreateVectorObject(volumeRefB, "Volume B")

    # Mixes both vector volume together using cross product
    resultMixVolume = volume.VolumeToolsInterface.MixVectorVolumes(volumeRefA, volumeRefB, c4d.MIXVECTORTYPE_CROSS)

    # Inserts the mixed volume into the scene
    CreateVectorObject(resultMixVolume, "Mixed Volume")

    # Pushes an update event to Cinema 4D
    c4d.EventAdd()