ANIMATIONMANAGER Provides per frame paths for stimuli We integrate dyn4j java physics engine for rigid body. The plan is to also support sinusoidal, brownian, circular etc.
More...
ANIMATIONMANAGER Provides per frame paths for stimuli We integrate dyn4j java physics engine for rigid body. The plan is to also support sinusoidal, brownian, circular etc.
screen = screenManager(); % create a screen object
ball = imageStimulus('size',4,'filePath','moon.png','name','moon');
ball.speed = 25; % will define velocity
ball.angle = -45; % will define velocity
world = animationManager('timeDelta', 0.016);
screenParamaters = open(screen); % open screen
% initialise stimulus with PTB screen parameters
setup(ball, screen);
addScreenBoundaries(world, screenParamaters); % add floor,ceiling and walls based on the screen
addBody(world, ball); % add stimulus as a rigidbody to animationManager
% initialise the simulation and pass the PTB
% screen so that the world can be related
% to the PTB dimensions.
% The mapping is 1° visual angle = 1 meter.
setup(world, screen);
for i = 1:120 % run for 120 frames
draw(ball); % draw the stimulus
flip(screen); % flip the screen
% step the simulation one step (0.016s) forwards
% true flag will update the ball stimulus at the new position
step(world, 1, true);
end
@TODO build the code for the different types of motion paths apart from rigid body 2D physics. These could be static methods.
Contributions: Heting Zhang Copyright ©2014-2025 Ian Max Andolina — released: LGPL3, see LICENCE.md
|
| function | animationManager (in varargin) |
| | Class constructor.
|
| |
| function | addBody (in me, in stimulus, in shape, in type, in density, in friction, in elasticity, in av) |
| |
| function | getBody (in me, in id, in bodyType) |
| | return the first body matching name or hash
|
| |
| function | editBody (in me, in id, in x, in y, in vx, in vy, in av, in editStim) |
| | NOTE: input y and vy are in opticka coordinates (-y = up) whereas world has +y = up, make sure your Y input is in opticka format.
|
| |
| function | rmBody (in me, in id) |
| |
| function | setEnabled (in me, in id, in state) |
| |
| function | show (in me, in id) |
| | modifies the physics body and opticka stimulus
|
| |
| function | hide (in me, in id) |
| |
| function | isCollision (in me, in body) |
| |
| function | resetBodies (in me) |
| |
| function | update (in me) |
| |
| function | setup (in me, in screen, in useBounds) |
| |
| function | addScreenBoundaries (in me, in sv, in padding) |
| | addScreenBoundaries add physical walls at the screen edges
|
| |
| function | step (in me, in varargin) |
| |
| function | updateBodyPositions (in me) |
| |
| function | reset (in me) |
| | Load an image.
|
| |
| function | getFixture (in me, in name, in num) |
| |
| function | setSensorState (in me, in name, in state) |
| |
| function | getBodyName (in me, in hash) |
| |
| function get | nBodies (in me) |
| |
| function get | nObstacles (in me) |
| |
| function | optickaCore (in varargin) |
| | Class constructor.
|
| |
| function get | fullName (in me) |
| |
| function | getALF (in me, in subject, in lab, in create) |
| | get the ALF path
|
| |
| function | makeReport (in me, in rpt) |
| | Generate a detailed report for the opticka object.
|
| |
| function | findAttributes (in me, in attrName, in attrValue) |
| |
| function | findAttributesandType (in me, in attrName, in attrValue, in type) |
| | find properties of object with specific attributes, for example all properties whose GetAcccess attribute is public and type is logical.
|
| |
| function | findPropertyDefault (in me, in propName) |
| | Return the declared default value for a class property.
|
| |
| function | clone (in me) |
| | Use this syntax to make a deep copy of the object, i.e. OBJ_OUT has the same field values, but will not behave as a handle-copy of me anymore.
|
| |
| function | checkSuperclasses (in List) |
| |
| function | editProperties (in me, in properties) |
| | method to modify a set of properties
|
| |
| function | setProp (in me, in property, in value) |
| | method to fast change a particular value. This is useful for use in anonymous functions, like in the state machine.
|
| |
| function | initialiseSaveFile (in me, in varargin) |
| | just get date fragment for backwards compatibility
|
| |
| function | checkPaths (in me) |
| | checks the paths are valid
|
| |
|
| static function | vector2 (in x, in y) |
| | dyn4j Vector2
|
| |
| static function | demo () |
| |
| static function | d2r (in degrees) |
| | degrees2radians
|
| |
| static function | r2d (in r) |
| | radians2degrees
|
| |
| static function | findDistance (in x1, in y1, in x2, in y2) |
| | findDistance in X and Y coordinates
|
| |
| static function | updatePosition (in delta, in angle) |
| | updatePosition returns dX and dY given an angle and delta
|
| |
| static function | bezier (in t, in P) |
| | bezier function
|
| |
| static function | initialiseGlobals (in doReset, in doOpen) |
| |
| static function | makeArgs (in args) |
| | Converts cell args to structure array.
|
| |
| static function | addDefaults (in args, in defs) |
| | regularises and adds default options to arg input
|
| |
| static function | hasKey (in in, in key) |
| | check if a struct / object has a propery / field
|
| |
| static function | getKeys (in device) |
| | PTB Get key presses, stops key bouncing.
|
| |
|
| function | getBodyIDX (in me, in id) |
| | return the first body matching name or hash
|
| |
| function | rigidStep (in me, in tick, in updatePositions) |
| |
| function | setupWorld (in me) |
| |
| function | setupBodies (in me) |
| |
| function | setupBody (in me, in thisBody) |
| |
| function | updateMassType (in me, in thisBody, in type) |
| |
| function | makeTrackIndex (in me) |
| |
| function | delete (in me) |
| | delete is the object Destructor Destructor automatically called when object is cleared
|
| |
| function | parseArgs (in me, in args, in allowedProperties) |
| | Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties.
|
| |
| function | addArgs (in me, in args) |
| |
| function | setPaths (in me) |
| | Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties.
|
| |
| function | getFonts (in me) |
| | set paths for object
|
| |
| function | toStructure (in me) |
| | Converts properties to a structure.
|
| |
| function | getType (in me, in in) |
| |
| function | logOutput (in me, in in, in message, in override) |
| | Give a metaproperty return the likely property class.
|
| |
| function | salutation (in me, in varargin) |
| | Prints messages dependent on verbosity.
|
| |