-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and adding render image and animation tasks.
- Loading branch information
Showing
5 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'blender' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/groovy/com/eowise/blender/render/RenderAnimation.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.eowise.blender.render | ||
|
||
import com.eowise.blender.render.specs.RenderSceneSpec | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* Created by aurel on 12/03/14. | ||
*/ | ||
class RenderAnimation extends DefaultTask { | ||
|
||
RenderSceneSpec spec; | ||
|
||
RenderAnimation() { | ||
spec = new RenderSceneSpec() | ||
} | ||
|
||
Task configure(Closure configureClosure) { | ||
|
||
project.configure(spec, configureClosure) | ||
|
||
return this; | ||
} | ||
|
||
@TaskAction | ||
def run() { | ||
project.delete project.fileTree(dir: spec.blendFile.getParent(), include: '*.png') | ||
project.delete spec.blendFile.getParent() + '/tmp' | ||
|
||
project.exec { | ||
commandLine 'blender', '-b', spec.blendFile, '-F', 'PNG', '-S', spec.scene, '-s', start, '-e', end, '-a' | ||
} | ||
|
||
project.copy { | ||
from spec.blendFile.getParent() + '/tmp' | ||
into spec.outputPath | ||
include '*.png' | ||
rename ~/([^\.]+)\.png/, spec.scene.toLowerCase() + '$1.png' | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/groovy/com/eowise/blender/render/RenderImage.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.eowise.blender.render | ||
|
||
import com.eowise.blender.render.specs.RenderSceneSpec | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* Created by aurel on 12/03/14. | ||
*/ | ||
class RenderImage extends DefaultTask { | ||
|
||
RenderSceneSpec spec; | ||
|
||
RenderImage() { | ||
spec = new RenderSceneSpec() | ||
} | ||
|
||
@InputFile | ||
File getBlendFile() { | ||
return spec.blendFile | ||
} | ||
|
||
@Input | ||
String getScene() { | ||
return spec.scene | ||
} | ||
|
||
@OutputDirectory | ||
File getOutputDirectory() { | ||
return spec.outputPath | ||
} | ||
|
||
@Override | ||
Task configure(Closure configureClosure) { | ||
|
||
project.configure(spec, configureClosure) | ||
|
||
return this; | ||
} | ||
|
||
@TaskAction | ||
def run() { | ||
|
||
project.exec { | ||
commandLine 'blender', '-b', getBlendFile(), '-o', "${temporaryDir}/${name}-####", '-F', 'PNG', '-S', getScene(), '-f', 1 | ||
} | ||
|
||
project.copy { | ||
from temporaryDir | ||
into getOutputDirectory() | ||
include "${name}-0001.png" | ||
rename { fileName -> getScene().toLowerCase() + '.png'} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/groovy/com/eowise/blender/render/specs/RenderSceneSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.eowise.blender.render.specs | ||
|
||
/** | ||
* Created by aurel on 15/03/14. | ||
*/ | ||
class RenderSceneSpec { | ||
|
||
File blendFile | ||
String scene | ||
File outputPath | ||
|
||
public RenderScene() { | ||
} | ||
|
||
def from(File file) { | ||
blendFile = file | ||
} | ||
|
||
def render(String sceneName) { | ||
scene = sceneName | ||
} | ||
|
||
def into(File path) { | ||
outputPath = path | ||
} | ||
|
||
} |