|
ProposedArchitectureChanges
Proposed Architecture Changes for making droidViz more general purpose and usable.
Phase-Design, Phase-Implementation IntroductionThe following is a proposed set of architecture changes. These are class definitions which should be sufficient enough for programmers to perform any task droidViz was designed for from either the Java or native layers. Current StateThe new spec is about 80% there. Coding can begin on the lower classes. Areas such as input and the JNI wrapper need further specification. ArchitectureRenderLayerRenderLayer encapsulates the required interface that each RenderLayer Object must/may overload in order to function. Renderlayers are added to the RenderStack object internally in droidViz Public Methods/Interface
When the RenderLayer is created/pushed into the stack its constructor is called. When the RenderLayer is removed from the stack, its destructor is called. RenderStackThe RenderStack is global. We'll still encapsulate it in a separate class, but we don't want to encourage creation of more than one RenderStack. The Renderstack will be internal to droidViz. The render stack will render a stack of layers from the top to the bottom. Because, in some cases, the visualization may depend on layering, we will treat the RenderStack as some sort of "Vector" of render layers. We don't have access to std::vector from the android library, so we'll have to implement something of our own. This will be nontrivial to implement, so we'll just code with this future expansion in mind and implement the functions we don't need right away later. public:
private:
FluidSimDataFluidSimData is a class which allocates memory for the fluid matrices, and contains accessor functions which provide read only access to the data. This is a friend class of FluidSim, so only FluidSim has non-const access to the data contained within. public:
Consider inlining some of this for performance
private:
FluidSimFluidSim carrys out the fluid calculations and performs updating of the FluidSimData object. droidViz passes the FluidSimData object on to the RenderStack each frame after its performed an update to the simulation. Solver.c will be converted to a bunch of static functions within this class public: // Constructor and Deconstructor
// Updating and returning data
// Fluid Parameters
// Input Functions - Note, use the conversion method in the FluidSimData class to convert XY to IJ
private:
InputInput is a special class which holds information about a new input event. It holds the type of input, the number of inputs (in the instance of multitouch) and information about the individual inputs in array form - X, Y. The input structure is designed to be expandable in the future (Pressure?) Implementation is trivial. DroidVizDroidViz is the wrapper object which instantiates one RenderStack and one FluidSim, and exposes the functions of both to each other and the JNI interface. DroidViz will aggregate input until the next fluid update and render cycle. public:
private:
JNI WrapperThe jni wrapper is a set of functions which exposes the main object and associated functions it performs. The following is a list of exposed JNI functions and what they do
Java Level Usage:The following is a proposed Java scenario which demonstrates how the developer should use the library. // Create a surface view and the droidViz renderer DroidVizSurfaceView sv; DroidViz dv; // (DroidVizRenderer will now be renamed to DroidViz because it contains the majority of the methods. // Get a list of all available render layers we can instantiate string[] Types; dv.GetTypes( Types ); // Add a render layer to the stack int idx = dv.PushBackRenderLayer( "Density" ); or int idx = dv.PushFrontRenderLayer( "Density" ); or assert( pos < dv.NumRenderLayers() ) int idx = dv.InsertRenderLayer( "Velocity", pos ); // Or remove a render layer from the stack if( dv.RemoveRenderLayer( idx ) ) Log.v( "droidViz", "Successfully removed the RenderLayer" ) else Log.v( "droidViz", "Could not remove the RenderLayer" ) // Set the renderer for this SurfaceView sv.SetRenderer( dv ); // Set the surface view to show droidViz SetContentView( sv ); |