Methods Summary |
---|
private void | addDrawables(android.renderscript.RenderScriptGL rs, android.content.res.Resources res, com.android.scenegraph.SceneManager sceneManager)
Allocation drawableData = Allocation.createSized(rs,
Element.ALLOCATION(rs),
mRenderables.size());
Allocation[] drawableAllocs = new Allocation[mRenderables.size()];
for (int i = 0; i < mRenderables.size(); i ++) {
Renderable dI = (Renderable)mRenderables.get(i);
addToMeshMap(dI);
drawableAllocs[i] = dI.getRsField(rs, res).getAllocation();
}
drawableData.copyFrom(drawableAllocs);
sceneManager.mRenderLoop.set_gRenderableObjects(drawableData);
initRenderPassRS(rs, sceneManager);
|
private void | addShaders(android.renderscript.RenderScriptGL rs, android.content.res.Resources res, com.android.scenegraph.SceneManager sceneManager)
if (mVertexShaders.size() > 0) {
Allocation shaderData = Allocation.createSized(rs, Element.ALLOCATION(rs),
mVertexShaders.size());
Allocation[] shaderAllocs = new Allocation[mVertexShaders.size()];
for (int i = 0; i < mVertexShaders.size(); i ++) {
VertexShader sI = mVertexShaders.get(i);
shaderAllocs[i] = sI.getRSData().getAllocation();
}
shaderData.copyFrom(shaderAllocs);
sceneManager.mRenderLoop.set_gVertexShaders(shaderData);
}
if (mFragmentShaders.size() > 0) {
Allocation shaderData = Allocation.createSized(rs, Element.ALLOCATION(rs),
mFragmentShaders.size());
Allocation[] shaderAllocs = new Allocation[mFragmentShaders.size()];
for (int i = 0; i < mFragmentShaders.size(); i ++) {
FragmentShader sI = mFragmentShaders.get(i);
shaderAllocs[i] = sI.getRSData().getAllocation();
}
shaderData.copyFrom(shaderAllocs);
sceneManager.mRenderLoop.set_gFragmentShaders(shaderData);
}
|
void | addToMeshMap(com.android.scenegraph.Renderable d)
ArrayList<Renderable> entries = mRenderableMeshMap.get(d.mMeshName);
if (entries == null) {
entries = new ArrayList<Renderable>();
mRenderableMeshMap.put(d.mMeshName, entries);
}
entries.add(d);
|
public void | addToTransformMap(Transform t)
mTransformMap.put(t.getName(), t);
|
public void | appendCamera(com.android.scenegraph.Camera c)
if (c == null) {
throw new RuntimeException("Adding null object");
}
mCameras.add(c);
|
public void | appendLight(LightBase l)
if (l == null) {
throw new RuntimeException("Adding null object");
}
mLights.add(l);
|
public com.android.scenegraph.Camera | appendNewCamera()
Camera c = new Camera();
appendCamera(c);
return c;
|
public com.android.scenegraph.CompoundTransform | appendNewCompoundTransform()
CompoundTransform t = new CompoundTransform();
appendTransform(t);
return t;
|
public MatrixTransform | appendNewMatrixTransform()
MatrixTransform t = new MatrixTransform();
appendTransform(t);
return t;
|
public com.android.scenegraph.RenderPass | appendNewRenderPass()
RenderPass p = new RenderPass();
appendRenderPass(p);
return p;
|
public com.android.scenegraph.Renderable | appendNewRenderable()
Renderable r = new Renderable();
appendRenderable(r);
return r;
|
public void | appendRenderPass(com.android.scenegraph.RenderPass p)
if (p == null) {
throw new RuntimeException("Adding null object");
}
mRenderPasses.add(p);
|
public void | appendRenderable(RenderableBase d)
if (d == null) {
throw new RuntimeException("Adding null object");
}
mRenderables.add(d);
if (d.getName() != null) {
mRenderableMap.put(d.getName(), d);
}
|
public void | appendShader(FragmentShader f)
if (f == null) {
throw new RuntimeException("Adding null object");
}
mFragmentShaders.add(f);
|
public void | appendShader(VertexShader v)
if (v == null) {
throw new RuntimeException("Adding null object");
}
mVertexShaders.add(v);
|
public void | appendTextures(Texture2D tex)
if (tex == null) {
throw new RuntimeException("Adding null object");
}
mTextures.add(tex);
|
public void | appendTransform(Transform t)
if (t == null) {
throw new RuntimeException("Adding null object");
}
mRootTransforms.appendChild(t);
|
public void | assignRenderState(RenderState renderState)
int numRenderables = mRenderables.size();
for (int i = 0; i < numRenderables; i ++) {
Renderable shape = (Renderable)mRenderables.get(i);
shape.setRenderState(renderState);
}
|
public void | assignRenderStateToMaterial(RenderState renderState, java.lang.String regex)
Pattern pattern = Pattern.compile(regex);
int numRenderables = mRenderables.size();
for (int i = 0; i < numRenderables; i ++) {
Renderable shape = (Renderable)mRenderables.get(i);
Matcher m = pattern.matcher(shape.mMaterialName);
if (m.find()) {
shape.setRenderState(renderState);
}
}
|
public void | clearRenderPasses()
mRenderPasses.clear();
|
public void | destroyRS()
SceneManager sceneManager = SceneManager.getInstance();
mTransformRSData = null;
sceneManager.mRenderLoop.bind_gRootNode(mTransformRSData);
sceneManager.mRenderLoop.set_gRenderableObjects(null);
mRenderPassAlloc = null;
sceneManager.mRenderLoop.set_gRenderPasses(null);
sceneManager.mRenderLoop.bind_gFrontToBack(null);
sceneManager.mRenderLoop.bind_gBackToFront(null);
sceneManager.mRenderLoop.set_gCameras(null);
mTransformMap = null;
mRenderPasses = null;
mLights = null;
mCameras = null;
mRenderables = null;
mRenderableMap = null;
mTextures = null;
mRenderableMeshMap = null;
mRootTransforms = null;
|
public java.util.ArrayList | getCameras()
return mCameras;
|
public java.util.ArrayList | getLights()
return mLights;
|
public RenderableBase | getRenderableByName(java.lang.String name)
return mRenderableMap.get(name);
|
public java.util.ArrayList | getRenderables()
return mRenderables;
|
public Transform | getTransformByName(java.lang.String name)
return mTransformMap.get(name);
|
public void | initRS()
SceneManager sceneManager = SceneManager.getInstance();
mRS = SceneManager.getRS();
mRes = SceneManager.getRes();
long start = System.currentTimeMillis();
mTransformRSData = mRootTransforms.getRSData();
long end = System.currentTimeMillis();
Log.v(TIMER_TAG, "Transform init time: " + (end - start));
start = System.currentTimeMillis();
sceneManager.mRenderLoop.bind_gRootNode(mTransformRSData);
end = System.currentTimeMillis();
Log.v(TIMER_TAG, "Script init time: " + (end - start));
start = System.currentTimeMillis();
addDrawables(mRS, mRes, sceneManager);
end = System.currentTimeMillis();
Log.v(TIMER_TAG, "Renderable init time: " + (end - start));
addShaders(mRS, mRes, sceneManager);
Allocation opaqueBuffer = null;
if (mRenderables.size() > 0) {
opaqueBuffer = Allocation.createSized(mRS, Element.U32(mRS), mRenderables.size());
}
Allocation transparentBuffer = null;
if (mRenderables.size() > 0) {
transparentBuffer = Allocation.createSized(mRS, Element.U32(mRS), mRenderables.size());
}
sceneManager.mRenderLoop.bind_gFrontToBack(opaqueBuffer);
sceneManager.mRenderLoop.bind_gBackToFront(transparentBuffer);
if (mCameras.size() > 0) {
Allocation cameraData;
cameraData = Allocation.createSized(mRS, Element.ALLOCATION(mRS), mCameras.size());
Allocation[] cameraAllocs = new Allocation[mCameras.size()];
for (int i = 0; i < mCameras.size(); i ++) {
cameraAllocs[i] = mCameras.get(i).getRSData().getAllocation();
}
cameraData.copyFrom(cameraAllocs);
sceneManager.mRenderLoop.set_gCameras(cameraData);
}
if (mLights.size() > 0) {
Allocation lightData = Allocation.createSized(mRS,
Element.ALLOCATION(mRS),
mLights.size());
Allocation[] lightAllocs = new Allocation[mLights.size()];
for (int i = 0; i < mLights.size(); i ++) {
lightAllocs[i] = mLights.get(i).getRSData().getAllocation();
}
lightData.copyFrom(lightAllocs);
sceneManager.mRenderLoop.set_gLights(lightData);
}
|
public void | initRenderPassRS(android.renderscript.RenderScriptGL rs, com.android.scenegraph.SceneManager sceneManager)
if (mRenderPasses.size() != 0) {
mRenderPassAlloc = new ScriptField_RenderPass_s(mRS, mRenderPasses.size());
for (int i = 0; i < mRenderPasses.size(); i ++) {
mRenderPassAlloc.set(mRenderPasses.get(i).getRsField(mRS, mRes), i, false);
}
mRenderPassAlloc.copyAll();
sceneManager.mRenderLoop.set_gRenderPasses(mRenderPassAlloc.getAllocation());
}
|
public void | meshLoaded(android.renderscript.Mesh m)
ArrayList<Renderable> entries = mRenderableMeshMap.get(m.getName());
int numEntries = entries.size();
for (int i = 0; i < numEntries; i++) {
Renderable d = entries.get(i);
d.resolveMeshData(m);
}
|