示例#1
0
def callBackSourcesMenu(event,val):
	source=event&EventsMask
	if event&Events['export']==0:
		Acoustic.getSources()[source].properties['WAV_SOURCE']=Blender.Sound.Get()[val-1].getFilename()
		return
	#else:
	sources=Acoustic.getSources()[source].sel=val
	return
示例#2
0
def wavsExport(scene):
	buffer=""
	for source in Acoustic.getSources():
		wavFilename=Acoustic.getWav(source)
		if wavFilename==0 or source.sel==0:
			continue
		objectName=source.name
		buffer+=WavLineTemplate % vars()
	return buffer	
示例#3
0
def wavsExport(scene):
    buffer = ""
    for source in Acoustic.getSources():
        wavFilename = Acoustic.getWav(source)
        if wavFilename == 0 or source.sel == 0:
            continue
        objectName = source.name
        buffer += WavLineTemplate % vars()
    return buffer
示例#4
0
def choreoExport(scene, normalize=True):
    SelectedObjects = Blender.Object.GetSelected()
    listeners = Acoustic.getListeners()
    sources = []
    target = None
    buffer = ""
    for source in Acoustic.getSources():
        if source.sel == 1:
            sources.append(source)
    for listener in listeners:
        if listener.sel == 1:
            target = listener
            break
    if target == None or not sources:
        Blender.Draw.PupMenu(
            'You have to select one listener and at least one source objects!')
        return
    allAcousticObjects = Acoustic.getAcousticObjects(scene)
    # print list(allAcousticObjects)
    #TODO: refactor this (checked three times!)
    if normalize == True:
        normalizationOffset, normalizationScale = getNormalizationParameters(
            allAcousticObjects)
    for frame in range(Blender.Get('staframe'), Blender.Get('endframe')):
        Blender.Set('curframe', frame)

        sourceOrientationMatrix = target.mat
        if target.type == 'Camera':  # if the listener is a camera, do a proper rotation acording to conventions: azimuth 0: seeing at x+
            rotationMatrix = Blender.Mathutils.Euler(
                90, 0, -90).toMatrix().invert().resize4x4()
            sourceOrientationMatrix = rotationMatrix * sourceOrientationMatrix

        roll, descention, azimuth = sourceOrientationMatrix.toEuler()

        targetElevation = (-descention) % 360
        if targetElevation > 180:
            targetElevation = targetElevation - 360
        targetRoll = (roll) % 360
        targetAzimuth = (azimuth) % 360
        if normalize == True:
            targetX, targetY, targetZ = normalizePosition(
                listener.mat.translationPart(), normalizationOffset,
                normalizationScale, False)
        else:
            targetX, targetY, targetZ = listener.mat.translationPart()
        sourcesPositions = ""
        for source in sources:
            if source.sel == 1:
                if normalize == True:
                    sourceX, sourceY, sourceZ = normalizePosition(
                        source.mat.translationPart(), normalizationOffset,
                        normalizationScale, False)
                else:
                    sourceX, sourceY, sourceZ = source.mat.translationPart()
                sourcesPositions += " %f\t%f\t%f" % (sourceX, sourceY, sourceZ)
        buffer += ChoreoLineTemplate % vars()
    return buffer
示例#5
0
def drawCallback():
	size=Blender.Window.GetAreaSize()
	xPos=0
	yPos=size[1]
	sources=Acoustic.getSources()
	yPos=layoutSources(sources,"Audio sources:",(xPos,yPos))-40
	materials=Acoustic.getMaterials()
	yPos=layoutMaterials(materials,"Acoustic materials:",(xPos,yPos))-40
	listeners=Acoustic.getListeners()
	yPos=layoutListeners(listeners,"Select listener:",(xPos,yPos))-10
	layoutExporter((xPos,yPos))
	return
示例#6
0
def choreoExport (scene,normalize=True):
	SelectedObjects = Blender.Object.GetSelected()
	listeners=Acoustic.getListeners()
	sources=[]
	target=None
	buffer=""
	for source in Acoustic.getSources():
		if source.sel==1:
			sources.append(source)
	for listener in listeners:
		if listener.sel==1:
			target=listener
			break
	if target==None or not sources:
		Blender.Draw.PupMenu('You have to select one listener and at least one source objects!')
		return
	allAcousticObjects=Acoustic.getAcousticObjects(scene)
	# print list(allAcousticObjects)
	#TODO: refactor this (checked three times!)
	if normalize==True:
		normalizationOffset,normalizationScale=getNormalizationParameters(allAcousticObjects)
	for frame in range(Blender.Get('staframe'),Blender.Get('endframe')):
		Blender.Set('curframe',frame)

		sourceOrientationMatrix=target.mat
		if target.type=='Camera': # if the listener is a camera, do a proper rotation acording to conventions: azimuth 0: seeing at x+
			rotationMatrix=Blender.Mathutils.Euler(90,0,-90).toMatrix().invert().resize4x4()
			sourceOrientationMatrix = rotationMatrix * sourceOrientationMatrix

		roll,descention,azimuth=sourceOrientationMatrix.toEuler()

		targetElevation=(-descention)%360
		if targetElevation>180:
			targetElevation=targetElevation-360
		targetRoll=(roll)%360
		targetAzimuth=(azimuth)%360
		if normalize==True:
			targetX,targetY,targetZ=normalizePosition(listener.mat.translationPart(),normalizationOffset,normalizationScale,False)
		else:
			targetX,targetY,targetZ=listener.mat.translationPart()
		sourcesPositions=""
		for source in sources:
			if source.sel==1:
				if normalize==True:
					sourceX,sourceY,sourceZ=normalizePosition(source.mat.translationPart(),normalizationOffset,normalizationScale,False)
				else:
					sourceX,sourceY,sourceZ=source.mat.translationPart()
				sourcesPositions+=" %f\t%f\t%f" % (sourceX,sourceY,sourceZ)
		buffer+=ChoreoLineTemplate % vars()
	return buffer