[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
[738] | 2 | // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. |
---|
[286] | 3 | // See LICENSE.txt for details. |
---|
[109] | 4 | |
---|
| 5 | #ifndef _MODELPARTS_H_ |
---|
| 6 | #define _MODELPARTS_H_ |
---|
| 7 | |
---|
| 8 | #include <frams/util/3d.h> |
---|
[121] | 9 | #include <frams/genetics/genoconv.h> |
---|
[109] | 10 | |
---|
| 11 | #include <frams/util/extvalue.h> |
---|
| 12 | #include <frams/util/list.h> |
---|
| 13 | #include <frams/util/sstring.h> |
---|
| 14 | #include <frams/util/sstringutils.h> |
---|
| 15 | #include <frams/param/param.h> |
---|
| 16 | #include <frams/param/syntparam.h> |
---|
| 17 | #include <frams/util/usertags.h> |
---|
| 18 | #include <frams/param/paramtabobj.h> |
---|
| 19 | |
---|
| 20 | #include <stdio.h> |
---|
| 21 | |
---|
| 22 | class Model; |
---|
| 23 | class IRange; |
---|
| 24 | class MultiRange; |
---|
| 25 | |
---|
[714] | 26 | typedef UserTags<Model, void*, 5> ModelUserTags; |
---|
[839] | 27 | extern template char ModelUserTags::reg[5]; |
---|
[109] | 28 | |
---|
| 29 | /** Common base for model elements. */ |
---|
| 30 | class PartBase |
---|
| 31 | { |
---|
| 32 | public: |
---|
[714] | 33 | SString vis_style; |
---|
| 34 | PartBase(const SString& s) :vis_style(s), mapped(0) {} |
---|
| 35 | ~PartBase(); |
---|
| 36 | static SString getDefaultStyle(){ return SString("none"); } |
---|
| 37 | MultiRange *mapped; |
---|
| 38 | enum PartBaseFlags { Selected = 1 }; |
---|
| 39 | int flags; |
---|
| 40 | Model *owner; ///< backlink to the model |
---|
[109] | 41 | |
---|
[714] | 42 | SString info; |
---|
[109] | 43 | |
---|
[714] | 44 | Model &getModel() const { return *owner; } |
---|
[109] | 45 | |
---|
[714] | 46 | ModelUserTags userdata; |
---|
[109] | 47 | |
---|
[714] | 48 | void notifyMappingChange(); |
---|
[109] | 49 | |
---|
[714] | 50 | void clearMapping(); |
---|
| 51 | MultiRange* getMapping() { return mapped; } |
---|
| 52 | void setMapping(const IRange &mr); |
---|
| 53 | void addMapping(const IRange &mr); |
---|
| 54 | void setMapping(const MultiRange &mr); |
---|
| 55 | void addMapping(const MultiRange &mr); |
---|
[109] | 56 | |
---|
[714] | 57 | void setInfo(const SString& name, const SString& value); |
---|
| 58 | void setInfo(const SString& name, int value); |
---|
| 59 | void setInfo(const SString& name, double value); |
---|
| 60 | SString getInfo(const SString& name); |
---|
[109] | 61 | }; |
---|
| 62 | |
---|
[408] | 63 | /// Part is the only real physical object in the Framsticks creature. |
---|
[109] | 64 | /// You can use this class for querying and adjusting constructed |
---|
| 65 | /// model properties |
---|
[714] | 66 | class Part : public PartBase |
---|
[109] | 67 | { |
---|
[714] | 68 | friend class Model; |
---|
| 69 | static SString getDefaultStyle(); |
---|
| 70 | Part(double _mass, double _size, double _density, double _friction, double _ingest, double _assim) |
---|
| 71 | :PartBase(getDefaultStyle()), mass(_mass), size(_size), density(_density), friction(_friction), ingest(_ingest), assim(_assim) |
---|
[109] | 72 | {} |
---|
[714] | 73 | void defassign(); |
---|
[109] | 74 | public: |
---|
[714] | 75 | // base properties - have special meaning and therefore are often accessed directly for convenience |
---|
| 76 | Pt3D p; ///< 3d coordinates of the part |
---|
| 77 | Orient o; ///< orientation in 3d space (rotation matrix) |
---|
| 78 | /// ParamInterface object is preferred way to get/set other properties. |
---|
| 79 | Param extraProperties(); |
---|
| 80 | Param properties(); |
---|
| 81 | paInt refno; |
---|
| 82 | Pt3D rot;///< rotation angles |
---|
[109] | 83 | |
---|
[714] | 84 | /// |
---|
| 85 | paInt shape;///default=old Framsticks compatible, do not mix with shapes>0 |
---|
| 86 | enum Shape { SHAPE_BALL_AND_STICK = 0, SHAPE_ELLIPSOID = 1, SHAPE_CUBOID = 2, SHAPE_CYLINDER = 3 }; |
---|
| 87 | double mass, size, density, friction, ingest, assim, hollow; |
---|
| 88 | Pt3D scale; |
---|
| 89 | Pt3D food; |
---|
| 90 | //SList points; // collistion points |
---|
| 91 | //Slist neurons; // "select * from owner->neurons where part=this" ;-) |
---|
[109] | 92 | |
---|
[714] | 93 | Pt3D vcolor; |
---|
| 94 | double vsize; |
---|
[109] | 95 | |
---|
[714] | 96 | Part(enum Shape s = SHAPE_BALL_AND_STICK); |
---|
| 97 | Part(const Part& src) :PartBase(getDefaultStyle()) { operator=(src); } |
---|
| 98 | void operator=(const Part& src); |
---|
[109] | 99 | |
---|
[714] | 100 | void setPositionAndRotationFromAxis(const Pt3D &p1, const Pt3D &p2); |
---|
| 101 | void setOrient(const Orient &o);///< set part.o and calculates part.rot (rotation angles) |
---|
| 102 | void setRot(const Pt3D &r);///< set part.rot (rotation angles) and calculate part.o |
---|
[109] | 103 | |
---|
[714] | 104 | static Param& getStaticParam(); |
---|
[109] | 105 | }; |
---|
| 106 | |
---|
| 107 | /// Imaginary connection between two parts. |
---|
| 108 | /// Joint has no mass nor intertia but can transfer forces. |
---|
[714] | 109 | class Joint : public PartBase |
---|
[109] | 110 | { |
---|
[714] | 111 | friend class Model; |
---|
| 112 | SString getDefaultStyle(); |
---|
| 113 | Joint(double _stamina, double _stif, double _rotstif, double _d) |
---|
| 114 | :PartBase(getDefaultStyle()), stamina(_stamina), stif(_stif), rotstif(_rotstif) |
---|
| 115 | { |
---|
| 116 | d = Pt3D(_d, 0, 0); |
---|
| 117 | } |
---|
| 118 | void defassign(); |
---|
| 119 | void resetDeltaMarkers(); |
---|
[109] | 120 | public: |
---|
[714] | 121 | // base properties: |
---|
| 122 | paInt p1_refno, p2_refno; ///< parts' reference numbers |
---|
[109] | 123 | |
---|
[714] | 124 | Part *part1, *part2; ///< references to parts |
---|
| 125 | class Pt3D d; ///< position delta between parts |
---|
| 126 | class Pt3D rot; ///< orientation delta between parts expressed as 3 angles |
---|
| 127 | enum Shape { SHAPE_BALL_AND_STICK = 0, SHAPE_FIXED = 1 }; |
---|
| 128 | paInt shape;///< ball-and-stick=old Framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with shape>0, fixed=merge parts into one physical entity |
---|
[109] | 129 | |
---|
[714] | 130 | Joint(); |
---|
| 131 | Joint(const Joint& src) :PartBase(getDefaultStyle()) { operator=(src); } |
---|
| 132 | void operator=(const Joint& src); |
---|
[109] | 133 | |
---|
[714] | 134 | /** connect two parts with this joint. |
---|
| 135 | p2 position will be adjusted if delta option is in effect. |
---|
| 136 | @see isDelta() |
---|
| 137 | */ |
---|
| 138 | void attachToParts(Part* p1, Part* p2); |
---|
| 139 | /// @see attachToParts(Part*,Part*) |
---|
| 140 | void attachToParts(int p1, int p2); |
---|
[109] | 141 | |
---|
[714] | 142 | /** discard delta information but don't disable delta flag. |
---|
| 143 | delta will be calculated from parts positions during final consistency check. |
---|
| 144 | */ |
---|
| 145 | void resetDelta(); |
---|
[109] | 146 | |
---|
[714] | 147 | /** enable or disable delta option. |
---|
| 148 | delta value is not changed. |
---|
| 149 | */ |
---|
| 150 | void useDelta(bool use); |
---|
[109] | 151 | |
---|
[714] | 152 | /** @return true if delta option is in effect. |
---|
| 153 | @see useDelta(), resetDelta(), useDelta() |
---|
| 154 | */ |
---|
| 155 | bool isDelta(); |
---|
[109] | 156 | |
---|
[714] | 157 | /// ParamInterface object is preferred way to get/set other properties. |
---|
| 158 | Param extraProperties(); |
---|
| 159 | Param properties(); |
---|
[109] | 160 | |
---|
[714] | 161 | // do not touch these: |
---|
| 162 | paInt refno; ///< this joint's reference number |
---|
| 163 | double stamina; |
---|
| 164 | double stif, rotstif; ///< stiffness for moving and bending forces |
---|
| 165 | class Orient o; ///< orientation delta between parts as rotation matrix |
---|
| 166 | /** flag: generated f0 should include delta data. |
---|
| 167 | set by 'singlestep' if j: attributes use delta option */ |
---|
| 168 | bool usedelta; |
---|
| 169 | Pt3D vcolor; |
---|
[109] | 170 | |
---|
[714] | 171 | static Param& getStaticParam(); |
---|
[109] | 172 | }; |
---|
| 173 | |
---|
| 174 | #define JOINT_DELTA_MARKER 99999.0 |
---|
| 175 | |
---|
| 176 | ////////////////// NN ///////////////// |
---|
| 177 | |
---|
| 178 | class NeuroClass; |
---|
| 179 | |
---|
[714] | 180 | typedef UserTags<NeuroClass, void*, 5> NeuroClassUserTags; |
---|
[109] | 181 | |
---|
| 182 | /** Information about neuron class. |
---|
| 183 | */ |
---|
| 184 | class NeuroClass |
---|
| 185 | { |
---|
[714] | 186 | bool ownedvectordata; |
---|
| 187 | void operator=(const NeuroClass& nosuchthich){} |
---|
| 188 | public: |
---|
| 189 | SString name, longname, description; |
---|
| 190 | ParamEntry *props; |
---|
| 191 | bool ownedprops;//< destructor will free props using ParamObject::freeParamTab |
---|
| 192 | paInt prefinputs, prefoutput; |
---|
| 193 | paInt preflocation; |
---|
| 194 | int *vectordata; |
---|
| 195 | paInt visualhints; |
---|
[109] | 196 | |
---|
[714] | 197 | //void *impl; |
---|
| 198 | int impl_count; |
---|
| 199 | bool active; |
---|
| 200 | bool genactive; |
---|
| 201 | NeuroClassUserTags userdata; |
---|
[109] | 202 | |
---|
[714] | 203 | ////////////////////// |
---|
| 204 | ~NeuroClass(); |
---|
| 205 | NeuroClass(); |
---|
| 206 | NeuroClass(ParamEntry *_props, SString _description, |
---|
| 207 | int _prefinputs, int _prefoutput, int _preflocation, int *_vectordata, bool own_vd = 1, int vhints = 0); |
---|
| 208 | /** class name for use in Neuro::setClassName(), Neuro::setDetails() (former 'moredata' field), |
---|
| 209 | eg. "N","-",G" */ |
---|
| 210 | const SString& getName() { return name; } |
---|
| 211 | /** human friendly name, eg. "Neuron","Link","Gyroscope" */ |
---|
| 212 | const SString& getLongName() { return longname; } |
---|
| 213 | /** long description */ |
---|
| 214 | const SString& getDescription() { return description; } |
---|
| 215 | ParamEntry* getParamTab() { return props; } |
---|
[109] | 216 | |
---|
[714] | 217 | /** NeuroClass specific properties, recognized by all neurons of this class */ |
---|
| 218 | Param getProperties() { return Param(props); } |
---|
[109] | 219 | |
---|
[714] | 220 | /** preferred number of inputs, -1 = no preference (any number will go). |
---|
| 221 | extra inputs may be ignored by the object (depends on the class). |
---|
| 222 | */ |
---|
| 223 | int getPreferredInputs() { return (int)prefinputs; } |
---|
[109] | 224 | |
---|
[714] | 225 | /** @return 0 if this object doesn't provide useful output signal. */ |
---|
| 226 | int getPreferredOutput() { return (int)prefoutput; } |
---|
[109] | 227 | |
---|
[714] | 228 | /** @return 0 if the object doesn't need any assignment to the body element. |
---|
| 229 | @return 1 = it likes to be attached to the Part ( @see Neuro::attachToPart() ) |
---|
| 230 | @return 2 = the object prefers to have the Joint ( @see Neuro::attachToJoint() ) |
---|
| 231 | */ |
---|
| 232 | int getPreferredLocation() { return (int)preflocation; } |
---|
| 233 | /** vector drawing to be used in neuro net diagram. |
---|
| 234 | interpretation: |
---|
| 235 | { |
---|
| 236 | LEN = datalength (excluding this number) |
---|
| 237 | NL = number_of_lines |
---|
| 238 | line#1 -> NS = number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, |
---|
| 239 | ... |
---|
| 240 | line#NL -> NS = number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, |
---|
| 241 | } |
---|
| 242 | */ |
---|
| 243 | int* getSymbolGlyph() |
---|
| 244 | { |
---|
| 245 | return vectordata; |
---|
| 246 | } |
---|
| 247 | void setSymbolGlyph(int *data, bool owned = 1) |
---|
| 248 | { |
---|
| 249 | if (vectordata&&ownedvectordata) delete[]vectordata; |
---|
| 250 | vectordata = data; ownedvectordata = owned; |
---|
| 251 | } |
---|
| 252 | /** additional information about how the neuron should be drawn |
---|
| 253 | used by structure view (and maybe some other components). |
---|
| 254 | return value is defined by the enum Hint |
---|
| 255 | @see enum Hint |
---|
| 256 | */ |
---|
| 257 | int getVisualHints() |
---|
| 258 | { |
---|
| 259 | return (int)visualhints; |
---|
| 260 | } |
---|
[109] | 261 | |
---|
[714] | 262 | enum Hint |
---|
[738] | 263 | { |
---|
[714] | 264 | /** don't draw neurons of this class */ |
---|
| 265 | Invisible = 1, |
---|
| 266 | /** don't draw classname label below the neuron */ |
---|
| 267 | DontShowClass = 2, |
---|
| 268 | /** draw the neuron at the first part when attached to joint (default is in the middle) */ |
---|
| 269 | AtFirstPart = 4, |
---|
| 270 | /** draw the neuron at the second part when attached to joint (default is in the middle) */ |
---|
| 271 | AtSecondPart = 8, |
---|
| 272 | /** use effector colour for this neuro unit */ |
---|
| 273 | EffectorClass = 16, |
---|
| 274 | /** use receptor colour for this neuro unit */ |
---|
| 275 | ReceptorClass = 32, |
---|
| 276 | V1BendMuscle = 64, |
---|
| 277 | V1RotMuscle = 128, |
---|
| 278 | LinearMuscle = 256 |
---|
| 279 | }; |
---|
[109] | 280 | |
---|
[714] | 281 | /** textual summary, automatically generated from other properties (like the neuro class tooltip) */ |
---|
| 282 | SString getSummary(); |
---|
| 283 | |
---|
| 284 | static void resetActive(); ///< set default values of active and genactive for all classes |
---|
| 285 | static void setGenActive(const char* classes[]); ///< set genactive for specified classes |
---|
[109] | 286 | }; |
---|
| 287 | |
---|
| 288 | class Neuro; |
---|
| 289 | |
---|
[408] | 290 | /** Single processing unit in Framsticks NN. */ |
---|
[714] | 291 | class Neuro : public PartBase |
---|
[109] | 292 | { |
---|
[714] | 293 | friend class Model; |
---|
| 294 | static SString getDefaultStyle(); |
---|
[109] | 295 | |
---|
[714] | 296 | struct NInput { |
---|
| 297 | Neuro *n; double weight; SString *info; |
---|
| 298 | NInput(Neuro *_n, double w, SString *i = 0) :n(_n), weight(w), info(i) {} |
---|
| 299 | }; |
---|
[109] | 300 | |
---|
[714] | 301 | SListTempl<NInput> inputs; |
---|
[109] | 302 | |
---|
[714] | 303 | NeuroClass *myclass; |
---|
| 304 | bool knownclass; |
---|
| 305 | SString myclassname, myclassparams; |
---|
| 306 | /** set myclass and make knownclass=true */ |
---|
| 307 | void checkClass(); |
---|
| 308 | SString** inputInfo(int i); |
---|
| 309 | void defassign(); |
---|
[109] | 310 | |
---|
| 311 | public: |
---|
[714] | 312 | enum NeuroFlags { HoldState = 2 }; |
---|
| 313 | Param properties(); |
---|
| 314 | Param extraProperties(); |
---|
[109] | 315 | |
---|
[714] | 316 | void setInputInfo(int i, const SString& name, const SString &value); |
---|
| 317 | void setInputInfo(int i, const SString& name, int value); |
---|
| 318 | void setInputInfo(int i, const SString& name, double value); |
---|
| 319 | SString getInputInfo(int i); |
---|
| 320 | SString getInputInfo(int i, const SString& name); |
---|
[109] | 321 | |
---|
[714] | 322 | NeuroClass* getClass(); |
---|
| 323 | void setClass(NeuroClass*); |
---|
[109] | 324 | |
---|
[714] | 325 | SString getClassParams() { return myclassparams; } |
---|
| 326 | void setClassParams(const SString& cp) { myclassparams = cp; } |
---|
[109] | 327 | |
---|
[714] | 328 | SString getClassName(); |
---|
| 329 | void setClassName(const SString& clazz); |
---|
[109] | 330 | |
---|
[714] | 331 | /** return neuro unit details encoded as <CLASS> ":" <PROPERTIES> |
---|
[109] | 332 | |
---|
[714] | 333 | new Neuro can be created as root object (without parent) or can be |
---|
| 334 | the child of existing Neuro. Children of the Neuro are its inputs. |
---|
| 335 | Standard Framsticks neuron calculates the sum of all input units - other processing |
---|
| 336 | units don't have to treat them equally and can even ignore some of them. |
---|
| 337 | There are hints about expected inputs in the class database, @see getClass |
---|
[109] | 338 | |
---|
[714] | 339 | Application should not assume anything about classes and its properties |
---|
| 340 | except for two standard classes: (information about all current classes |
---|
| 341 | can be retrieved with getClass/getClassProperties methods) |
---|
| 342 | - getClassName()="N" is the standard Framsticks neuron, accepts any number of inputs, |
---|
| 343 | compatible with old Neuro object |
---|
| 344 | - getClassName()="-" is the neuron link, compatible with old Neuro-Neuro link |
---|
| 345 | (NeuroItem with empty details) |
---|
| 346 | Empty details defaults to "-" if the parent unit is specified, |
---|
| 347 | and "N" if the unit has no parent. |
---|
| 348 | */ |
---|
| 349 | SString getDetails(); |
---|
[109] | 350 | |
---|
[714] | 351 | /** details = classname + ":" + classparams |
---|
| 352 | @see getDetails() |
---|
| 353 | */ |
---|
| 354 | void setDetails(const SString&); |
---|
| 355 | |
---|
[109] | 356 | #define STATRICKCLASS Neuro |
---|
[714] | 357 | PARAMGETDEF(details) { arg1->setString(getDetails()); } |
---|
| 358 | PARAMSETDEF(details) { setDetails(arg1->getString()); return PSET_CHANGED; } |
---|
| 359 | PARAMGETDEF(inputCount); |
---|
| 360 | PARAMPROCDEF(p_getInputNeuroDef); |
---|
| 361 | PARAMPROCDEF(p_getInputNeuroIndex); |
---|
| 362 | PARAMPROCDEF(p_getInputWeight); |
---|
| 363 | PARAMGETDEF(classObject); |
---|
[109] | 364 | #undef STATRICKCLASS |
---|
| 365 | |
---|
[714] | 366 | ///@param handle_defaults_when_saving see SyntParam |
---|
| 367 | SyntParam classProperties(bool handle_defaults_when_saving = true); |
---|
| 368 | // base properties: |
---|
| 369 | paInt refno; ///< unique reference number (former 'neuro' refno) |
---|
[109] | 370 | |
---|
[714] | 371 | paInt part_refno; ///< can be used by some items as the part ref# |
---|
| 372 | paInt joint_refno; ///< can be used by some items as the joint ref# |
---|
[109] | 373 | |
---|
[714] | 374 | Pt3D pos, rot; ///< default = zero |
---|
[109] | 375 | |
---|
[714] | 376 | ModelUserTags userdata; |
---|
[109] | 377 | |
---|
[714] | 378 | Neuro(); |
---|
| 379 | Neuro(double _state, double _inertia, double _force, double _sigmo); |
---|
| 380 | Neuro(const Neuro& src) :PartBase(getDefaultStyle()) { operator=(src); } |
---|
[109] | 381 | |
---|
[714] | 382 | ~Neuro(); |
---|
[109] | 383 | |
---|
[714] | 384 | void operator=(const Neuro& src); |
---|
[109] | 385 | |
---|
[714] | 386 | /** Attach this Neuro to the specified Part or detach it from the body if p==NULL. |
---|
| 387 | Neuro can be attached to either Part or Joint, but not both. |
---|
| 388 | @see getPart() |
---|
| 389 | */ |
---|
| 390 | void attachToPart(Part* p) { part = p; joint = 0; } |
---|
[109] | 391 | |
---|
[714] | 392 | /** Attach this Neuro to the specified Joint or detach it from the body if p==NULL. |
---|
| 393 | Neuro can be attached to either Part or Joint, but not both. |
---|
| 394 | @see getJoint() |
---|
| 395 | */ |
---|
| 396 | void attachToJoint(Joint* j) { joint = j; part = 0; } |
---|
[109] | 397 | |
---|
[714] | 398 | void attachToPart(int i); |
---|
| 399 | void attachToJoint(int i); |
---|
[109] | 400 | |
---|
[714] | 401 | /** @return Part the Neuro is attached to, or NULL if it has no defined location on the body. |
---|
| 402 | @see attachToPart() |
---|
| 403 | */ |
---|
| 404 | Part *getPart() { return part; } |
---|
[109] | 405 | |
---|
[714] | 406 | /** @return Joint the Neuro is attached to, or NULL if it has no defined location on the body. |
---|
| 407 | @see attachToJoint() |
---|
| 408 | */ |
---|
| 409 | Joint *getJoint() { return joint; } |
---|
[109] | 410 | |
---|
[714] | 411 | int isOldEffector(); |
---|
| 412 | int isOldReceptor(); |
---|
| 413 | int isOldNeuron(); |
---|
| 414 | int isNNConnection(); |
---|
[109] | 415 | |
---|
[714] | 416 | /** @return the number of inputs connected to this Neuro. |
---|
| 417 | Functions like getInput(), getInputWeight() will accept connection number [0..InputCount-1] |
---|
| 418 | */ |
---|
| 419 | int getInputCount() const { return inputs.size(); } |
---|
[109] | 420 | |
---|
[714] | 421 | /// @return the number of output connections (including possible self-connections) |
---|
| 422 | int getOutputsCount() const; |
---|
[109] | 423 | |
---|
[714] | 424 | /** @return the Neuro connected as i-th input */ |
---|
| 425 | Neuro* getInput(int i) const { return (i >= inputs.size()) ? 0 : inputs(i).n; } |
---|
| 426 | /** @return the Neuro connected as i-th input. |
---|
| 427 | @param weight |
---|
| 428 | */ |
---|
| 429 | Neuro* getInput(int i, double &weight) const; |
---|
| 430 | /** @return connectin weight for i-th input */ |
---|
| 431 | double getInputWeight(int i) const; |
---|
| 432 | /** change connection weight for i-th input */ |
---|
| 433 | void setInputWeight(int i, double weight); |
---|
| 434 | /** connect i-th input with another neuron */ |
---|
| 435 | void setInput(int i, Neuro*n); |
---|
| 436 | /** connect i-th input with another neuron */ |
---|
| 437 | void setInput(int i, Neuro*n, double weight); |
---|
| 438 | /** add new input. @return its reference number */ |
---|
| 439 | int addInput(Neuro* child, double weight = 1.0, const SString* info = 0); |
---|
| 440 | /** @return reference number [0..InputCount-1] of the input |
---|
| 441 | or -1 if 'child' is not connected with this Neuro.*/ |
---|
| 442 | int findInput(Neuro* child) const; |
---|
| 443 | void removeInput(paInt refno); |
---|
| 444 | /** @return reference number of the child connection, like findInput() */ |
---|
| 445 | int removeInput(Neuro* child); |
---|
[109] | 446 | |
---|
[714] | 447 | int findInputs(SList& result, const char* classname = 0, const Part* part = 0, const Joint* joint = 0) const; |
---|
| 448 | int findOutputs(SList& result, const char* classname = 0, const Part* part = 0, const Joint* joint = 0) const; |
---|
[109] | 449 | |
---|
[714] | 450 | /* class database retrieval */ |
---|
| 451 | static int getClassCount(); |
---|
| 452 | /** @return Neuro class name. |
---|
| 453 | @param classindex 0 .. getClassCount() |
---|
| 454 | */ |
---|
| 455 | static SString getClassName(int classindex); |
---|
| 456 | static NeuroClass* getClass(int classindex); |
---|
| 457 | static NeuroClass* getClass(const SString& classname); |
---|
| 458 | static int getClassIndex(const NeuroClass*nc); |
---|
[109] | 459 | |
---|
[714] | 460 | // not really private, but you should not access those directly |
---|
| 461 | double state; |
---|
[109] | 462 | |
---|
[714] | 463 | /** may reference parent neuron if parentcount is exacty 1. parent is invalid otherwise. @sa parentcount */ |
---|
| 464 | Neuro *parent; |
---|
| 465 | int parentcount; ///< @sa parent |
---|
[109] | 466 | |
---|
[714] | 467 | Part *part; ///< link to the Part |
---|
| 468 | Joint *joint; ///< link to the Joint - required by some objects (eg.muscles) |
---|
| 469 | Orient o; ///< rotation matrix calculated from "rot" |
---|
| 470 | static ParamEntry emptyParamTab[]; |
---|
| 471 | static Param& getStaticParam(); |
---|
[109] | 472 | }; |
---|
| 473 | |
---|
[714] | 474 | class NeuroExt : public Neuro |
---|
[109] | 475 | { |
---|
[714] | 476 | public: |
---|
[109] | 477 | #define STATRICKCLASS NeuroExt |
---|
[714] | 478 | PARAMGETDEF(neuroclass); |
---|
| 479 | PARAMSETDEF(neuroclass); |
---|
[109] | 480 | #undef STATRICKCLASS |
---|
[714] | 481 | static ParamEntry *getParamTab(); |
---|
[109] | 482 | }; |
---|
| 483 | |
---|
| 484 | class NeuroConn |
---|
| 485 | { |
---|
[714] | 486 | void defassign(); |
---|
| 487 | public: |
---|
| 488 | int n1_refno, n2_refno; |
---|
| 489 | double weight; |
---|
| 490 | SString info; |
---|
| 491 | NeuroConn(); |
---|
[109] | 492 | }; |
---|
| 493 | |
---|
[714] | 494 | extern ParamEntry f0_part_paramtab[], f0_joint_paramtab[], f0_nodeltajoint_paramtab[], f0_neuro_paramtab[], f0_neuroconn_paramtab[], f0_neuroitem_paramtab[]; |
---|
[109] | 495 | |
---|
| 496 | #endif |
---|