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