├── .gitignore ├── Makefile ├── README.md ├── direct ├── actor.nim ├── interval.nim ├── loader.nim ├── showbase.nim ├── showbase │ ├── DirectObject.nim │ ├── EventManager.nim │ ├── EventManagerGlobal.nim │ ├── Loader.nim │ ├── Messenger.nim │ ├── MessengerGlobal.nim │ └── ShowBase.nim └── task.nim ├── examples └── roaming-ralph │ ├── build.sh │ ├── main.nim │ └── models │ ├── ground.jpg │ ├── hedge.jpg │ ├── ralph-run.egg.pz │ ├── ralph-walk.egg.pz │ ├── ralph.egg.pz │ ├── ralph.jpg │ ├── rock03.jpg │ ├── tree.jpg │ └── world.egg.pz ├── generate.py ├── panda3d ├── core.nim ├── direct.nim ├── helpers.hpp └── private.nim └── test.nim /.gitignore: -------------------------------------------------------------------------------- 1 | /test 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PANDA_DIR=$(shell python -c "import panda3d.core,os;print(os.path.dirname(os.path.dirname(panda3d.core.__file__)))") 2 | NIM?=nim 3 | 4 | .PHONY: all clean 5 | 6 | all: test 7 | 8 | test: test.nim panda3d/*.nim direct/*.nim direct/*/*.nim 9 | $(NIM) --cincludes:${PANDA_DIR}/include --cincludes:/usr/include/eigen3 --clibdir:${PANDA_DIR}/lib cpp test.nim 10 | 11 | clean: 12 | rm -f test 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a proof of concept nim binding for Panda3D. 2 | 3 | There is a subset of the DIRECT API implemented as well. It is deliberately 4 | incomplete, only the parts that can't be trivially reimplemented using the C++ 5 | API are intended to be supported. 6 | 7 | Some things to keep in mind: 8 | * Reference-counted types like PandaNode are always by-ref, using Panda's 9 | reference counting system, just like in Python. To create an instance, use 10 | something like `newPandaNode()`. These types are `nil`lable. 11 | * Other types, like NodePath, are stored by-value. Create instances using 12 | `initNodePath()` and the like. 13 | * The typical code convention in nim is camelCase, but snake_case is supported 14 | as well by virtue of how nim's identifier resolution works. 15 | * Both property interfaces and getter/setter methods are supported. 16 | * Tuples are accepted in place of vectors, but be sure that the types of the 17 | elements are correct. 18 | * The ShowBase constructor doesn't open a window. Call `openDefaultWindow()`. 19 | * The `direct` modules are woefully incomplete, see above. 20 | 21 | Here is a brief example, see `test.nim` for the complete Hello World tutorial. 22 | ```nim 23 | import direct/showbase 24 | import direct/actor 25 | import panda3d/core 26 | 27 | var base = ShowBase() 28 | base.openDefaultWindow() 29 | 30 | var env = loader.loadModel("models/environment") 31 | env.reparentTo(render) 32 | env.setScale(0.25, 0.25, 0.25) 33 | env.setPos(-8, 42, 0) 34 | 35 | var pandaActor = Actor() 36 | pandaActor.loadModel("models/panda-model") 37 | pandaActor.loadAnims({"walk": "models/panda-walk4"}) 38 | pandaActor.setScale(0.005, 0.005, 0.005) 39 | pandaActor.reparentTo(render) 40 | pandaActor.loop("walk") 41 | 42 | base.run() 43 | ``` 44 | 45 | Building the example: 46 | ``` 47 | make test 48 | ./test 49 | ``` 50 | -------------------------------------------------------------------------------- /direct/actor.nim: -------------------------------------------------------------------------------- 1 | import ../panda3d/core 2 | import std/strutils 3 | import std/tables 4 | 5 | type 6 | AnimDef = object 7 | filename: string 8 | animControl: AnimControl 9 | 10 | type 11 | Actor* = object of NodePath 12 | bundleDict: Table[string, PartBundle] 13 | partDict: Table[string, Table[string, AnimDef]] 14 | bundleNP: NodePath 15 | 16 | proc loadModel*(this: var Actor, modelPath: string, partName: string = "modelRoot") = 17 | var model = initNodePath(Loader.getGlobalPtr().loadSync(initFilename(modelPath))) 18 | {.emit: """ 19 | (NodePath &)`this` = `model`; 20 | """.} 21 | 22 | if model.node().isOfType(Character.getClassType()): 23 | this.bundleNP = model 24 | else: 25 | this.bundleNP = model.find("**/+Character") 26 | 27 | var acc: AnimControlCollection 28 | autoBind(model.node(), acc, not 0) 29 | let numAnims = acc.getNumAnims() 30 | 31 | this.bundleDict[partName] = Character.dcast(this.bundleNP.node()).getBundle(0) 32 | 33 | var animDict = addr this.partDict.mgetOrPut(partName, Table[string, AnimDef]()) 34 | for i in 0 ..< numAnims: 35 | var animControl = acc.getAnim(i) 36 | var animName = acc.getAnimName(i) 37 | 38 | animDict[][animName] = AnimDef(animControl: animControl) 39 | 40 | proc loadAnims*(this: var Actor, anims: openArray[(string, string)], partName: string = "modelRoot") = 41 | var animDict = addr this.partDict.mgetOrPut(partName, Table[string, AnimDef]()) 42 | 43 | for i, (animName, filename) in anims: 44 | animDict[][animName] = AnimDef(filename: filename) 45 | 46 | iterator children(this: PartGroup): PartGroup = 47 | var count = this.getNumChildren() 48 | for i in 0 ..< count: 49 | yield this.getChild(i) 50 | 51 | proc doListJoints(this: var Actor, indentLevel: int, part: PartGroup) = 52 | var name = part.getName() 53 | var value : string 54 | 55 | if part.isOfType(MovingPartBase.getClassType()): 56 | var lineStream : LineStream 57 | dcast(MovingPartBase, part).outputValue(lineStream) 58 | value = lineStream.getLine() 59 | 60 | echo spaces(indentLevel), ' ', name, ' ', value 61 | 62 | for child in part.children: 63 | this.doListJoints(indentLevel + 2, child) 64 | 65 | proc listJoints*(this: var Actor, partName: string = "modelRoot") = 66 | this.doListJoints(0, this.bundleDict[partName]) 67 | 68 | proc getAnimNames*(this: var Actor): seq[string] = 69 | for partName, animDict in this.partDict: 70 | for animName in animDict.keys(): 71 | if animName notin result: 72 | result.add(animName) 73 | 74 | proc exposeJoint*(this: var Actor, node: NodePath, partName: string, jointName: string, localTransform: bool = false): NodePath = 75 | # Get a handle to the joint. 76 | var joint = dcast(CharacterJoint, this.bundleDict[partName].findChild(jointName)) 77 | 78 | var node2: NodePath 79 | 80 | if not node.isEmpty: 81 | node2 = node 82 | else: 83 | node2 = this.bundleNP.attachNewNode(jointName) 84 | 85 | if joint != nil: 86 | if localTransform: 87 | discard joint.addLocalTransform(node2.node()) 88 | else: 89 | discard joint.addNetTransform(node2.node()) 90 | 91 | return node2 92 | 93 | proc exposeJoint*(this: var Actor, node: type(nil), partName: string, jointName: string, localTransform: bool = false): NodePath = 94 | this.exposeJoint(this.bundleNP.attachNewNode(jointName), partName, jointName, localTransform) 95 | 96 | proc stopJoint*(this: var Actor, partName: string, jointName: string) = 97 | # Get a handle to the joint. 98 | var joint = dcast(CharacterJoint, this.bundleDict[partName].findChild(jointName)) 99 | 100 | if joint != nil: 101 | joint.clearNetTransforms() 102 | joint.clearLocalTransforms() 103 | 104 | proc getPartJoints(this: var Actor, joints: var seq[MovingPartBase], pattern: var GlobPattern, part: PartGroup) = 105 | if part.isOfType(MovingPartBase.getClassType()) and pattern.matches(part.getName): 106 | joints.add(MovingPartBase.dcast(part)) 107 | 108 | for child in part.children: 109 | this.getPartJoints(joints, pattern, child) 110 | 111 | proc getJoints*(this: var Actor, partName: string = "modelRoot", jointName: string = "*"): seq[MovingPartBase] = 112 | var pattern = initGlobPattern(jointName) 113 | 114 | var partBundle = this.bundleDict[partName] 115 | if not pattern.hasGlobCharacters(): 116 | var joint = partBundle.findChild(jointName) 117 | if joint != nil and joint.isOfType(MovingPartBase.getClassType()): 118 | result.add(MovingPartBase.dcast(joint)) 119 | else: 120 | this.getPartJoints(result, pattern, partBundle) 121 | 122 | proc controlJoint*(this: var Actor, node: NodePath, partName: string, jointName: string): NodePath = 123 | var anyGood = false 124 | 125 | var node2: NodePath 126 | 127 | var bundle = this.bundleDict[partName] 128 | if not node.isEmpty: 129 | node2 = node 130 | else: 131 | node2 = this.attachNewNode(newModelNode(jointName)) 132 | var joint = bundle.findChild(jointName) 133 | if joint != nil and joint.isOfType(MovingPartMatrix.getClassType()): 134 | node2.setMat(MovingPartMatrix.dcast(joint).getDefaultValue()) 135 | 136 | if bundle.controlJoint(jointName, node2.node()): 137 | anyGood = true 138 | 139 | return node2 140 | 141 | proc controlJoint*(this: var Actor, node: type(nil), partName: string, jointName: string): NodePath = 142 | this.controlJoint(NodePath(), partName, jointName) 143 | 144 | proc releaseJoint*(this: var Actor, partName: string, jointName: string) = 145 | discard this.bundleDict[partName].releaseJoint(jointName) 146 | 147 | proc bindAnimToPart(this: var Actor, animName: string, partName: string): AnimControl {.discardable.} = 148 | var anim = addr this.partDict[partName][animName] 149 | 150 | var animControl = this.bundleDict[partName].loadBindAnim(Loader.getGlobalPtr(), initFilename(anim.filename), -1, PartSubset(), false) 151 | anim.animControl = animControl 152 | return animControl 153 | 154 | proc getAnimControl*(this: var Actor, animName: string, partName: string = "modelRoot"): AnimControl = 155 | if not this.partDict.hasKey(partName): 156 | return toAnimControl(nil) 157 | 158 | var animDict = addr this.partDict[partName] 159 | if not animDict[].hasKey(animName): 160 | return toAnimControl(nil) 161 | 162 | var anim = addr animDict[][animName] 163 | if anim.animControl == nil: 164 | this.bindAnimToPart(animName, partName) 165 | return anim.animControl 166 | 167 | proc stop*(this: var Actor, animName: string, partName: string = "modelRoot") = 168 | this.getAnimControl(animName, partName).stop() 169 | 170 | proc play*(this: var Actor, animName: string, partName: string = "modelRoot") = 171 | this.getAnimControl(animName, partName).play() 172 | 173 | proc loop*(this: var Actor, animName: string, restart: bool = true, partName: string = "modelRoot") = 174 | this.getAnimControl(animName, partName).loop(restart) 175 | 176 | proc pingpong*(this: var Actor, animName: string, restart: bool = true, partName: string = "modelRoot") = 177 | this.getAnimControl(animName, partName).pingpong(restart) 178 | 179 | proc pose*(this: var Actor, animName: string, frame: float, partName: string = "modelRoot") = 180 | this.getAnimControl(animName, partName).pose(frame) 181 | 182 | proc getCurrentAnim*(this: var Actor, partName: string = "modelRoot"): string = 183 | for animName, anim in this.partDict[partName]: 184 | if anim.animControl != nil and anim.animControl.isPlaying(): 185 | return animName 186 | 187 | proc setPlayRate*(this: var Actor, rate: float, animName: string, partName: string = "modelRoot") = 188 | this.getAnimControl(animName, partName).setPlayRate(rate) 189 | -------------------------------------------------------------------------------- /direct/interval.nim: -------------------------------------------------------------------------------- 1 | import ../panda3d/core 2 | import ../panda3d/direct 3 | 4 | export direct 5 | 6 | var lerpNodePathNum = 1 7 | var sequenceNum = 1 8 | var parallelNum = 1 9 | var funcNum = 1 10 | 11 | proc posInterval*(nodePath: NodePath, duration: float, pos: VBase3, startPos: VBase3): CLerpNodePathInterval = 12 | let num = lerpNodePathNum 13 | lerpNodePathNum += 1 14 | var ival = newCLerpNodePathInterval("LerpPosInterval-" & $num, duration, CLerpInterval.BTNoBlend, true, false, nodePath, initNodePath()) 15 | ival.setStartPos(startPos) 16 | ival.setEndPos(pos) 17 | return ival 18 | 19 | proc hprInterval*(nodePath: NodePath, duration: float, hpr: VBase3, startHpr: VBase3): CLerpNodePathInterval = 20 | let num = lerpNodePathNum 21 | lerpNodePathNum += 1 22 | var ival = newCLerpNodePathInterval("LerpHprInterval-" & $num, duration, CLerpInterval.BTNoBlend, true, false, nodePath, initNodePath()) 23 | ival.setStartHpr(startHpr) 24 | ival.setEndHpr(hpr) 25 | return ival 26 | 27 | proc Sequence*(ivals: varargs[CInterval], name: string = ""): CMetaInterval = 28 | let num = sequenceNum 29 | sequenceNum += 1 30 | var meta = newCMetaInterval("Sequence-" & $num) 31 | for ival in ivals: 32 | discard meta.addCInterval(ival, 0, CMetaInterval.RSPreviousEnd) 33 | return meta 34 | 35 | proc Parallel*(ivals: varargs[CInterval], name: string = ""): CMetaInterval = 36 | let num = parallelNum 37 | parallelNum += 1 38 | var meta = newCMetaInterval("Parallel-" & $num) 39 | for ival in ivals: 40 | discard meta.addCInterval(ival, 0, CMetaInterval.RSLevelBegin) 41 | return meta 42 | 43 | proc Wait*(duration: float): WaitInterval = 44 | return newWaitInterval(duration) 45 | 46 | {.emit: """/*TYPESECTION*/ 47 | #include "cInterval.h" 48 | 49 | N_LIB_PRIVATE N_NIMCALL(void, unrefEnv)(void *envp); 50 | 51 | class NimFunctionInterval final : public CInterval { 52 | public: 53 | typedef void Function(void *env); 54 | 55 | NimFunctionInterval(const std::string &name, Function *proc, void *env) : 56 | CInterval(name, 0.0, true), 57 | _proc(proc), 58 | _env(env) {} 59 | 60 | virtual ~NimFunctionInterval() { 61 | if (_env != nullptr) { 62 | unrefEnv(_env); 63 | } 64 | } 65 | 66 | virtual void priv_instant() override { 67 | _proc(_env); 68 | } 69 | 70 | private: 71 | Function *_proc; 72 | void *_env; 73 | }; 74 | """.} 75 | 76 | proc Func*(function: proc()): CInterval = 77 | var procp = rawProc(function); 78 | var envp = rawEnv(function); 79 | if envp != nil: 80 | GC_ref(cast[RootRef](envp)) 81 | 82 | let num = funcNum 83 | funcNum += 1 84 | let name: string = "Func-" & $num 85 | 86 | {.emit: """ 87 | std::string cname; 88 | if (name != nullptr) { 89 | cname.assign(`name`->data, `name`->len); 90 | } 91 | `result` = new NimFunctionInterval(cname, (NimFunctionInterval::Function *)`procp`, `envp`); 92 | """.} 93 | 94 | template Func*[T1](function: proc(arg1: T1), arg1: T1): CInterval = 95 | Func(proc() = function(arg1)) 96 | 97 | template Func*[T1, T2](function: proc(arg1: T1, arg2: T2), arg1: T1, arg2: T2): CInterval = 98 | Func(proc() = function(arg1, arg2)) 99 | 100 | template Func*[T1, T2, T3](function: proc(arg1: T1, arg2: T2, arg3: T3), arg1: T1, arg2: T2, arg3: T3): CInterval = 101 | Func(proc() = function(arg1, arg2, arg3)) 102 | 103 | template Func*[T1, T2, T3, T4](function: proc(arg1: T1, arg2: T2, arg3: T3, arg4: T4), arg1: T1, arg2: T2, arg3: T3, arg4: T4): CInterval = 104 | Func(proc() = function(arg1, arg2, arg3, arg4)) 105 | 106 | template Func*[T1, T2, T3, T4, T5](function: proc(arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5), arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): CInterval = 107 | Func(proc() = function(arg1, arg2, arg3, arg4, arg5)) 108 | -------------------------------------------------------------------------------- /direct/loader.nim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/direct/loader.nim -------------------------------------------------------------------------------- /direct/showbase.nim: -------------------------------------------------------------------------------- 1 | import ./showbase/DirectObject 2 | import ./showbase/Loader 3 | import ./showbase/ShowBase 4 | 5 | export DirectObject 6 | export Loader 7 | export ShowBase 8 | -------------------------------------------------------------------------------- /direct/showbase/DirectObject.nim: -------------------------------------------------------------------------------- 1 | import ./Messenger 2 | import ./MessengerGlobal 3 | 4 | export Messenger.DirectObject 5 | 6 | proc accept*(this: DirectObject, event: string, function: proc ()) = 7 | messenger.accept(event, this, function) 8 | 9 | proc accept*[T](this: DirectObject, event: string, function: proc (param: T)) = 10 | messenger.accept(event, this, function) 11 | 12 | proc ignore*(this: DirectObject, event: string) = 13 | messenger.ignore(event, this) 14 | 15 | proc ignoreAll*(this: DirectObject) = 16 | messenger.ignoreAll(this) 17 | -------------------------------------------------------------------------------- /direct/showbase/EventManager.nim: -------------------------------------------------------------------------------- 1 | import ../../panda3d/core 2 | import ../task 3 | import ./Messenger 4 | import ./MessengerGlobal 5 | 6 | type 7 | EventManager* = ref object of RootObj 8 | eventQueue*: EventQueue 9 | 10 | proc doEvents*(this: EventManager) = 11 | while not this.eventQueue.isQueueEmpty(): 12 | var event = this.eventQueue.dequeueEvent() 13 | var numParams = event.getNumParameters() 14 | var parameters = newSeq[EventParameter](numParams) 15 | 16 | for i in 0..numParams-1: 17 | parameters[i] = event.getParameter(i) 18 | 19 | messenger.send(event.name, parameters) 20 | 21 | proc eventLoopTask(this: EventManager, task: Task): auto = 22 | this.doEvents() 23 | Task.cont 24 | 25 | proc restart*(this: EventManager) = 26 | taskMgr.add(proc (task: Task): auto = this.eventLoopTask(task), "eventManager") 27 | -------------------------------------------------------------------------------- /direct/showbase/EventManagerGlobal.nim: -------------------------------------------------------------------------------- 1 | import ../../panda3d/core 2 | import ./EventManager 3 | 4 | var eventMgr* = EventManager(eventQueue: EventQueue.getGlobalEventQueue()) 5 | -------------------------------------------------------------------------------- /direct/showbase/Loader.nim: -------------------------------------------------------------------------------- 1 | import ../../panda3d/core 2 | 3 | type 4 | PandaLoader = Loader 5 | 6 | type 7 | Loader* = ref object of RootObj 8 | sfxManager*: AudioManager 9 | musicManager*: AudioManager 10 | 11 | proc loadModel*(this: Loader, modelPath: string, loaderOptions: LoaderOptions = LoaderOptions()): NodePath = 12 | var loader = PandaLoader.getGlobalPtr() 13 | return initNodePath(loader.loadSync(initFilename(modelPath), loaderOptions)) 14 | 15 | proc loadTexture*(this: Loader, texturePath: string): Texture = 16 | var texture = TexturePool.loadTexture(initFilename(texturePath)) 17 | if texture == nil: 18 | var e: ref IOError 19 | new(e) 20 | e.msg = "Could not load texture: " & texturePath 21 | raise e 22 | return texture 23 | 24 | proc loadSound*(this: Loader, manager: AudioManager, soundPath: string, positional: bool = false): AudioSound = 25 | return manager.getSound(initFilename(soundPath), positional, 0) 26 | 27 | proc loadSfx*(this: Loader, soundPath: string, positional: bool = false): AudioSound = 28 | if this.sfxManager == nil: 29 | this.sfxManager = AudioManager.createAudioManager() 30 | return this.loadSound(this.sfxManager, soundPath, positional) 31 | 32 | proc loadMusic*(this: Loader, soundPath: string, positional: bool = false): AudioSound = 33 | if this.musicManager == nil: 34 | this.musicManager = AudioManager.createAudioManager() 35 | this.musicManager.setConcurrentSoundLimit(1) 36 | return this.loadSound(this.musicManager, soundPath, positional) 37 | 38 | var loader* = Loader() 39 | -------------------------------------------------------------------------------- /direct/showbase/Messenger.nim: -------------------------------------------------------------------------------- 1 | import ../../panda3d/core 2 | import std/tables 3 | 4 | type 5 | DirectObject* = ref object of RootObj 6 | messengerId: int 7 | 8 | type 9 | Messenger* = ref object of RootObj 10 | callbacks: Table[string, Table[int, proc (args: openArray[EventParameter])]] 11 | 12 | var nextMessengerId = 1 13 | 14 | proc accept*(this: Messenger, event: string, obj: DirectObject, function: proc ()) = 15 | var acceptorDict = addr this.callbacks.mgetOrPut(event, Table[int, proc (args: openArray[EventParameter])]()) 16 | if obj.messengerId == 0: 17 | obj.messengerId = nextMessengerId 18 | nextMessengerId += 1 19 | 20 | acceptorDict[][obj.messengerId] = (proc(args: openArray[EventParameter]) = function()) 21 | 22 | proc accept*[T](this: Messenger, event: string, obj: DirectObject, function: proc (param: T)) = 23 | var acceptorDict = addr this.callbacks.mgetOrPut(event, Table[int, proc (args: openArray[EventParameter])]()) 24 | if obj.messengerId == 0: 25 | obj.messengerId = nextMessengerId 26 | nextMessengerId += 1 27 | 28 | acceptorDict[][obj.messengerId] = (proc(args: openArray[EventParameter]) = function(T.dcast(args[0].getPtr()))) 29 | 30 | proc ignore*(this: Messenger, event: string, obj: DirectObject) = 31 | if obj.messengerId == 0: 32 | return 33 | 34 | if this.callbacks.hasKey(event): 35 | this.callbacks[event].del(obj.messengerId) 36 | 37 | proc ignoreAll*(this: Messenger, obj: DirectObject) = 38 | if obj.messengerId == 0: 39 | return 40 | 41 | for event in this.callbacks.keys(): 42 | this.callbacks[event].del(obj.messengerId) 43 | 44 | proc send*(this: Messenger, event: string, sentArgs: openArray[EventParameter] = []) = 45 | if this.callbacks.hasKey(event): 46 | var acceptorDict = this.callbacks.getOrDefault(event) 47 | for function in acceptorDict.values: 48 | function(sentArgs) 49 | -------------------------------------------------------------------------------- /direct/showbase/MessengerGlobal.nim: -------------------------------------------------------------------------------- 1 | import ./Messenger 2 | 3 | var messenger* = Messenger() 4 | -------------------------------------------------------------------------------- /direct/showbase/ShowBase.nim: -------------------------------------------------------------------------------- 1 | import ../../panda3d/core 2 | import ../../panda3d/direct 3 | import ../task 4 | import ./DirectObject 5 | import ./EventManagerGlobal 6 | import ./EventManager 7 | from ./Loader import loader 8 | 9 | var aspect2d* = initNodePath(newPGTop("aspect2d")) 10 | var render* = initNodePath("render") 11 | var render2d* = initNodePath("render2d") 12 | aspect2d.reparentTo(render2d) 13 | 14 | type 15 | ShowBase* = ref object of DirectObject 16 | a2dBackground*: NodePath 17 | a2dBottom*: float 18 | a2dBottomCenter*: NodePath 19 | a2dBottomLeft*: NodePath 20 | a2dBottomRight*: NodePath 21 | a2dLeft*: float 22 | a2dLeftCenter*: NodePath 23 | a2dRight*: float 24 | a2dRightCenter*: NodePath 25 | a2dTop*: float 26 | a2dTopCenter*: NodePath 27 | a2dTopLeft*: NodePath 28 | a2dTopRight*: NodePath 29 | aspect2d*: NodePath 30 | cam*: NodePath 31 | cam2d*: NodePath 32 | camera*: NodePath 33 | camera2d*: NodePath 34 | camLens*: Lens 35 | camNode*: Camera 36 | clock*: ClockObject 37 | dataRoot*: NodePath 38 | dataRootNode*: PandaNode 39 | drive*: NodePath 40 | frameRateMeter*: FrameRateMeter 41 | graphicsEngine*: GraphicsEngine 42 | loader*: type(Loader.loader) 43 | mouse2cam*: NodePath 44 | mouseInterface*: NodePath 45 | mouseInterfaceNode*: MouseInterfaceNode 46 | mouseWatcher*: NodePath 47 | mouseWatcherNode*: MouseWatcher 48 | pipe*: GraphicsPipe 49 | render*: NodePath 50 | render2d*: NodePath 51 | taskMgr*: TaskManager 52 | timeButtonThrower*: NodePath 53 | trackball*: NodePath 54 | win*: GraphicsOutput 55 | windowType*: string 56 | wireframeEnabled*: bool 57 | 58 | proc makeDefaultPipe*(this: ShowBase) = 59 | var selection = GraphicsPipeSelection.getGlobalPtr() 60 | selection.printPipeTypes() 61 | this.pipe = selection.makeDefaultPipe() 62 | 63 | proc makeAllPipes*(this: ShowBase) = 64 | if this.pipe == nil: 65 | this.makeDefaultPipe() 66 | 67 | proc dataLoop(this: ShowBase): auto = 68 | var dgTrav = initDataGraphTraverser() 69 | dgTrav.traverse(this.dataRootNode) 70 | return Task.cont 71 | 72 | proc ivalLoop(this: ShowBase): auto = 73 | var ivalMgr = CIntervalManager.getGlobalPtr() 74 | ivalMgr.step() 75 | return Task.cont 76 | 77 | proc igLoop(this: ShowBase): auto = 78 | this.graphicsEngine.renderFrame() 79 | return Task.cont 80 | 81 | proc audioLoop(this: ShowBase): auto = 82 | if this.loader.musicManager != nil: 83 | this.loader.musicManager.update() 84 | if this.loader.sfxManager != nil: 85 | this.loader.sfxManager.update() 86 | return Task.cont 87 | 88 | proc getAspectRatio*(this: ShowBase): float = 89 | return this.win.getSbsLeftXSize() / this.win.getSbsLeftYSize() 90 | 91 | proc adjustWindowAspectRatio*(this: ShowBase, aspectRatio: float) = 92 | if this.camLens != nil: 93 | this.camLens.aspectRatio = aspectRatio 94 | 95 | if aspectRatio < 1: 96 | # If the window is TALL, lets expand the top and bottom 97 | this.aspect2d.setScale(1.0, aspectRatio, aspectRatio) 98 | this.a2dTop = 1.0 / aspectRatio 99 | this.a2dBottom = - 1.0 / aspectRatio 100 | this.a2dLeft = -1 101 | this.a2dRight = 1.0 102 | else: 103 | # If the window is WIDE, lets expand the left and right 104 | this.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0) 105 | this.a2dTop = 1.0 106 | this.a2dBottom = -1.0 107 | this.a2dLeft = -aspectRatio 108 | this.a2dRight = aspectRatio 109 | 110 | # Reposition the aspect2d marker nodes 111 | this.a2dTopCenter.setPos(0, 0, this.a2dTop) 112 | this.a2dBottomCenter.setPos(0, 0, this.a2dBottom) 113 | this.a2dLeftCenter.setPos(this.a2dLeft, 0, 0) 114 | this.a2dRightCenter.setPos(this.a2dRight, 0, 0) 115 | 116 | this.a2dTopLeft.setPos(this.a2dLeft, 0, this.a2dTop) 117 | this.a2dTopRight.setPos(this.a2dRight, 0, this.a2dTop) 118 | this.a2dBottomLeft.setPos(this.a2dLeft, 0, this.a2dBottom) 119 | this.a2dBottomRight.setPos(this.a2dRight, 0, this.a2dBottom) 120 | 121 | proc finalizeExit(this: ShowBase) = 122 | quit(0) 123 | 124 | proc userExit(this: ShowBase) = 125 | this.finalizeExit() 126 | 127 | proc windowEvent*(this: ShowBase, win: GraphicsWindow) = 128 | this.adjustWindowAspectRatio(this.getAspectRatio()) 129 | 130 | var properties = win.getProperties() 131 | if not properties.open: 132 | this.userExit() 133 | 134 | proc setupDataGraph*(this: ShowBase) = 135 | this.dataRoot = initNodePath("dataRoot") 136 | this.dataRootNode = this.dataRoot.node() 137 | 138 | this.trackball = initNodePath(newTrackball("trackball")) 139 | this.drive = initNodePath(newDriveInterface("drive")) 140 | this.mouse2cam = initNodePath(newTransform2SG("mouse2cam")) 141 | 142 | proc changeMouseInterface*(this: ShowBase, changeTo: NodePath) = 143 | this.mouseInterface.detachNode() 144 | this.mouseInterface = changeTo 145 | this.mouseInterfaceNode = dcast(MouseInterfaceNode, changeTo.node()) 146 | if not this.mouseWatcher.isEmpty: 147 | this.mouseInterface.reparentTo(this.mouseWatcher) 148 | if not this.mouse2cam.isEmpty: 149 | this.mouse2cam.reparentTo(this.mouseInterface) 150 | 151 | proc useDrive*(this: ShowBase) = 152 | if not this.drive.isEmpty: 153 | this.changeMouseInterface(this.drive) 154 | # Set the height to a good eyeheight 155 | this.drive.reset() 156 | this.drive.setZ(4.0) 157 | 158 | proc useTrackball*(this: ShowBase) = 159 | if not this.trackball.isEmpty: 160 | this.changeMouseInterface(this.trackball) 161 | 162 | proc setupMouse*(this: ShowBase, win: GraphicsWindow) = 163 | let name = win.getInputDeviceName(0) 164 | var mk = this.dataRoot.attachNewNode(newMouseAndKeyboard(win, 0, name)) 165 | var mwn = newMouseWatcher("watcher0") 166 | var mw = mk.attachNewNode(mwn) 167 | 168 | if win.getSideBySideStereo(): 169 | mwn.setDisplayRegion(win.getOverlayDisplayRegion()) 170 | 171 | var mb = mwn.getModifierButtons() 172 | discard mb.addButton(KeyboardButton.shift()) 173 | discard mb.addButton(KeyboardButton.control()) 174 | discard mb.addButton(KeyboardButton.alt()) 175 | discard mb.addButton(KeyboardButton.meta()) 176 | mwn.setModifierButtons(mb) 177 | var btn = newButtonThrower("buttons0") 178 | discard mw.attachNewNode(btn) 179 | var mods = initModifierButtons() 180 | discard mods.addButton(KeyboardButton.shift()) 181 | discard mods.addButton(KeyboardButton.control()) 182 | discard mods.addButton(KeyboardButton.alt()) 183 | discard mods.addButton(KeyboardButton.meta()) 184 | btn.setModifierButtons(mods) 185 | 186 | this.mouseWatcher = mw 187 | this.mouseWatcherNode = mwn 188 | 189 | this.mouseInterface.reparentTo(this.mouseWatcher) 190 | 191 | var timeButtonThrowerNode = newButtonThrower("timeButtons") 192 | this.timeButtonThrower = mw.attachNewNode(timeButtonThrowerNode) 193 | timeButtonThrowerNode.setPrefix("time-") 194 | timeButtonThrowerNode.setTimeFlag(true) 195 | 196 | # Tell the gui system about our new mouse watcher. 197 | dcast(PGTop, aspect2d.node()).setMouseWatcher(mwn) 198 | 199 | mwn.upcastToMouseWatcherBase.addRegion(newPGMouseWatcherBackground()) 200 | 201 | proc getAspectRatio*(this: ShowBase, win: GraphicsOutput): float = 202 | var aspectRatio: float = 1 203 | 204 | if win != nil and win.hasSize() and win.getSbsLeftYSize() != 0: 205 | aspectRatio = float(win.getSbsLeftXSize()) / float(win.getSbsLeftYSize()) 206 | else: 207 | var props: WindowProperties 208 | if win == nil or not win.isOfType(GraphicsWindow.getClassType()): 209 | props = WindowProperties.getDefault() 210 | else: 211 | props = dcast(GraphicsWindow, win).getRequestedProperties() 212 | if not props.hasSize(): 213 | props = WindowProperties.getDefault() 214 | 215 | if props.hasSize() and props.getYSize() != 0: 216 | aspectRatio = float(props.getXSize()) / float(props.getYSize()) 217 | 218 | if aspectRatio == 0: 219 | return 1 220 | 221 | return aspectRatio 222 | 223 | proc makeCamera2d*(this: ShowBase, win: GraphicsOutput, sort: int = 10, 224 | displayRegion: tuple[left: float32, right: float32, bottom: float32, top: float32] = (0f32, 1f32, 0f32, 1f32), 225 | coords: tuple[left: float32, right: float32, bottom: float32, top: float32] = (-1f32, 1f32, -1f32, 1f32)): NodePath = 226 | 227 | var dr = win.makeMonoDisplayRegion(displayRegion.left, displayRegion.right, 228 | displayRegion.bottom, displayRegion.top) 229 | dr.setSort(sort) 230 | 231 | # Enable clearing of the depth buffer on this new display 232 | # region (see the comment in setupRender2d, above). 233 | dr.setClearDepthActive(true) 234 | 235 | # Make any texture reloads on the gui come up immediately. 236 | dr.setIncompleteRender(false) 237 | 238 | var (left, right, bottom, top) = coords 239 | 240 | # Now make a new Camera node. 241 | var cam2dNode = newCamera("cam2d") 242 | 243 | var lens = newOrthographicLens() 244 | lens.setFilmSize(right - left, top - bottom) 245 | lens.setFilmOffset((right + left) * 0.5, (top + bottom) * 0.5) 246 | lens.setNearFar(-1000, 1000) 247 | cam2dNode.setLens(lens) 248 | 249 | # this.camera2d is the analog of this.camera, although it's 250 | # not as clear how useful it is. 251 | if this.camera2d.isEmpty(): 252 | this.camera2d = this.render2d.attachNewNode("camera2d") 253 | 254 | var camera2d = this.camera2d.attachNewNode(cam2dNode) 255 | dr.setCamera(camera2d) 256 | 257 | if this.cam2d.isEmpty(): 258 | this.cam2d = camera2d 259 | 260 | return camera2d 261 | 262 | proc setupRender2d*(this: ShowBase) = 263 | this.render2d.setDepthTest(false) 264 | this.render2d.setDepthWrite(false) 265 | this.render2d.setMaterialOff(1) 266 | this.render2d.setTwoSided(true) 267 | 268 | var aspectRatio = this.getAspectRatio() 269 | this.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0) 270 | 271 | this.a2dBackground = this.aspect2d.attachNewNode("a2dBackground") 272 | 273 | # The Z position of the top border of the aspect2d screen. 274 | this.a2dTop = 1.0 275 | # The Z position of the bottom border of the aspect2d screen. 276 | this.a2dBottom = -1.0 277 | # The X position of the left border of the aspect2d screen. 278 | this.a2dLeft = -aspectRatio 279 | # The X position of the right border of the aspect2d screen. 280 | this.a2dRight = aspectRatio 281 | 282 | this.a2dTopCenter = this.aspect2d.attachNewNode("a2dTopCenter") 283 | this.a2dBottomCenter = this.aspect2d.attachNewNode("a2dBottomCenter") 284 | this.a2dLeftCenter = this.aspect2d.attachNewNode("a2dLeftCenter") 285 | this.a2dRightCenter = this.aspect2d.attachNewNode("a2dRightCenter") 286 | 287 | this.a2dTopLeft = this.aspect2d.attachNewNode("a2dTopLeft") 288 | this.a2dTopRight = this.aspect2d.attachNewNode("a2dTopRight") 289 | this.a2dBottomLeft = this.aspect2d.attachNewNode("a2dBottomLeft") 290 | this.a2dBottomRight = this.aspect2d.attachNewNode("a2dBottomRight") 291 | 292 | # Put the nodes in their places 293 | this.a2dTopCenter.setPos(0, 0, this.a2dTop) 294 | this.a2dBottomCenter.setPos(0, 0, this.a2dBottom) 295 | this.a2dLeftCenter.setPos(this.a2dLeft, 0, 0) 296 | this.a2dRightCenter.setPos(this.a2dRight, 0, 0) 297 | 298 | this.a2dTopLeft.setPos(this.a2dLeft, 0, this.a2dTop) 299 | this.a2dTopRight.setPos(this.a2dRight, 0, this.a2dTop) 300 | this.a2dBottomLeft.setPos(this.a2dLeft, 0, this.a2dBottom) 301 | this.a2dBottomRight.setPos(this.a2dRight, 0, this.a2dBottom) 302 | 303 | proc openMainWindow*(this: ShowBase, props: WindowProperties = WindowProperties.getDefault()) = 304 | this.makeAllPipes() 305 | this.graphicsEngine = GraphicsEngine.getGlobalPtr() 306 | 307 | eventMgr.restart() 308 | this.accept("window-event", proc (win: GraphicsWindow) = this.windowEvent(win)) 309 | 310 | if this.windowType == "": 311 | this.windowType = "onscreen" 312 | 313 | var flags: int 314 | if this.windowType == "onscreen": 315 | flags = 0x0808 316 | elif this.windowType == "offscreen": 317 | flags = 0x0804 318 | else: 319 | flags = 0x0800 320 | 321 | var fbprops: FrameBufferProperties = FrameBufferProperties.getDefault() 322 | this.win = this.graphicsEngine.makeOutput(this.pipe, "window", 0, fbprops, props, flags) 323 | 324 | this.taskMgr = taskMgr 325 | this.loader = Loader.loader 326 | this.render = render 327 | this.render2d = render2d 328 | this.aspect2d = aspect2d 329 | this.camera = this.render.attachNewNode(newModelNode("camera")) 330 | this.camNode = newCamera("cam") 331 | this.camLens = this.camNode.getLens() 332 | this.cam = this.camera.attachNewNode(this.camNode) 333 | this.clock = ClockObject.getGlobalClock() 334 | 335 | dcast(ModelNode, this.camera.node()).setPreserveTransform(ModelNode.PTLocal) 336 | 337 | this.setupDataGraph() 338 | 339 | this.mouseInterface = this.trackball 340 | this.useTrackball() 341 | 342 | dcast(Transform2SG, this.mouse2cam.node()).setNode(this.camera.node()) 343 | 344 | var dr = this.win.makeDisplayRegion() 345 | dr.setCamera(this.cam) 346 | 347 | this.setupRender2d() 348 | 349 | discard this.makeCamera2d(this.win) 350 | 351 | taskMgr.add(proc (task: Task): auto = this.dataLoop(), "dataLoop", -50) 352 | taskMgr.add(proc (task: Task): auto = this.ivalLoop(), "ivalLoop", 20) 353 | taskMgr.add(proc (task: Task): auto = this.igLoop(), "igLoop", 50) 354 | taskMgr.add(proc (task: Task): auto = this.audioLoop(), "audioLoop", 60) 355 | 356 | this.graphicsEngine.openWindows() 357 | 358 | if this.win.isOfType(GraphicsWindow.getClassType()): 359 | this.setupMouse(dcast(GraphicsWindow, this.win)) 360 | 361 | proc openDefaultWindow*(this: ShowBase, props: WindowProperties = WindowProperties.getDefault()): bool {.discardable.} = 362 | this.openMainWindow() 363 | return this.win != nil 364 | 365 | proc setBackgroundColor*(this: ShowBase, color: LVecBase4) = 366 | this.win.setClearColor(color) 367 | 368 | proc setBackgroundColor*(this: ShowBase, r: float, g: float, b: float) = 369 | this.setBackgroundColor(initLVecBase4f(r, g, b, 0.0f)) 370 | 371 | proc setBackgroundColor*(this: ShowBase, r: float, g: float, b: float, a: float) = 372 | this.setBackgroundColor(initLVecBase4f(r, g, b, a)) 373 | 374 | proc wireframeOn*(this: ShowBase) = 375 | this.render.setRenderModeWireframe(100) 376 | this.render.setTwoSided(true) 377 | this.wireframeEnabled = true 378 | 379 | proc wireframeOff*(this: ShowBase) = 380 | this.render.clearRenderMode() 381 | this.render.setTwoSided(false) 382 | this.wireframeEnabled = false 383 | 384 | proc toggleWireframe*(this: ShowBase) = 385 | if this.wireframeEnabled: 386 | this.wireframeOff() 387 | else: 388 | this.wireframeOn() 389 | 390 | proc disableMouse*(this: ShowBase) = 391 | if not this.mouse2cam.isEmpty: 392 | this.mouse2cam.detachNode() 393 | 394 | proc enableMouse*(this: ShowBase) = 395 | if not this.mouse2cam.isEmpty: 396 | this.mouse2cam.reparentTo(this.mouseInterface) 397 | 398 | proc setFrameRateMeter*(this: ShowBase, flag: bool) = 399 | if flag: 400 | if this.frameRateMeter == nil: 401 | this.frameRateMeter = newFrameRateMeter("frameRateMeter") 402 | this.frameRateMeter.setupWindow(this.win) 403 | else: 404 | if this.frameRateMeter != nil: 405 | this.frameRateMeter.clearWindow() 406 | this.frameRateMeter = toFrameRateMeter(nil) 407 | 408 | proc run*(this: ShowBase) = 409 | taskMgr.run() 410 | -------------------------------------------------------------------------------- /direct/task.nim: -------------------------------------------------------------------------------- 1 | import ../panda3d/core 2 | 3 | {.emit: """/*TYPESECTION*/ 4 | #include "asyncTask.h" 5 | 6 | N_LIB_PRIVATE N_NIMCALL(void, unrefEnv)(void *envp); 7 | 8 | class NimTask final : public AsyncTask { 9 | public: 10 | typedef int TaskProc(PT(AsyncTask) task, void *env); 11 | 12 | NimTask(TaskProc *proc, void *env) : _proc(proc), _env(env) {} 13 | 14 | virtual ~NimTask() { 15 | if (_env != nullptr) { 16 | unrefEnv(_env); 17 | } 18 | } 19 | 20 | ALLOC_DELETED_CHAIN(NimTask); 21 | 22 | virtual DoneStatus do_task() { 23 | return (DoneStatus)_proc(this, _env); 24 | } 25 | 26 | private: 27 | TaskProc *_proc; 28 | void *_env; 29 | }; 30 | """.} 31 | 32 | type 33 | Task* = AsyncTask 34 | 35 | type 36 | DoneStatus {.pure.} = enum 37 | done = 0 38 | cont = 1 39 | again = 2 40 | pickup = 3 41 | exit = 4 42 | 43 | template done*(_: typedesc[Task]): DoneStatus = 44 | DoneStatus.done 45 | 46 | template cont*(_: typedesc[Task]): DoneStatus = 47 | DoneStatus.cont 48 | 49 | template again*(_: typedesc[Task]): DoneStatus = 50 | DoneStatus.again 51 | 52 | template pickup*(_: typedesc[Task]): DoneStatus = 53 | DoneStatus.pickup 54 | 55 | template exit*(_: typedesc[Task]): DoneStatus = 56 | DoneStatus.exit 57 | 58 | type 59 | TaskManager* = ref object of RootObj 60 | mgr: AsyncTaskManager 61 | running: bool 62 | 63 | proc add*(this: TaskManager, function: (proc(task: Task): DoneStatus), name: string, sort: int = 0) : AsyncTask {.discardable.} = 64 | var procp = rawProc(function); 65 | var envp = rawEnv(function); 66 | if envp != nil: 67 | GC_ref(cast[RootRef](envp)) 68 | 69 | {.emit: """ 70 | `result` = new NimTask((NimTask::TaskProc *)`procp`, `envp`); 71 | `this`->mgr->add(`result`.p()); 72 | """.} 73 | 74 | proc stop*(this: TaskManager) = 75 | this.running = false 76 | 77 | proc run*(this: TaskManager) = 78 | this.running = true 79 | while this.running: 80 | this.mgr.poll() 81 | 82 | var taskMgr* = new(TaskManager) 83 | taskMgr.mgr = AsyncTaskManager.getGlobalPtr() 84 | -------------------------------------------------------------------------------- /examples/roaming-ralph/build.sh: -------------------------------------------------------------------------------- 1 | nim -p:../.. --clibdir:/usr/lib/panda3d --cincludes:/usr/include/panda3d --out:ralph -r cpp main.nim 2 | -------------------------------------------------------------------------------- /examples/roaming-ralph/main.nim: -------------------------------------------------------------------------------- 1 | # Author: Original python version by Ryan Myers 2 | # Models: Jeff Styers, Reagan Heller 3 | # 4 | # Last Updated: 2015-03-13 (translated to nim in 2022 by Entikan) 5 | # 6 | # This tutorial provides an example of creating a character 7 | # and having it walk around on uneven terrain, as well 8 | # as implementing a fully rotatable camera. 9 | 10 | 11 | import direct/showbase 12 | import direct/task 13 | import direct/actor 14 | import panda3d/core 15 | 16 | var base = ShowBase() 17 | base.openDefaultWindow() 18 | 19 | proc makeText(y:float, text: string, scale: float = 0.05) = 20 | var textnode = newTextNode("text") 21 | var nodepath = base.aspect2d.attach_new_node(textnode) 22 | textnode.set_text(text) 23 | nodepath.set_scale(scale) 24 | nodepath.set_pos(-0.8,0,0.8-y) 25 | 26 | makeText(0, "Panda3D Tutorial: Roaming Ralph, written in Nim.", 0.06) 27 | makeText(0.06, "[ESC]: Quit") 28 | makeText(0.12, "[Left Arrow]: Rotate Ralph Left") 29 | makeText(0.18, "[Right Arrow]: Rotate Ralph Right") 30 | makeText(0.24, "[Up Arrow]: Run Ralph Forward") 31 | makeText(0.30, "[Down Arrow]: Walk Ralph Backward") 32 | makeText(0.36, "[A]: Rotate Camera Left") 33 | makeText(0.42, "[S]: Rotate Camera Right") 34 | 35 | var environ = base.loader.loadModel("models/world") 36 | environ.reparentTo(base.render) 37 | 38 | # We do not have a skybox, so we will just use a sky blue background color 39 | base.setBackgroundColor(0.53, 0.80, 0.92, 1) 40 | 41 | # Create the main character, Ralph 42 | var 43 | ralphStartPos = environ.find("**/start_point").getPos() 44 | ralph = Actor() 45 | ralph.loadModel("models/ralph") 46 | ralph.loadAnims({"run":"models/ralph-run", "walk":"models/ralph-walk"}) 47 | ralph.reparentTo(base.render) 48 | ralph.setScale(0.2) 49 | ralph.setPos(ralphStartPos) 50 | ralph.setPos(ralph, 0, 0, 1.5) 51 | 52 | # Create a floater object, which floats 2 units above ralph. We 53 | # use this as a target for the camera to look at. 54 | var floater = ralph.attach_new_node("floater") 55 | floater.setZ(2.0) 56 | 57 | # Set up the camera 58 | base.disableMouse() 59 | base.camera.setPos(ralph.getX(), ralph.getY() + 10, 2) 60 | 61 | 62 | # Use a CollisionHandlerPusher to handle collisions between Ralph and 63 | # the environment. Ralph is added as a "from" object which will be 64 | # "pushed" out of the environment if he walks into obstacles. 65 | # 66 | # Ralph is composed of two spheres, one around the torso and one 67 | # around the head. They are slightly oversized since we want Ralph to 68 | # keep some distance from obstacles. 69 | var cTrav = CollisionTraverser() 70 | 71 | var 72 | ralphCol = newCollisionNode("ralph") 73 | ralphColNp = ralph.attachNewNode(ralphCol) 74 | ralphPusher = newCollisionHandlerPusher() 75 | 76 | discard ralphCol.addSolid(newCollisionSphere(0, 0, 2, 1.5)) 77 | discard ralphCol.addSolid(newCollisionSphere(0, -0.25, 5, 1.5)) 78 | ralphCol.setFromCollideMask(CollideMask.bit(0)) 79 | ralphCol.setIntoCollideMask(CollideMask.allOff()) 80 | ralphPusher.horizontal = true 81 | ralphPusher.addCollider(ralphColNp, ralph) 82 | cTrav.addCollider(ralphColNp, ralphPusher) 83 | 84 | var 85 | ralphGroundRay = newCollisionRay() 86 | ralphGroundCol = newCollisionNode("ralphRay") 87 | ralphGroundColNp = ralph.attachNewNode(ralphGroundCol) 88 | ralphGroundHandler = newCollisionHandlerQueue() 89 | 90 | ralphGroundRay.setOrigin(0, 0, 9) 91 | ralphGroundRay.setDirection(0, 0, -1) 92 | discard ralphGroundCol.addSolid(ralphGroundRay) 93 | ralphGroundCol.setFromCollideMask(CollideMask.bit(0)) 94 | ralphGroundCol.setIntoCollideMask(CollideMask.allOff()) 95 | cTrav.addCollider(ralphGroundColNp, ralphGroundHandler) 96 | 97 | var 98 | camGroundRay = newCollisionRay() 99 | camGroundCol = newCollisionNode("camRay") 100 | camGroundColNp = base.camera.attachNewNode(camGroundCol) 101 | camGroundHandler = newCollisionHandlerQueue() 102 | 103 | camGroundRay.setOrigin(0, 0, 9) 104 | camGroundRay.setDirection(0, 0, -1) 105 | discard camGroundCol.addSolid(camGroundRay) 106 | camGroundCol.setFromCollideMask(CollideMask.bit(0)) 107 | camGroundCol.setIntoCollideMask(CollideMask.allOff()) 108 | cTrav.addCollider(camGroundColNp, camGroundHandler) 109 | 110 | # Uncomment this line to see the collision rays 111 | #ralphColNp.show() 112 | #camGroundColNp.show() 113 | 114 | # Uncomment this line to show a visual representation of the 115 | # collisions occuring 116 | #cTrav.showCollisions(base.render) 117 | 118 | # Create some lighting 119 | var ambientLight = newAmbientLight("ambientLight") 120 | ambientLight.setColor(initLVector4f(0.3, 0.3, 0.3, 1.0)) 121 | base.render.setLight(base.render.attachNewNode(ambientLight)) 122 | 123 | var directionalLight = newDirectionalLight("directionalLight") 124 | directionalLight.setDirection(initLVector3f(-5, -5, -5)) 125 | directionalLight.setColor(initLVector4f(1)) 126 | directionalLight.setSpecularColor(initLVector4f(1)) 127 | base.render.setLight(base.render.attachNewNode(directionalLight)) 128 | 129 | 130 | # This is used to store which keys are currently pressed. 131 | type 132 | Keys = enum 133 | left, right, forward, backward, 134 | cam_left, cam_right 135 | KeyMap = array[left..cam_right, bool] 136 | var keyMap: KeyMap 137 | 138 | # Records the state of the arrow keys 139 | proc setKey(key: Keys, value: bool) = 140 | keyMap[key] = value 141 | 142 | 143 | base.accept("escape", proc () = quit(0)) 144 | base.accept("arrow_left", proc () = setKey(left, true)) 145 | base.accept("arrow_right", proc () = setKey(right, true)) 146 | base.accept("arrow_up", proc () = setKey(forward, true)) 147 | base.accept("arrow_down", proc () = setKey(backward, true)) 148 | base.accept("a", proc () = setKey(cam_left, true)) 149 | base.accept("s", proc () = setKey(cam_right, true)) 150 | 151 | base.accept("arrow_left-up", proc () = setKey(left, false)) 152 | base.accept("arrow_right-up", proc () = setKey(right, false)) 153 | base.accept("arrow_up-up", proc () = setKey(forward, false)) 154 | base.accept("arrow_down-up", proc () = setKey(backward, false)) 155 | base.accept("a-up", proc () = setKey(cam_left, false)) 156 | base.accept("s-up", proc () = setKey(cam_right, false)) 157 | 158 | var currentAnim: string 159 | 160 | # Accepts arrow keys to move either the player or the menu cursor, 161 | # Also deals with grid checking and collision detection 162 | proc move(task:Task): auto = 163 | var dt = base.clock.get_dt() 164 | if keyMap[cam_left]: 165 | base.camera.setX(base.camera, -20 * dt) 166 | if keyMap[cam_right]: 167 | base.camera.setX(base.camera, +20 * dt) 168 | # If a move-key is pressed, move ralph in the specified direction. 169 | if keyMap[left]: 170 | ralph.setH(ralph.getH() + 300 * dt) 171 | if keyMap[right]: 172 | ralph.setH(ralph.getH() - 300 * dt) 173 | if keyMap[forward]: 174 | ralph.setY(ralph, -20 * dt) 175 | if keyMap[backward]: 176 | ralph.setY(ralph, +10 * dt) 177 | 178 | # If ralph is moving, loop the run animation. 179 | # If he is standing still, stop the animation. 180 | currentAnim = ralph.getCurrentAnim() 181 | if currentAnim == "": 182 | currentAnim = "none" 183 | 184 | if keyMap[forward]: 185 | if currentAnim != "run": 186 | ralph.loop("run") 187 | elif keyMap[backward]: 188 | # Play the walk animation backwards. 189 | if currentAnim != "walk": 190 | ralph.loop("walk") 191 | ralph.setPlayRate(-1.0, "walk") 192 | elif keyMap[left] or keyMap[right]: 193 | if currentAnim != "walk": 194 | ralph.loop("walk") 195 | ralph.setPlayRate(1.0, "walk") 196 | else: 197 | ralph.stop("run") 198 | ralph.stop("walk") 199 | ralph.pose("walk", 5) 200 | 201 | var camvec = ralph.getPos() - base.camera.getPos() 202 | camvec.setZ(0) 203 | var camdist = camvec.length() 204 | discard camvec.normalize() 205 | if camdist > 10: 206 | base.camera.setPos(base.camera.getPos() + camvec * (camdist - 10)) 207 | camdist = 10 208 | if camdist < 5.0: 209 | base.camera.setPos(base.camera.getPos() - camvec * (5 - camdist)) 210 | camdist = 5.0 211 | # Normally, we would have to call traverse() to check for collisions. 212 | # However, the class ShowBase that we inherit from has a task to do 213 | # this for us, if we assign a CollisionTraverser to self.cTrav. 214 | cTrav.traverse(render) 215 | 216 | # Adjust ralph's Z coordinate. If ralph's ray hit terrain, 217 | # update his Z 218 | 219 | ralphGroundHandler.sortEntries() 220 | var entry = ralphGroundHandler.getEntry(0) 221 | if entry.getIntoNode().name == "terrain": 222 | ralph.setZ(entry.getSurfacePoint(render).getZ()) 223 | 224 | camGroundHandler.sortEntries() 225 | entry = camGroundHandler.getEntry(0) 226 | if entry.getIntoNode().name == "terrain": 227 | base.camera.setZ(entry.getSurfacePoint(render).getZ()+1.5) 228 | if base.camera.getZ() < ralph.getZ() + 2.0: 229 | base.camera.setZ(ralph.getZ() + 2.0) 230 | 231 | base.camera.lookAt(floater) 232 | Task.cont 233 | 234 | base.taskMgr.add(move, "moveTask") 235 | base.run() 236 | -------------------------------------------------------------------------------- /examples/roaming-ralph/models/ground.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/ground.jpg -------------------------------------------------------------------------------- /examples/roaming-ralph/models/hedge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/hedge.jpg -------------------------------------------------------------------------------- /examples/roaming-ralph/models/ralph-run.egg.pz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/ralph-run.egg.pz -------------------------------------------------------------------------------- /examples/roaming-ralph/models/ralph-walk.egg.pz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/ralph-walk.egg.pz -------------------------------------------------------------------------------- /examples/roaming-ralph/models/ralph.egg.pz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/ralph.egg.pz -------------------------------------------------------------------------------- /examples/roaming-ralph/models/ralph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/ralph.jpg -------------------------------------------------------------------------------- /examples/roaming-ralph/models/rock03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/rock03.jpg -------------------------------------------------------------------------------- /examples/roaming-ralph/models/tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/tree.jpg -------------------------------------------------------------------------------- /examples/roaming-ralph/models/world.egg.pz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdb/nim-panda3d/ac908ca9fb8789d14cb2166bc3db0f00f7906e5e/examples/roaming-ralph/models/world.egg.pz -------------------------------------------------------------------------------- /panda3d/direct.nim: -------------------------------------------------------------------------------- 1 | 2 | import ./private 3 | import ./core 4 | 5 | when defined(vcc): 6 | when defined(pandaDir): 7 | {.passL: "\"" & pandaDir & "/lib/libp3direct.lib\"".} 8 | else: 9 | {.passL: "libp3direct.lib".} 10 | else: 11 | {.passL: "-lp3direct".} 12 | 13 | type DCSubatomicType* {.importcpp: "DCSubatomicType", header: "dcSubatomicType.h".} = enum 14 | ST_int8 = 0 15 | ST_int16 = 1 16 | ST_int32 = 2 17 | ST_int64 = 3 18 | ST_uint8 = 4 19 | ST_uint16 = 5 20 | ST_uint32 = 6 21 | ST_uint64 = 7 22 | ST_float64 = 8 23 | ST_string = 9 24 | ST_blob = 10 25 | ST_blob32 = 11 26 | ST_int16array = 12 27 | ST_int32array = 13 28 | ST_uint16array = 14 29 | ST_uint32array = 15 30 | ST_int8array = 16 31 | ST_uint8array = 17 32 | ST_uint32uint8array = 18 33 | ST_char = 19 34 | ST_invalid = 20 35 | 36 | type DCPackType* {.importcpp: "DCPackType", header: "dcPackerInterface.h".} = enum 37 | PT_invalid = 0 38 | PT_double = 1 39 | PT_int = 2 40 | PT_uint = 3 41 | PT_int64 = 4 42 | PT_uint64 = 5 43 | PT_string = 6 44 | PT_blob = 7 45 | PT_array = 8 46 | PT_field = 9 47 | PT_class = 10 48 | PT_switch = 11 49 | 50 | type DCPackerInterface* {.importcpp: "DCPackerInterface*", bycopy, pure, inheritable, header: "dcPackerInterface.h".} = object 51 | 52 | converter toDCPackerInterface*(_: type(nil)): DCPackerInterface {.importcpp: "(nullptr)".} 53 | 54 | type DCKeywordList* {.importcpp: "DCKeywordList", pure, inheritable, header: "dcKeywordList.h".} = object 55 | 56 | type DCField* {.importcpp: "DCField*", bycopy, pure, inheritable, header: "dcField.h".} = object of DCPackerInterface 57 | 58 | converter upcastToDCKeywordList*(_: typedesc[DCField]): typedesc[DCKeywordList] = typedesc[DCKeywordList] 59 | 60 | converter toDCField*(_: type(nil)): DCField {.importcpp: "(nullptr)".} 61 | 62 | type DCPackData* {.importcpp: "DCPackData", pure, inheritable, header: "dcPackData.h".} = object 63 | 64 | type DCPacker* {.importcpp: "DCPacker", pure, inheritable, header: "dcPacker.h".} = object 65 | 66 | type DCParameter* {.importcpp: "DCParameter*", bycopy, pure, inheritable, header: "dcParameter.h".} = object of DCField 67 | 68 | converter toDCParameter*(_: type(nil)): DCParameter {.importcpp: "(nullptr)".} 69 | 70 | type DCArrayParameter* {.importcpp: "DCArrayParameter*", bycopy, pure, inheritable, header: "dcArrayParameter.h".} = object of DCParameter 71 | 72 | converter toDCArrayParameter*(_: type(nil)): DCArrayParameter {.importcpp: "(nullptr)".} 73 | 74 | type DCAtomicField* {.importcpp: "DCAtomicField*", bycopy, pure, inheritable, header: "dcAtomicField.h".} = object of DCField 75 | 76 | converter toDCAtomicField*(_: type(nil)): DCAtomicField {.importcpp: "(nullptr)".} 77 | 78 | type DCDeclaration* {.importcpp: "DCDeclaration*", bycopy, pure, inheritable, header: "dcDeclaration.h".} = object 79 | 80 | converter toDCDeclaration*(_: type(nil)): DCDeclaration {.importcpp: "(nullptr)".} 81 | 82 | type DCClass* {.importcpp: "DCClass*", bycopy, pure, inheritable, header: "dcClass.h".} = object of DCDeclaration 83 | 84 | converter toDCClass*(_: type(nil)): DCClass {.importcpp: "(nullptr)".} 85 | 86 | type DCClassParameter* {.importcpp: "DCClassParameter", pure, inheritable, header: "dcClassParameter.h".} = object of DCParameter 87 | 88 | type DCFile* {.importcpp: "DCFile", pure, inheritable, header: "dcFile.h".} = object 89 | 90 | type DCKeyword* {.importcpp: "DCKeyword*", bycopy, pure, inheritable, header: "dcKeyword.h".} = object of DCDeclaration 91 | 92 | converter toDCKeyword*(_: type(nil)): DCKeyword {.importcpp: "(nullptr)".} 93 | 94 | type DCMolecularField* {.importcpp: "DCMolecularField", pure, inheritable, header: "dcMolecularField.h".} = object of DCField 95 | 96 | type DCSimpleParameter* {.importcpp: "DCSimpleParameter", pure, inheritable, header: "dcSimpleParameter.h".} = object of DCParameter 97 | 98 | type DCSwitch* {.importcpp: "DCSwitch*", bycopy, pure, inheritable, header: "dcSwitch.h".} = object of DCDeclaration 99 | 100 | converter toDCSwitch*(_: type(nil)): DCSwitch {.importcpp: "(nullptr)".} 101 | 102 | type DCSwitchParameter* {.importcpp: "DCSwitchParameter", pure, inheritable, header: "dcSwitchParameter.h".} = object of DCParameter 103 | 104 | type DCTypedef* {.importcpp: "DCTypedef*", bycopy, pure, inheritable, header: "dcTypedef.h".} = object of DCDeclaration 105 | 106 | converter toDCTypedef*(_: type(nil)): DCTypedef {.importcpp: "(nullptr)".} 107 | 108 | type SmoothMover* {.importcpp: "SmoothMover", pure, inheritable, header: "smoothMover.h".} = object 109 | 110 | type SmoothMover_SmoothMode {.importcpp: "SmoothMover::SmoothMode", pure, header: "smoothMover.h".} = enum 111 | SM_off = 0 112 | SM_on = 1 113 | 114 | template SmoothMode*(_: typedesc[SmoothMover]): typedesc[SmoothMover_SmoothMode] = typedesc[SmoothMover_SmoothMode] 115 | template SmoothMode*(_: typedesc[SmoothMover], value: untyped): SmoothMover_SmoothMode = SmoothMover_SmoothMode(value) 116 | 117 | template SM_off*(_: typedesc[SmoothMover]): SmoothMover_SmoothMode = SmoothMover_SmoothMode.SM_off 118 | template SM_on*(_: typedesc[SmoothMover]): SmoothMover_SmoothMode = SmoothMover_SmoothMode.SM_on 119 | 120 | type SmoothMover_PredictionMode {.importcpp: "SmoothMover::PredictionMode", pure, header: "smoothMover.h".} = enum 121 | PM_off = 0 122 | PM_on = 1 123 | 124 | template PredictionMode*(_: typedesc[SmoothMover]): typedesc[SmoothMover_PredictionMode] = typedesc[SmoothMover_PredictionMode] 125 | template PredictionMode*(_: typedesc[SmoothMover], value: untyped): SmoothMover_PredictionMode = SmoothMover_PredictionMode(value) 126 | 127 | template PM_off*(_: typedesc[SmoothMover]): SmoothMover_PredictionMode = SmoothMover_PredictionMode.PM_off 128 | template PM_on*(_: typedesc[SmoothMover]): SmoothMover_PredictionMode = SmoothMover_PredictionMode.PM_on 129 | 130 | type CInterval* {.importcpp: "PT(CInterval)", bycopy, pure, inheritable, header: "cInterval.h".} = object of TypedReferenceCount 131 | 132 | converter toCInterval*(_: type(nil)): CInterval {.importcpp: "(nullptr)".} 133 | func dcast*(_: typedesc[CInterval], obj: TypedObject): CInterval {.importcpp: "DCAST(CInterval, @)".} 134 | 135 | type CInterval_EventType {.importcpp: "CInterval::EventType", pure, header: "cInterval.h".} = enum 136 | ET_initialize = 0 137 | ET_instant = 1 138 | ET_step = 2 139 | ET_finalize = 3 140 | ET_reverseInitialize = 4 141 | ET_reverseInstant = 5 142 | ET_reverseFinalize = 6 143 | ET_interrupt = 7 144 | 145 | template EventType*(_: typedesc[CInterval]): typedesc[CInterval_EventType] = typedesc[CInterval_EventType] 146 | template EventType*(_: typedesc[CInterval], value: untyped): CInterval_EventType = CInterval_EventType(value) 147 | 148 | template ET_initialize*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_initialize 149 | template ET_instant*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_instant 150 | template ET_step*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_step 151 | template ET_finalize*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_finalize 152 | template ET_reverseInitialize*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_reverseInitialize 153 | template ET_reverseInstant*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_reverseInstant 154 | template ET_reverseFinalize*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_reverseFinalize 155 | template ET_interrupt*(_: typedesc[CInterval]): CInterval_EventType = CInterval_EventType.ET_interrupt 156 | 157 | type CInterval_State {.importcpp: "CInterval::State", pure, header: "cInterval.h".} = enum 158 | S_initial = 0 159 | S_started = 1 160 | S_paused = 2 161 | S_final = 3 162 | 163 | template State*(_: typedesc[CInterval]): typedesc[CInterval_State] = typedesc[CInterval_State] 164 | template State*(_: typedesc[CInterval], value: untyped): CInterval_State = CInterval_State(value) 165 | 166 | template S_initial*(_: typedesc[CInterval]): CInterval_State = CInterval_State.S_initial 167 | template S_started*(_: typedesc[CInterval]): CInterval_State = CInterval_State.S_started 168 | template S_paused*(_: typedesc[CInterval]): CInterval_State = CInterval_State.S_paused 169 | template S_final*(_: typedesc[CInterval]): CInterval_State = CInterval_State.S_final 170 | 171 | type CIntervalManager* {.importcpp: "CIntervalManager*", bycopy, pure, inheritable, header: "cIntervalManager.h".} = object 172 | 173 | converter toCIntervalManager*(_: type(nil)): CIntervalManager {.importcpp: "(nullptr)".} 174 | 175 | type CConstraintInterval* {.importcpp: "PT(CConstraintInterval)", bycopy, pure, inheritable, header: "cConstraintInterval.h".} = object of CInterval 176 | 177 | converter toCConstraintInterval*(_: type(nil)): CConstraintInterval {.importcpp: "(nullptr)".} 178 | func dcast*(_: typedesc[CConstraintInterval], obj: TypedObject): CConstraintInterval {.importcpp: "DCAST(CConstraintInterval, @)".} 179 | 180 | type CConstrainHprInterval* {.importcpp: "PT(CConstrainHprInterval)", bycopy, pure, inheritable, header: "cConstrainHprInterval.h".} = object of CConstraintInterval 181 | 182 | converter toCConstrainHprInterval*(_: type(nil)): CConstrainHprInterval {.importcpp: "(nullptr)".} 183 | func dcast*(_: typedesc[CConstrainHprInterval], obj: TypedObject): CConstrainHprInterval {.importcpp: "DCAST(CConstrainHprInterval, @)".} 184 | 185 | type CConstrainPosHprInterval* {.importcpp: "PT(CConstrainPosHprInterval)", bycopy, pure, inheritable, header: "cConstrainPosHprInterval.h".} = object of CConstraintInterval 186 | 187 | converter toCConstrainPosHprInterval*(_: type(nil)): CConstrainPosHprInterval {.importcpp: "(nullptr)".} 188 | func dcast*(_: typedesc[CConstrainPosHprInterval], obj: TypedObject): CConstrainPosHprInterval {.importcpp: "DCAST(CConstrainPosHprInterval, @)".} 189 | 190 | type CConstrainPosInterval* {.importcpp: "PT(CConstrainPosInterval)", bycopy, pure, inheritable, header: "cConstrainPosInterval.h".} = object of CConstraintInterval 191 | 192 | converter toCConstrainPosInterval*(_: type(nil)): CConstrainPosInterval {.importcpp: "(nullptr)".} 193 | func dcast*(_: typedesc[CConstrainPosInterval], obj: TypedObject): CConstrainPosInterval {.importcpp: "DCAST(CConstrainPosInterval, @)".} 194 | 195 | type CConstrainTransformInterval* {.importcpp: "PT(CConstrainTransformInterval)", bycopy, pure, inheritable, header: "cConstrainTransformInterval.h".} = object of CConstraintInterval 196 | 197 | converter toCConstrainTransformInterval*(_: type(nil)): CConstrainTransformInterval {.importcpp: "(nullptr)".} 198 | func dcast*(_: typedesc[CConstrainTransformInterval], obj: TypedObject): CConstrainTransformInterval {.importcpp: "DCAST(CConstrainTransformInterval, @)".} 199 | 200 | type CLerpInterval* {.importcpp: "PT(CLerpInterval)", bycopy, pure, inheritable, header: "cLerpInterval.h".} = object of CInterval 201 | 202 | converter toCLerpInterval*(_: type(nil)): CLerpInterval {.importcpp: "(nullptr)".} 203 | func dcast*(_: typedesc[CLerpInterval], obj: TypedObject): CLerpInterval {.importcpp: "DCAST(CLerpInterval, @)".} 204 | 205 | type CLerpInterval_BlendType {.importcpp: "CLerpInterval::BlendType", pure, header: "cLerpInterval.h".} = enum 206 | BT_noBlend = 0 207 | BT_easeIn = 1 208 | BT_easeOut = 2 209 | BT_easeInOut = 3 210 | BT_invalid = 4 211 | 212 | template BlendType*(_: typedesc[CLerpInterval]): typedesc[CLerpInterval_BlendType] = typedesc[CLerpInterval_BlendType] 213 | template BlendType*(_: typedesc[CLerpInterval], value: untyped): CLerpInterval_BlendType = CLerpInterval_BlendType(value) 214 | 215 | template BT_noBlend*(_: typedesc[CLerpInterval]): CLerpInterval_BlendType = CLerpInterval_BlendType.BT_noBlend 216 | template BT_easeIn*(_: typedesc[CLerpInterval]): CLerpInterval_BlendType = CLerpInterval_BlendType.BT_easeIn 217 | template BT_easeOut*(_: typedesc[CLerpInterval]): CLerpInterval_BlendType = CLerpInterval_BlendType.BT_easeOut 218 | template BT_easeInOut*(_: typedesc[CLerpInterval]): CLerpInterval_BlendType = CLerpInterval_BlendType.BT_easeInOut 219 | template BT_invalid*(_: typedesc[CLerpInterval]): CLerpInterval_BlendType = CLerpInterval_BlendType.BT_invalid 220 | 221 | type CLerpAnimEffectInterval* {.importcpp: "PT(CLerpAnimEffectInterval)", bycopy, pure, inheritable, header: "cLerpAnimEffectInterval.h".} = object of CLerpInterval 222 | 223 | converter toCLerpAnimEffectInterval*(_: type(nil)): CLerpAnimEffectInterval {.importcpp: "(nullptr)".} 224 | func dcast*(_: typedesc[CLerpAnimEffectInterval], obj: TypedObject): CLerpAnimEffectInterval {.importcpp: "DCAST(CLerpAnimEffectInterval, @)".} 225 | 226 | type CLerpNodePathInterval* {.importcpp: "PT(CLerpNodePathInterval)", bycopy, pure, inheritable, header: "cLerpNodePathInterval.h".} = object of CLerpInterval 227 | 228 | converter toCLerpNodePathInterval*(_: type(nil)): CLerpNodePathInterval {.importcpp: "(nullptr)".} 229 | func dcast*(_: typedesc[CLerpNodePathInterval], obj: TypedObject): CLerpNodePathInterval {.importcpp: "DCAST(CLerpNodePathInterval, @)".} 230 | 231 | type CMetaInterval* {.importcpp: "PT(CMetaInterval)", bycopy, pure, inheritable, header: "cMetaInterval.h".} = object of CInterval 232 | 233 | converter toCMetaInterval*(_: type(nil)): CMetaInterval {.importcpp: "(nullptr)".} 234 | func dcast*(_: typedesc[CMetaInterval], obj: TypedObject): CMetaInterval {.importcpp: "DCAST(CMetaInterval, @)".} 235 | 236 | type CMetaInterval_RelativeStart {.importcpp: "CMetaInterval::RelativeStart", pure, header: "cMetaInterval.h".} = enum 237 | RS_previousEnd = 0 238 | RS_previousBegin = 1 239 | RS_levelBegin = 2 240 | 241 | template RelativeStart*(_: typedesc[CMetaInterval]): typedesc[CMetaInterval_RelativeStart] = typedesc[CMetaInterval_RelativeStart] 242 | template RelativeStart*(_: typedesc[CMetaInterval], value: untyped): CMetaInterval_RelativeStart = CMetaInterval_RelativeStart(value) 243 | 244 | template RS_previousEnd*(_: typedesc[CMetaInterval]): CMetaInterval_RelativeStart = CMetaInterval_RelativeStart.RS_previousEnd 245 | template RS_previousBegin*(_: typedesc[CMetaInterval]): CMetaInterval_RelativeStart = CMetaInterval_RelativeStart.RS_previousBegin 246 | template RS_levelBegin*(_: typedesc[CMetaInterval]): CMetaInterval_RelativeStart = CMetaInterval_RelativeStart.RS_levelBegin 247 | 248 | type CMetaInterval_DefType {.importcpp: "CMetaInterval::DefType", pure, header: "cMetaInterval.h".} = enum 249 | DT_cInterval = 0 250 | DT_extIndex = 1 251 | DT_pushLevel = 2 252 | DT_popLevel = 3 253 | 254 | template DefType*(_: typedesc[CMetaInterval]): typedesc[CMetaInterval_DefType] = typedesc[CMetaInterval_DefType] 255 | template DefType*(_: typedesc[CMetaInterval], value: untyped): CMetaInterval_DefType = CMetaInterval_DefType(value) 256 | 257 | template DT_cInterval*(_: typedesc[CMetaInterval]): CMetaInterval_DefType = CMetaInterval_DefType.DT_cInterval 258 | template DT_extIndex*(_: typedesc[CMetaInterval]): CMetaInterval_DefType = CMetaInterval_DefType.DT_extIndex 259 | template DT_pushLevel*(_: typedesc[CMetaInterval]): CMetaInterval_DefType = CMetaInterval_DefType.DT_pushLevel 260 | template DT_popLevel*(_: typedesc[CMetaInterval]): CMetaInterval_DefType = CMetaInterval_DefType.DT_popLevel 261 | 262 | type HideInterval* {.importcpp: "PT(HideInterval)", bycopy, pure, inheritable, header: "hideInterval.h".} = object of CInterval 263 | 264 | converter toHideInterval*(_: type(nil)): HideInterval {.importcpp: "(nullptr)".} 265 | func dcast*(_: typedesc[HideInterval], obj: TypedObject): HideInterval {.importcpp: "DCAST(HideInterval, @)".} 266 | 267 | type LerpBlendType* {.importcpp: "PT(LerpBlendType)", bycopy, pure, inheritable, header: "lerpblend.h".} = object of TypedReferenceCount 268 | 269 | converter toLerpBlendType*(_: type(nil)): LerpBlendType {.importcpp: "(nullptr)".} 270 | func dcast*(_: typedesc[LerpBlendType], obj: TypedObject): LerpBlendType {.importcpp: "DCAST(LerpBlendType, @)".} 271 | 272 | type EaseInBlendType* {.importcpp: "PT(EaseInBlendType)", bycopy, pure, inheritable, header: "lerpblend.h".} = object of LerpBlendType 273 | 274 | converter toEaseInBlendType*(_: type(nil)): EaseInBlendType {.importcpp: "(nullptr)".} 275 | func dcast*(_: typedesc[EaseInBlendType], obj: TypedObject): EaseInBlendType {.importcpp: "DCAST(EaseInBlendType, @)".} 276 | 277 | type EaseOutBlendType* {.importcpp: "PT(EaseOutBlendType)", bycopy, pure, inheritable, header: "lerpblend.h".} = object of LerpBlendType 278 | 279 | converter toEaseOutBlendType*(_: type(nil)): EaseOutBlendType {.importcpp: "(nullptr)".} 280 | func dcast*(_: typedesc[EaseOutBlendType], obj: TypedObject): EaseOutBlendType {.importcpp: "DCAST(EaseOutBlendType, @)".} 281 | 282 | type EaseInOutBlendType* {.importcpp: "PT(EaseInOutBlendType)", bycopy, pure, inheritable, header: "lerpblend.h".} = object of LerpBlendType 283 | 284 | converter toEaseInOutBlendType*(_: type(nil)): EaseInOutBlendType {.importcpp: "(nullptr)".} 285 | func dcast*(_: typedesc[EaseInOutBlendType], obj: TypedObject): EaseInOutBlendType {.importcpp: "DCAST(EaseInOutBlendType, @)".} 286 | 287 | type NoBlendType* {.importcpp: "PT(NoBlendType)", bycopy, pure, inheritable, header: "lerpblend.h".} = object of LerpBlendType 288 | 289 | converter toNoBlendType*(_: type(nil)): NoBlendType {.importcpp: "(nullptr)".} 290 | func dcast*(_: typedesc[NoBlendType], obj: TypedObject): NoBlendType {.importcpp: "DCAST(NoBlendType, @)".} 291 | 292 | type ShowInterval* {.importcpp: "PT(ShowInterval)", bycopy, pure, inheritable, header: "showInterval.h".} = object of CInterval 293 | 294 | converter toShowInterval*(_: type(nil)): ShowInterval {.importcpp: "(nullptr)".} 295 | func dcast*(_: typedesc[ShowInterval], obj: TypedObject): ShowInterval {.importcpp: "DCAST(ShowInterval, @)".} 296 | 297 | type WaitInterval* {.importcpp: "PT(WaitInterval)", bycopy, pure, inheritable, header: "waitInterval.h".} = object of CInterval 298 | 299 | converter toWaitInterval*(_: type(nil)): WaitInterval {.importcpp: "(nullptr)".} 300 | func dcast*(_: typedesc[WaitInterval], obj: TypedObject): WaitInterval {.importcpp: "DCAST(WaitInterval, @)".} 301 | 302 | type CConnectionRepository* {.importcpp: "CConnectionRepository", pure, inheritable, header: "cConnectionRepository.h".} = object 303 | 304 | type CDistributedSmoothNodeBase* {.importcpp: "CDistributedSmoothNodeBase", pure, inheritable, header: "cDistributedSmoothNodeBase.h".} = object 305 | 306 | type CMotionTrail* {.importcpp: "PT(CMotionTrail)", bycopy, pure, inheritable, header: "cMotionTrail.h".} = object of TypedReferenceCount 307 | 308 | converter toCMotionTrail*(_: type(nil)): CMotionTrail {.importcpp: "(nullptr)".} 309 | func dcast*(_: typedesc[CMotionTrail], obj: TypedObject): CMotionTrail {.importcpp: "DCAST(CMotionTrail, @)".} 310 | 311 | proc initDCPackData*(): DCPackData {.importcpp: "DCPackData()".} 312 | 313 | proc initDCPackData*(param0: DCPackData): DCPackData {.importcpp: "DCPackData(#)".} 314 | 315 | proc initDCPacker*(): DCPacker {.importcpp: "DCPacker()".} 316 | 317 | proc initDCPacker*(param0: DCPacker): DCPacker {.importcpp: "DCPacker(#)".} 318 | 319 | proc getNumStackElementsEverAllocated*(_: typedesc[DCPacker]): int {.importcpp: "DCPacker::get_num_stack_elements_ever_allocated()", header: "dcPacker.h".} 320 | 321 | proc initDCFile*(): DCFile {.importcpp: "DCFile()".} 322 | 323 | proc initDCFile*(param0: DCFile): DCFile {.importcpp: "DCFile(#)".} 324 | 325 | proc getParticlePath*(): ConfigVariableSearchPath {.importcpp: "get_particle_path()", header: "showBase.h".} 326 | 327 | proc throwNewFrame*() {.importcpp: "throw_new_frame()", header: "showBase.h".} 328 | 329 | proc initAppForGui*() {.importcpp: "init_app_for_gui()", header: "showBase.h".} 330 | 331 | proc addFullscreenTestsize*(xsize: int, ysize: int) {.importcpp: "add_fullscreen_testsize(#, #)", header: "showBase.h".} 332 | 333 | proc runtestFullscreenSizes*(win: GraphicsWindow) {.importcpp: "runtest_fullscreen_sizes(#)", header: "showBase.h".} 334 | 335 | proc queryFullscreenTestresult*(xsize: int, ysize: int): bool {.importcpp: "query_fullscreen_testresult(#, #)", header: "showBase.h".} 336 | 337 | proc storeAccessibilityShortcutKeys*() {.importcpp: "store_accessibility_shortcut_keys()", header: "showBase.h".} 338 | 339 | proc allowAccessibilityShortcutKeys*(allowKeys: bool) {.importcpp: "allow_accessibility_shortcut_keys(#)", header: "showBase.h".} 340 | 341 | proc initSmoothMover*(): SmoothMover {.importcpp: "SmoothMover()".} 342 | 343 | proc initSmoothMover*(param0: SmoothMover): SmoothMover {.importcpp: "SmoothMover(#)".} 344 | 345 | proc newCIntervalManager*(): CIntervalManager {.importcpp: "new CIntervalManager()".} 346 | 347 | proc getGlobalPtr*(_: typedesc[CIntervalManager]): CIntervalManager {.importcpp: "CIntervalManager::get_global_ptr()", header: "cIntervalManager.h".} 348 | 349 | converter getClassType*(_: typedesc[CInterval]): TypeHandle {.importcpp: "CInterval::get_class_type()", header: "cInterval.h".} 350 | 351 | proc newCInterval*(param0: CInterval): CInterval {.importcpp: "new CInterval(#)".} 352 | 353 | converter getClassType*(_: typedesc[CConstraintInterval]): TypeHandle {.importcpp: "CConstraintInterval::get_class_type()", header: "cConstraintInterval.h".} 354 | 355 | proc newCConstraintInterval*(param0: CConstraintInterval): CConstraintInterval {.importcpp: "new CConstraintInterval(#)".} 356 | 357 | proc newCConstrainHprInterval*(param0: CConstrainHprInterval): CConstrainHprInterval {.importcpp: "new CConstrainHprInterval(#)".} 358 | 359 | proc newCConstrainHprInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool, hprOffset: LVecBase3): CConstrainHprInterval {.importcpp: "new CConstrainHprInterval(nimStringToStdString(#), #, #, #, #, (LVecBase3 const &)(#))", header: stringConversionCode.} 360 | 361 | proc newCConstrainHprInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool): CConstrainHprInterval {.importcpp: "new CConstrainHprInterval(nimStringToStdString(#), #, #, #, #)", header: stringConversionCode.} 362 | 363 | converter getClassType*(_: typedesc[CConstrainHprInterval]): TypeHandle {.importcpp: "CConstrainHprInterval::get_class_type()", header: "cConstrainHprInterval.h".} 364 | 365 | proc newCConstrainPosHprInterval*(param0: CConstrainPosHprInterval): CConstrainPosHprInterval {.importcpp: "new CConstrainPosHprInterval(#)".} 366 | 367 | proc newCConstrainPosHprInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool, posOffset: LVecBase3, hprOffset: LVecBase3): CConstrainPosHprInterval {.importcpp: "new CConstrainPosHprInterval(nimStringToStdString(#), #, #, #, #, (LVecBase3 const &)(#), (LVecBase3 const &)(#))", header: stringConversionCode.} 368 | 369 | proc newCConstrainPosHprInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool, posOffset: LVecBase3): CConstrainPosHprInterval {.importcpp: "new CConstrainPosHprInterval(nimStringToStdString(#), #, #, #, #, (LVecBase3 const &)(#))", header: stringConversionCode.} 370 | 371 | proc newCConstrainPosHprInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool): CConstrainPosHprInterval {.importcpp: "new CConstrainPosHprInterval(nimStringToStdString(#), #, #, #, #)", header: stringConversionCode.} 372 | 373 | converter getClassType*(_: typedesc[CConstrainPosHprInterval]): TypeHandle {.importcpp: "CConstrainPosHprInterval::get_class_type()", header: "cConstrainPosHprInterval.h".} 374 | 375 | proc newCConstrainPosInterval*(param0: CConstrainPosInterval): CConstrainPosInterval {.importcpp: "new CConstrainPosInterval(#)".} 376 | 377 | proc newCConstrainPosInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool, posOffset: LVecBase3): CConstrainPosInterval {.importcpp: "new CConstrainPosInterval(nimStringToStdString(#), #, #, #, #, (LVecBase3 const &)(#))", header: stringConversionCode.} 378 | 379 | proc newCConstrainPosInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool): CConstrainPosInterval {.importcpp: "new CConstrainPosInterval(nimStringToStdString(#), #, #, #, #)", header: stringConversionCode.} 380 | 381 | converter getClassType*(_: typedesc[CConstrainPosInterval]): TypeHandle {.importcpp: "CConstrainPosInterval::get_class_type()", header: "cConstrainPosInterval.h".} 382 | 383 | proc newCConstrainTransformInterval*(param0: CConstrainTransformInterval): CConstrainTransformInterval {.importcpp: "new CConstrainTransformInterval(#)".} 384 | 385 | proc newCConstrainTransformInterval*(name: string, duration: float64, node: NodePath, target: NodePath, wrt: bool): CConstrainTransformInterval {.importcpp: "new CConstrainTransformInterval(nimStringToStdString(#), #, #, #, #)", header: stringConversionCode.} 386 | 387 | converter getClassType*(_: typedesc[CConstrainTransformInterval]): TypeHandle {.importcpp: "CConstrainTransformInterval::get_class_type()", header: "cConstrainTransformInterval.h".} 388 | 389 | proc stringBlendType*(_: typedesc[CLerpInterval], blendType: string): CLerpInterval_BlendType {.importcpp: "#CLerpInterval::string_blend_type(nimStringToStdString(#))", header: "cLerpInterval.h".} 390 | 391 | converter getClassType*(_: typedesc[CLerpInterval]): TypeHandle {.importcpp: "CLerpInterval::get_class_type()", header: "cLerpInterval.h".} 392 | 393 | proc newCLerpInterval*(param0: CLerpInterval): CLerpInterval {.importcpp: "new CLerpInterval(#)".} 394 | 395 | proc newCLerpAnimEffectInterval*(param0: CLerpAnimEffectInterval): CLerpAnimEffectInterval {.importcpp: "new CLerpAnimEffectInterval(#)".} 396 | 397 | proc newCLerpAnimEffectInterval*(name: string, duration: float64, blendType: CLerpInterval_BlendType): CLerpAnimEffectInterval {.importcpp: "new CLerpAnimEffectInterval(nimStringToStdString(#), #, #)", header: stringConversionCode.} 398 | 399 | converter getClassType*(_: typedesc[CLerpAnimEffectInterval]): TypeHandle {.importcpp: "CLerpAnimEffectInterval::get_class_type()", header: "cLerpAnimEffectInterval.h".} 400 | 401 | proc newCLerpNodePathInterval*(param0: CLerpNodePathInterval): CLerpNodePathInterval {.importcpp: "new CLerpNodePathInterval(#)".} 402 | 403 | proc newCLerpNodePathInterval*(name: string, duration: float64, blendType: CLerpInterval_BlendType, bakeInStart: bool, fluid: bool, node: NodePath, other: NodePath): CLerpNodePathInterval {.importcpp: "new CLerpNodePathInterval(nimStringToStdString(#), #, #, #, #, #, #)", header: stringConversionCode.} 404 | 405 | converter getClassType*(_: typedesc[CLerpNodePathInterval]): TypeHandle {.importcpp: "CLerpNodePathInterval::get_class_type()", header: "cLerpNodePathInterval.h".} 406 | 407 | proc newCMetaInterval*(param0: CMetaInterval): CMetaInterval {.importcpp: "new CMetaInterval(#)".} 408 | 409 | proc newCMetaInterval*(name: string): CMetaInterval {.importcpp: "new CMetaInterval(nimStringToStdString(#))", header: stringConversionCode.} 410 | 411 | converter getClassType*(_: typedesc[CMetaInterval]): TypeHandle {.importcpp: "CMetaInterval::get_class_type()", header: "cMetaInterval.h".} 412 | 413 | proc newHideInterval*(param0: HideInterval): HideInterval {.importcpp: "new HideInterval(#)".} 414 | 415 | proc newHideInterval*(node: NodePath, name: string): HideInterval {.importcpp: "new HideInterval(#, nimStringToStdString(#))", header: stringConversionCode.} 416 | 417 | proc newHideInterval*(node: NodePath): HideInterval {.importcpp: "new HideInterval(#)".} 418 | 419 | converter getClassType*(_: typedesc[HideInterval]): TypeHandle {.importcpp: "HideInterval::get_class_type()", header: "hideInterval.h".} 420 | 421 | converter getClassType*(_: typedesc[LerpBlendType]): TypeHandle {.importcpp: "LerpBlendType::get_class_type()", header: "lerpblend.h".} 422 | 423 | proc newEaseInBlendType*(): EaseInBlendType {.importcpp: "new EaseInBlendType()".} 424 | 425 | converter getClassType*(_: typedesc[EaseInBlendType]): TypeHandle {.importcpp: "EaseInBlendType::get_class_type()", header: "lerpblend.h".} 426 | 427 | proc newEaseOutBlendType*(): EaseOutBlendType {.importcpp: "new EaseOutBlendType()".} 428 | 429 | converter getClassType*(_: typedesc[EaseOutBlendType]): TypeHandle {.importcpp: "EaseOutBlendType::get_class_type()", header: "lerpblend.h".} 430 | 431 | proc newEaseInOutBlendType*(): EaseInOutBlendType {.importcpp: "new EaseInOutBlendType()".} 432 | 433 | converter getClassType*(_: typedesc[EaseInOutBlendType]): TypeHandle {.importcpp: "EaseInOutBlendType::get_class_type()", header: "lerpblend.h".} 434 | 435 | proc newNoBlendType*(): NoBlendType {.importcpp: "new NoBlendType()".} 436 | 437 | converter getClassType*(_: typedesc[NoBlendType]): TypeHandle {.importcpp: "NoBlendType::get_class_type()", header: "lerpblend.h".} 438 | 439 | proc newShowInterval*(node: NodePath, name: string): ShowInterval {.importcpp: "new ShowInterval(#, nimStringToStdString(#))", header: stringConversionCode.} 440 | 441 | proc newShowInterval*(node: NodePath): ShowInterval {.importcpp: "new ShowInterval(#)".} 442 | 443 | proc newShowInterval*(param0: ShowInterval): ShowInterval {.importcpp: "new ShowInterval(#)".} 444 | 445 | converter getClassType*(_: typedesc[ShowInterval]): TypeHandle {.importcpp: "ShowInterval::get_class_type()", header: "showInterval.h".} 446 | 447 | proc newWaitInterval*(param0: WaitInterval): WaitInterval {.importcpp: "new WaitInterval(#)".} 448 | 449 | proc newWaitInterval*(duration: float64): WaitInterval {.importcpp: "new WaitInterval(#)".} 450 | 451 | converter getClassType*(_: typedesc[WaitInterval]): TypeHandle {.importcpp: "WaitInterval::get_class_type()", header: "waitInterval.h".} 452 | 453 | proc initCConnectionRepository*(hasOwnerView: bool, threadedNet: bool): CConnectionRepository {.importcpp: "CConnectionRepository(#, #)".} 454 | 455 | proc initCConnectionRepository*(hasOwnerView: bool): CConnectionRepository {.importcpp: "CConnectionRepository(#)".} 456 | 457 | proc initCConnectionRepository*(): CConnectionRepository {.importcpp: "CConnectionRepository()".} 458 | 459 | proc getOverflowEventName*(_: typedesc[CConnectionRepository]): string {.importcpp: "nimStringFromStdString(CConnectionRepository::get_overflow_event_name())", header: "cConnectionRepository.h".} 460 | 461 | proc initCDistributedSmoothNodeBase*(): CDistributedSmoothNodeBase {.importcpp: "CDistributedSmoothNodeBase()".} 462 | 463 | proc initCDistributedSmoothNodeBase*(param0: CDistributedSmoothNodeBase): CDistributedSmoothNodeBase {.importcpp: "CDistributedSmoothNodeBase(#)".} 464 | 465 | proc newCMotionTrail*(): CMotionTrail {.importcpp: "new CMotionTrail()".} 466 | 467 | proc newCMotionTrail*(param0: CMotionTrail): CMotionTrail {.importcpp: "new CMotionTrail(#)".} 468 | 469 | converter getClassType*(_: typedesc[CMotionTrail]): TypeHandle {.importcpp: "CMotionTrail::get_class_type()", header: "cMotionTrail.h".} 470 | 471 | func name*(this: CInterval): string {.importcpp: "nimStringFromStdString(#->get_name())", header: stringConversionCode.} 472 | 473 | func duration*(this: CInterval): float64 {.importcpp: "#->get_duration()".} 474 | 475 | func openEnded*(this: CInterval): bool {.importcpp: "#->get_open_ended()".} 476 | 477 | func state*(this: CInterval): CInterval_State {.importcpp: "#->get_state()".} 478 | 479 | func stopped*(this: CInterval): bool {.importcpp: "#->is_stopped()".} 480 | 481 | func doneEvent*(this: CInterval): string {.importcpp: "nimStringFromStdString(#->get_done_event())", header: stringConversionCode.} 482 | 483 | proc `doneEvent=`*(this: CInterval, event: string) {.importcpp: "#->set_done_event(nimStringToStdString(#))", header: stringConversionCode.} 484 | 485 | func t*(this: CInterval): float64 {.importcpp: "#->get_t()".} 486 | 487 | proc `t=`*(this: CInterval, t: float64) {.importcpp: "#->set_t(#)".} 488 | 489 | func autoPause*(this: CInterval): bool {.importcpp: "#->get_auto_pause()".} 490 | 491 | proc `autoPause=`*(this: CInterval, autoPause: bool) {.importcpp: "#->set_auto_pause(#)".} 492 | 493 | func autoFinish*(this: CInterval): bool {.importcpp: "#->get_auto_finish()".} 494 | 495 | proc `autoFinish=`*(this: CInterval, autoFinish: bool) {.importcpp: "#->set_auto_finish(#)".} 496 | 497 | func manager*(this: CInterval): CIntervalManager {.importcpp: "#->get_manager()".} 498 | 499 | proc `manager=`*(this: CInterval, manager: CIntervalManager) {.importcpp: "#->set_manager(#)".} 500 | 501 | func playRate*(this: CInterval): float64 {.importcpp: "#->get_play_rate()".} 502 | 503 | proc `playRate=`*(this: CInterval, playRate: float64) {.importcpp: "#->set_play_rate(#)".} 504 | 505 | func playing*(this: CInterval): bool {.importcpp: "#->is_playing()".} 506 | 507 | proc getName*(this: CInterval | DCClass | DCKeyword | DCPackerInterface | DCSwitch | DCTypedef): string {.importcpp: "nimStringFromStdString(#->get_name())", header: stringConversionCode.} 508 | 509 | proc findSeekIndex*(this: DCPackerInterface, name: string): int {.importcpp: "#->find_seek_index(nimStringToStdString(#))", header: stringConversionCode.} 510 | 511 | proc asField*(this: DCField | DCPackerInterface): DCField {.importcpp: "#->as_field()".} 512 | 513 | proc asSwitchParameter*(this: DCPackerInterface): DCSwitchParameter {.importcpp: "#->as_switch_parameter()".} 514 | 515 | proc asClassParameter*(this: DCPackerInterface): DCClassParameter {.importcpp: "#->as_class_parameter()".} 516 | 517 | proc checkMatch*(this: DCPackerInterface, other: DCPackerInterface): bool {.importcpp: "#->check_match(#)".} 518 | 519 | proc checkMatch*(this: DCPackerInterface, description: string, dcfile: DCFile): bool {.importcpp: "#->check_match(nimStringToStdString(#), #)", header: stringConversionCode.} 520 | 521 | proc checkMatch*(this: DCPackerInterface, description: string): bool {.importcpp: "#->check_match(nimStringToStdString(#))", header: stringConversionCode.} 522 | 523 | proc hasKeyword*(this: DCKeywordList, keyword: DCKeyword): bool {.importcpp: "#.has_keyword(#)".} 524 | 525 | proc hasKeyword*(this: DCKeywordList, name: string): bool {.importcpp: "#.has_keyword(nimStringToStdString(#))", header: stringConversionCode.} 526 | 527 | proc getNumKeywords*(this: DCFile | DCKeywordList): int {.importcpp: "#.get_num_keywords()".} 528 | 529 | proc getKeyword*(this: DCFile | DCKeywordList, n: int): DCKeyword {.importcpp: "#.get_keyword(#)".} 530 | 531 | proc getKeywordByName*(this: DCFile | DCKeywordList, name: string): DCKeyword {.importcpp: "#.get_keyword_by_name(nimStringToStdString(#))", header: stringConversionCode.} 532 | 533 | proc compareKeywords*(this: DCKeywordList, other: DCKeywordList): bool {.importcpp: "#.compare_keywords(#)".} 534 | 535 | converter upcastToDCPackerInterface*(this: DCField): DCPackerInterface {.importcpp: "((DCPackerInterface *)(#))".} 536 | 537 | converter upcastToDCKeywordList*(this: DCField): DCKeywordList {.importcpp: "((DCKeywordList *)(#))".} 538 | 539 | proc getNumber*(this: DCClass | DCField | DCTypedef): int {.importcpp: "#->get_number()".} 540 | 541 | proc getClass*(this: DCField): DCClass {.importcpp: "#->get_class()".} 542 | 543 | proc asAtomicField*(this: DCField): DCAtomicField {.importcpp: "#->as_atomic_field()".} 544 | 545 | proc asMolecularField*(this: DCField): DCMolecularField {.importcpp: "#->as_molecular_field()".} 546 | 547 | proc asParameter*(this: DCField): DCParameter {.importcpp: "#->as_parameter()".} 548 | 549 | proc hasDefaultValue*(this: DCField): bool {.importcpp: "#->has_default_value()".} 550 | 551 | proc isBogusField*(this: DCField): bool {.importcpp: "#->is_bogus_field()".} 552 | 553 | proc isRequired*(this: DCField): bool {.importcpp: "#->is_required()".} 554 | 555 | proc isBroadcast*(this: DCField): bool {.importcpp: "#->is_broadcast()".} 556 | 557 | proc isRam*(this: DCField): bool {.importcpp: "#->is_ram()".} 558 | 559 | proc isDb*(this: DCField): bool {.importcpp: "#->is_db()".} 560 | 561 | proc isClsend*(this: DCField): bool {.importcpp: "#->is_clsend()".} 562 | 563 | proc isClrecv*(this: DCField): bool {.importcpp: "#->is_clrecv()".} 564 | 565 | proc isOwnsend*(this: DCField): bool {.importcpp: "#->is_ownsend()".} 566 | 567 | proc isOwnrecv*(this: DCField): bool {.importcpp: "#->is_ownrecv()".} 568 | 569 | proc isAirecv*(this: DCField): bool {.importcpp: "#->is_airecv()".} 570 | 571 | proc output*(this: CInterval | CIntervalManager | DCClass | DCDeclaration | DCField, `out`: ostream) {.importcpp: "#->output(#)".} 572 | 573 | proc write*(this: CInterval | DCDeclaration | DCField, `out`: ostream, indentLevel: int) {.importcpp: "#->write(#, #)".} 574 | 575 | proc clear*(this: DCFile | DCPackData) {.importcpp: "#.clear()".} 576 | 577 | proc getString*(this: DCPackData | DCPacker): string {.importcpp: "nimStringFromStdString(#.get_string())", header: stringConversionCode.} 578 | 579 | proc getLength*(this: DCPackData | DCPacker): int {.importcpp: "#.get_length()".} 580 | 581 | proc clearData*(this: DCPacker) {.importcpp: "#.clear_data()".} 582 | 583 | proc beginPack*(this: DCPacker, root: DCPackerInterface) {.importcpp: "#.begin_pack(#)".} 584 | 585 | proc endPack*(this: DCPacker): bool {.importcpp: "#.end_pack()".} 586 | 587 | proc beginUnpack*(this: DCPacker, root: DCPackerInterface) {.importcpp: "#.begin_unpack(#)".} 588 | 589 | proc endUnpack*(this: DCPacker): bool {.importcpp: "#.end_unpack()".} 590 | 591 | proc beginRepack*(this: DCPacker, root: DCPackerInterface) {.importcpp: "#.begin_repack(#)".} 592 | 593 | proc endRepack*(this: DCPacker): bool {.importcpp: "#.end_repack()".} 594 | 595 | proc seek*(this: DCPacker, seekIndex: int): bool {.importcpp: "#.seek(#)".} 596 | 597 | proc seek*(this: DCPacker, fieldName: string): bool {.importcpp: "#.seek(nimStringToStdString(#))", header: stringConversionCode.} 598 | 599 | proc hasNestedFields*(this: DCPacker): bool {.importcpp: "#.has_nested_fields()".} 600 | 601 | proc getNumNestedFields*(this: DCPacker): int {.importcpp: "#.get_num_nested_fields()".} 602 | 603 | proc moreNestedFields*(this: DCPacker): bool {.importcpp: "#.more_nested_fields()".} 604 | 605 | proc getCurrentParent*(this: DCPacker): DCPackerInterface {.importcpp: "#.get_current_parent()".} 606 | 607 | proc getCurrentField*(this: DCPacker): DCPackerInterface {.importcpp: "#.get_current_field()".} 608 | 609 | proc getLastSwitch*(this: DCPacker): DCSwitchParameter {.importcpp: "#.get_last_switch()".} 610 | 611 | proc getPackType*(this: DCPacker): DCPackType {.importcpp: "#.get_pack_type()".} 612 | 613 | proc getCurrentFieldName*(this: DCPacker): string {.importcpp: "nimStringFromStdString(#.get_current_field_name())", header: stringConversionCode.} 614 | 615 | proc push*(this: DCPacker) {.importcpp: "#.push()".} 616 | 617 | proc pop*(this: DCPacker) {.importcpp: "#.pop()".} 618 | 619 | proc packDouble*(this: DCPacker, value: float64) {.importcpp: "#.pack_double(#)".} 620 | 621 | proc packInt*(this: DCPacker, value: int) {.importcpp: "#.pack_int(#)".} 622 | 623 | proc packUint*(this: DCPacker, value: int) {.importcpp: "#.pack_uint(#)".} 624 | 625 | proc packInt64*(this: DCPacker, value: clonglong) {.importcpp: "#.pack_int64(#)".} 626 | 627 | proc packUint64*(this: DCPacker, value: clonglong) {.importcpp: "#.pack_uint64(#)".} 628 | 629 | proc packString*(this: DCPacker, value: string) {.importcpp: "#.pack_string(nimStringToStdString(#))", header: stringConversionCode.} 630 | 631 | proc packDefaultValue*(this: DCPacker) {.importcpp: "#.pack_default_value()".} 632 | 633 | proc unpackDouble*(this: DCPacker): float64 {.importcpp: "#.unpack_double()".} 634 | 635 | proc unpackInt*(this: DCPacker): int {.importcpp: "#.unpack_int()".} 636 | 637 | proc unpackUint*(this: DCPacker): int {.importcpp: "#.unpack_uint()".} 638 | 639 | proc unpackInt64*(this: DCPacker): clonglong {.importcpp: "#.unpack_int64()".} 640 | 641 | proc unpackUint64*(this: DCPacker): clonglong {.importcpp: "#.unpack_uint64()".} 642 | 643 | proc unpackString*(this: DCPacker): string {.importcpp: "nimStringFromStdString(#.unpack_string())", header: stringConversionCode.} 644 | 645 | proc unpackValidate*(this: DCPacker) {.importcpp: "#.unpack_validate()".} 646 | 647 | proc unpackSkip*(this: DCPacker) {.importcpp: "#.unpack_skip()".} 648 | 649 | proc parseAndPack*(this: DCPacker, `in`: istream): bool {.importcpp: "#.parse_and_pack(#)".} 650 | 651 | proc parseAndPack*(this: DCPacker, formattedObject: string): bool {.importcpp: "#.parse_and_pack(nimStringToStdString(#))", header: stringConversionCode.} 652 | 653 | proc unpackAndFormat*(this: DCPacker, showFieldNames: bool): string {.importcpp: "nimStringFromStdString(#.unpack_and_format(#))", header: stringConversionCode.} 654 | 655 | proc unpackAndFormat*(this: DCPacker): string {.importcpp: "nimStringFromStdString(#.unpack_and_format())", header: stringConversionCode.} 656 | 657 | proc unpackAndFormat*(this: DCPacker, `out`: ostream, showFieldNames: bool) {.importcpp: "#.unpack_and_format(#, #)".} 658 | 659 | proc unpackAndFormat*(this: DCPacker, `out`: ostream) {.importcpp: "#.unpack_and_format(#)".} 660 | 661 | proc hadParseError*(this: DCPacker): bool {.importcpp: "#.had_parse_error()".} 662 | 663 | proc hadPackError*(this: DCPacker): bool {.importcpp: "#.had_pack_error()".} 664 | 665 | proc hadRangeError*(this: DCPacker): bool {.importcpp: "#.had_range_error()".} 666 | 667 | proc hadError*(this: DCPacker): bool {.importcpp: "#.had_error()".} 668 | 669 | proc getNumUnpackedBytes*(this: DCPacker): int {.importcpp: "#.get_num_unpacked_bytes()".} 670 | 671 | proc getUnpackLength*(this: DCPacker): int {.importcpp: "#.get_unpack_length()".} 672 | 673 | proc getUnpackString*(this: DCPacker): string {.importcpp: "nimStringFromStdString(#.get_unpack_string())", header: stringConversionCode.} 674 | 675 | proc rawPackInt8*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_int8(#)".} 676 | 677 | proc rawPackInt16*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_int16(#)".} 678 | 679 | proc rawPackInt32*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_int32(#)".} 680 | 681 | proc rawPackInt64*(this: DCPacker, value: clonglong) {.importcpp: "#.raw_pack_int64(#)".} 682 | 683 | proc rawPackUint8*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_uint8(#)".} 684 | 685 | proc rawPackUint16*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_uint16(#)".} 686 | 687 | proc rawPackUint32*(this: DCPacker, value: int) {.importcpp: "#.raw_pack_uint32(#)".} 688 | 689 | proc rawPackUint64*(this: DCPacker, value: clonglong) {.importcpp: "#.raw_pack_uint64(#)".} 690 | 691 | proc rawPackFloat64*(this: DCPacker, value: float64) {.importcpp: "#.raw_pack_float64(#)".} 692 | 693 | proc rawPackString*(this: DCPacker, value: string) {.importcpp: "#.raw_pack_string(nimStringToStdString(#))", header: stringConversionCode.} 694 | 695 | proc rawUnpackInt8*(this: DCPacker): int {.importcpp: "#.raw_unpack_int8()".} 696 | 697 | proc rawUnpackInt16*(this: DCPacker): int {.importcpp: "#.raw_unpack_int16()".} 698 | 699 | proc rawUnpackInt32*(this: DCPacker): int {.importcpp: "#.raw_unpack_int32()".} 700 | 701 | proc rawUnpackInt64*(this: DCPacker): clonglong {.importcpp: "#.raw_unpack_int64()".} 702 | 703 | proc rawUnpackUint8*(this: DCPacker): int {.importcpp: "#.raw_unpack_uint8()".} 704 | 705 | proc rawUnpackUint16*(this: DCPacker): int {.importcpp: "#.raw_unpack_uint16()".} 706 | 707 | proc rawUnpackUint32*(this: DCPacker): int {.importcpp: "#.raw_unpack_uint32()".} 708 | 709 | proc rawUnpackUint64*(this: DCPacker): clonglong {.importcpp: "#.raw_unpack_uint64()".} 710 | 711 | proc rawUnpackFloat64*(this: DCPacker): float64 {.importcpp: "#.raw_unpack_float64()".} 712 | 713 | proc rawUnpackString*(this: DCPacker): string {.importcpp: "nimStringFromStdString(#.raw_unpack_string())", header: stringConversionCode.} 714 | 715 | proc asSimpleParameter*(this: DCParameter): DCSimpleParameter {.importcpp: "#->as_simple_parameter()".} 716 | 717 | proc asArrayParameter*(this: DCParameter): DCArrayParameter {.importcpp: "#->as_array_parameter()".} 718 | 719 | proc makeCopy*(this: DCParameter): DCParameter {.importcpp: "#->make_copy()".} 720 | 721 | proc isValid*(this: DCParameter): bool {.importcpp: "#->is_valid()".} 722 | 723 | proc getTypedef*(this: DCParameter): DCTypedef {.importcpp: "#->get_typedef()".} 724 | 725 | proc getElementType*(this: DCArrayParameter): DCParameter {.importcpp: "#->get_element_type()".} 726 | 727 | proc getArraySize*(this: DCArrayParameter): int {.importcpp: "#->get_array_size()".} 728 | 729 | proc getNumElements*(this: DCAtomicField): int {.importcpp: "#->get_num_elements()".} 730 | 731 | proc getElement*(this: DCAtomicField, n: int): DCParameter {.importcpp: "#->get_element(#)".} 732 | 733 | proc hasElementDefault*(this: DCAtomicField, n: int): bool {.importcpp: "#->has_element_default(#)".} 734 | 735 | proc getElementName*(this: DCAtomicField, n: int): string {.importcpp: "nimStringFromStdString(#->get_element_name(#))", header: stringConversionCode.} 736 | 737 | proc getElementType*(this: DCAtomicField, n: int): DCSubatomicType {.importcpp: "#->get_element_type(#)".} 738 | 739 | proc getElementDivisor*(this: DCAtomicField, n: int): int {.importcpp: "#->get_element_divisor(#)".} 740 | 741 | proc asClass*(this: DCDeclaration): DCClass {.importcpp: "#->as_class()".} 742 | 743 | proc asSwitch*(this: DCDeclaration): DCSwitch {.importcpp: "#->as_switch()".} 744 | 745 | proc getDcFile*(this: DCClass): DCFile {.importcpp: "#->get_dc_file()".} 746 | 747 | proc getNumParents*(this: DCClass): int {.importcpp: "#->get_num_parents()".} 748 | 749 | proc getParent*(this: DCClass, n: int): DCClass {.importcpp: "#->get_parent(#)".} 750 | 751 | proc hasConstructor*(this: DCClass): bool {.importcpp: "#->has_constructor()".} 752 | 753 | proc getConstructor*(this: DCClass): DCField {.importcpp: "#->get_constructor()".} 754 | 755 | proc getNumFields*(this: DCClass): int {.importcpp: "#->get_num_fields()".} 756 | 757 | proc getField*(this: DCClass, n: int): DCField {.importcpp: "#->get_field(#)".} 758 | 759 | proc getFieldByName*(this: DCClass, name: string): DCField {.importcpp: "#->get_field_by_name(nimStringToStdString(#))", header: stringConversionCode.} 760 | 761 | proc getFieldByIndex*(this: DCClass, indexNumber: int): DCField {.importcpp: "#->get_field_by_index(#)".} 762 | 763 | proc getNumInheritedFields*(this: DCClass): int {.importcpp: "#->get_num_inherited_fields()".} 764 | 765 | proc getInheritedField*(this: DCClass, n: int): DCField {.importcpp: "#->get_inherited_field(#)".} 766 | 767 | proc isStruct*(this: DCClass): bool {.importcpp: "#->is_struct()".} 768 | 769 | proc isBogusClass*(this: DCClass): bool {.importcpp: "#->is_bogus_class()".} 770 | 771 | proc inheritsFromBogusClass*(this: DCClass): bool {.importcpp: "#->inherits_from_bogus_class()".} 772 | 773 | proc startGenerate*(this: DCClass) {.importcpp: "#->start_generate()".} 774 | 775 | proc stopGenerate*(this: DCClass) {.importcpp: "#->stop_generate()".} 776 | 777 | proc hasClassDef*(this: DCClass): bool {.importcpp: "#->has_class_def()".} 778 | 779 | proc hasOwnerClassDef*(this: DCClass): bool {.importcpp: "#->has_owner_class_def()".} 780 | 781 | proc getClass*(this: DCClassParameter): DCClass {.importcpp: "#.get_class()".} 782 | 783 | proc readAll*(this: DCFile): bool {.importcpp: "#.read_all()".} 784 | 785 | proc read*(this: DCFile, filename: Filename): bool {.importcpp: "#.read(#)".} 786 | 787 | proc read*(this: DCFile, `in`: istream, filename: string): bool {.importcpp: "#.read(#, nimStringToStdString(#))", header: stringConversionCode.} 788 | 789 | proc read*(this: DCFile, `in`: istream): bool {.importcpp: "#.read(#)".} 790 | 791 | proc write*(this: DCFile, filename: Filename, brief: bool): bool {.importcpp: "#.write(#, #)".} 792 | 793 | proc write*(this: DCFile, `out`: ostream, brief: bool): bool {.importcpp: "#.write(#, #)".} 794 | 795 | proc getNumClasses*(this: DCFile): int {.importcpp: "#.get_num_classes()".} 796 | 797 | proc getClass*(this: DCFile, n: int): DCClass {.importcpp: "#.get_class(#)".} 798 | 799 | proc getClassByName*(this: DCFile, name: string): DCClass {.importcpp: "#.get_class_by_name(nimStringToStdString(#))", header: stringConversionCode.} 800 | 801 | proc getSwitchByName*(this: DCFile, name: string): DCSwitch {.importcpp: "#.get_switch_by_name(nimStringToStdString(#))", header: stringConversionCode.} 802 | 803 | proc getFieldByIndex*(this: DCFile, indexNumber: int): DCField {.importcpp: "#.get_field_by_index(#)".} 804 | 805 | proc allObjectsValid*(this: DCFile): bool {.importcpp: "#.all_objects_valid()".} 806 | 807 | proc getNumImportModules*(this: DCFile): int {.importcpp: "#.get_num_import_modules()".} 808 | 809 | proc getImportModule*(this: DCFile, n: int): string {.importcpp: "nimStringFromStdString(#.get_import_module(#))", header: stringConversionCode.} 810 | 811 | proc getNumImportSymbols*(this: DCFile, n: int): int {.importcpp: "#.get_num_import_symbols(#)".} 812 | 813 | proc getImportSymbol*(this: DCFile, n: int, i: int): string {.importcpp: "nimStringFromStdString(#.get_import_symbol(#, #))", header: stringConversionCode.} 814 | 815 | proc getNumTypedefs*(this: DCFile): int {.importcpp: "#.get_num_typedefs()".} 816 | 817 | proc getTypedef*(this: DCFile, n: int): DCTypedef {.importcpp: "#.get_typedef(#)".} 818 | 819 | proc getTypedefByName*(this: DCFile, name: string): DCTypedef {.importcpp: "#.get_typedef_by_name(nimStringToStdString(#))", header: stringConversionCode.} 820 | 821 | proc getHash*(this: DCFile): int {.importcpp: "#.get_hash()".} 822 | 823 | proc getNumAtomics*(this: DCMolecularField): int {.importcpp: "#.get_num_atomics()".} 824 | 825 | proc getAtomic*(this: DCMolecularField, n: int): DCAtomicField {.importcpp: "#.get_atomic(#)".} 826 | 827 | proc getType*(this: DCSimpleParameter): DCSubatomicType {.importcpp: "#.get_type()".} 828 | 829 | proc hasModulus*(this: DCSimpleParameter): bool {.importcpp: "#.has_modulus()".} 830 | 831 | proc getModulus*(this: DCSimpleParameter): float64 {.importcpp: "#.get_modulus()".} 832 | 833 | proc getDivisor*(this: DCSimpleParameter): int {.importcpp: "#.get_divisor()".} 834 | 835 | proc getKeyParameter*(this: DCSwitch): DCField {.importcpp: "#->get_key_parameter()".} 836 | 837 | proc getNumCases*(this: DCSwitch): int {.importcpp: "#->get_num_cases()".} 838 | 839 | proc getCase*(this: DCSwitch, n: int): DCPackerInterface {.importcpp: "#->get_case(#)".} 840 | 841 | proc getDefaultCase*(this: DCSwitch): DCPackerInterface {.importcpp: "#->get_default_case()".} 842 | 843 | proc getNumFields*(this: DCSwitch, caseIndex: int): int {.importcpp: "#->get_num_fields(#)".} 844 | 845 | proc getField*(this: DCSwitch, caseIndex: int, n: int): DCField {.importcpp: "#->get_field(#, #)".} 846 | 847 | proc getFieldByName*(this: DCSwitch, caseIndex: int, name: string): DCField {.importcpp: "#->get_field_by_name(#, nimStringToStdString(#))", header: stringConversionCode.} 848 | 849 | proc getSwitch*(this: DCSwitchParameter): DCSwitch {.importcpp: "#.get_switch()".} 850 | 851 | proc getDescription*(this: DCTypedef): string {.importcpp: "nimStringFromStdString(#->get_description())", header: stringConversionCode.} 852 | 853 | proc isBogusTypedef*(this: DCTypedef): bool {.importcpp: "#->is_bogus_typedef()".} 854 | 855 | proc isImplicitTypedef*(this: DCTypedef): bool {.importcpp: "#->is_implicit_typedef()".} 856 | 857 | proc setPos*(this: SmoothMover, pos: LVecBase3): bool {.importcpp: "#.set_pos((LVecBase3 const &)(#))".} 858 | 859 | proc setPos*(this: SmoothMover, x: float, y: float, z: float): bool {.importcpp: "#.set_pos(#, #, #)".} 860 | 861 | proc setX*(this: SmoothMover, x: float): bool {.importcpp: "#.set_x(#)".} 862 | 863 | proc setY*(this: SmoothMover, y: float): bool {.importcpp: "#.set_y(#)".} 864 | 865 | proc setZ*(this: SmoothMover, z: float): bool {.importcpp: "#.set_z(#)".} 866 | 867 | proc setHpr*(this: SmoothMover, hpr: LVecBase3): bool {.importcpp: "#.set_hpr((LVecBase3 const &)(#))".} 868 | 869 | proc setHpr*(this: SmoothMover, h: float, p: float, r: float): bool {.importcpp: "#.set_hpr(#, #, #)".} 870 | 871 | proc setH*(this: SmoothMover, h: float): bool {.importcpp: "#.set_h(#)".} 872 | 873 | proc setP*(this: SmoothMover, p: float): bool {.importcpp: "#.set_p(#)".} 874 | 875 | proc setR*(this: SmoothMover, r: float): bool {.importcpp: "#.set_r(#)".} 876 | 877 | proc setPosHpr*(this: SmoothMover, pos: LVecBase3, hpr: LVecBase3): bool {.importcpp: "#.set_pos_hpr((LVecBase3 const &)(#), (LVecBase3 const &)(#))".} 878 | 879 | proc setPosHpr*(this: SmoothMover, x: float, y: float, z: float, h: float, p: float, r: float): bool {.importcpp: "#.set_pos_hpr(#, #, #, #, #, #)".} 880 | 881 | proc getSamplePos*(this: SmoothMover): LPoint3 {.importcpp: "#.get_sample_pos()".} 882 | 883 | proc getSampleHpr*(this: SmoothMover): LVecBase3 {.importcpp: "#.get_sample_hpr()".} 884 | 885 | proc setPhonyTimestamp*(this: SmoothMover, timestamp: float64, periodAdjust: bool) {.importcpp: "#.set_phony_timestamp(#, #)".} 886 | 887 | proc setPhonyTimestamp*(this: SmoothMover, timestamp: float64) {.importcpp: "#.set_phony_timestamp(#)".} 888 | 889 | proc setPhonyTimestamp*(this: SmoothMover) {.importcpp: "#.set_phony_timestamp()".} 890 | 891 | proc setTimestamp*(this: SmoothMover, timestamp: float64) {.importcpp: "#.set_timestamp(#)".} 892 | 893 | proc hasMostRecentTimestamp*(this: SmoothMover): bool {.importcpp: "#.has_most_recent_timestamp()".} 894 | 895 | proc getMostRecentTimestamp*(this: SmoothMover): float64 {.importcpp: "#.get_most_recent_timestamp()".} 896 | 897 | proc markPosition*(this: SmoothMover) {.importcpp: "#.mark_position()".} 898 | 899 | proc clearPositions*(this: SmoothMover, resetVelocity: bool) {.importcpp: "#.clear_positions(#)".} 900 | 901 | proc computeSmoothPosition*(this: SmoothMover): bool {.importcpp: "#.compute_smooth_position()".} 902 | 903 | proc computeSmoothPosition*(this: SmoothMover, timestamp: float64): bool {.importcpp: "#.compute_smooth_position(#)".} 904 | 905 | proc getLatestPosition*(this: SmoothMover): bool {.importcpp: "#.get_latest_position()".} 906 | 907 | proc getSmoothPos*(this: SmoothMover): LPoint3 {.importcpp: "#.get_smooth_pos()".} 908 | 909 | proc getSmoothHpr*(this: SmoothMover): LVecBase3 {.importcpp: "#.get_smooth_hpr()".} 910 | 911 | proc applySmoothPos*(this: SmoothMover, node: NodePath) {.importcpp: "#.apply_smooth_pos(#)".} 912 | 913 | proc applySmoothPosHpr*(this: SmoothMover, posNode: NodePath, hprNode: NodePath) {.importcpp: "#.apply_smooth_pos_hpr(#, #)".} 914 | 915 | proc applySmoothHpr*(this: SmoothMover, node: NodePath) {.importcpp: "#.apply_smooth_hpr(#)".} 916 | 917 | proc computeAndApplySmoothPos*(this: SmoothMover, node: NodePath) {.importcpp: "#.compute_and_apply_smooth_pos(#)".} 918 | 919 | proc computeAndApplySmoothPosHpr*(this: SmoothMover, posNode: NodePath, hprNode: NodePath) {.importcpp: "#.compute_and_apply_smooth_pos_hpr(#, #)".} 920 | 921 | proc computeAndApplySmoothHpr*(this: SmoothMover, hprNode: NodePath) {.importcpp: "#.compute_and_apply_smooth_hpr(#)".} 922 | 923 | proc getSmoothForwardVelocity*(this: SmoothMover): float {.importcpp: "#.get_smooth_forward_velocity()".} 924 | 925 | proc getSmoothLateralVelocity*(this: SmoothMover): float {.importcpp: "#.get_smooth_lateral_velocity()".} 926 | 927 | proc getSmoothRotationalVelocity*(this: SmoothMover): float {.importcpp: "#.get_smooth_rotational_velocity()".} 928 | 929 | proc getForwardAxis*(this: SmoothMover): LVecBase3 {.importcpp: "#.get_forward_axis()".} 930 | 931 | proc handleWrtReparent*(this: SmoothMover, oldParent: NodePath, newParent: NodePath) {.importcpp: "#.handle_wrt_reparent(#, #)".} 932 | 933 | proc setSmoothMode*(this: SmoothMover, mode: SmoothMover_SmoothMode) {.importcpp: "#.set_smooth_mode(#)".} 934 | 935 | proc getSmoothMode*(this: SmoothMover): SmoothMover_SmoothMode {.importcpp: "#.get_smooth_mode()".} 936 | 937 | proc setPredictionMode*(this: SmoothMover, mode: SmoothMover_PredictionMode) {.importcpp: "#.set_prediction_mode(#)".} 938 | 939 | proc getPredictionMode*(this: SmoothMover): SmoothMover_PredictionMode {.importcpp: "#.get_prediction_mode()".} 940 | 941 | proc setDelay*(this: SmoothMover, delay: float64) {.importcpp: "#.set_delay(#)".} 942 | 943 | proc getDelay*(this: SmoothMover): float64 {.importcpp: "#.get_delay()".} 944 | 945 | proc setAcceptClockSkew*(this: SmoothMover, flag: bool) {.importcpp: "#.set_accept_clock_skew(#)".} 946 | 947 | proc getAcceptClockSkew*(this: SmoothMover): bool {.importcpp: "#.get_accept_clock_skew()".} 948 | 949 | proc setMaxPositionAge*(this: SmoothMover, age: float64) {.importcpp: "#.set_max_position_age(#)".} 950 | 951 | proc getMaxPositionAge*(this: SmoothMover): float64 {.importcpp: "#.get_max_position_age()".} 952 | 953 | proc setExpectedBroadcastPeriod*(this: SmoothMover, period: float64) {.importcpp: "#.set_expected_broadcast_period(#)".} 954 | 955 | proc getExpectedBroadcastPeriod*(this: SmoothMover): float64 {.importcpp: "#.get_expected_broadcast_period()".} 956 | 957 | proc setResetVelocityAge*(this: SmoothMover, age: float64) {.importcpp: "#.set_reset_velocity_age(#)".} 958 | 959 | proc getResetVelocityAge*(this: SmoothMover): float64 {.importcpp: "#.get_reset_velocity_age()".} 960 | 961 | proc setDirectionalVelocity*(this: SmoothMover, flag: bool) {.importcpp: "#.set_directional_velocity(#)".} 962 | 963 | proc getDirectionalVelocity*(this: SmoothMover): bool {.importcpp: "#.get_directional_velocity()".} 964 | 965 | proc setDefaultToStandingStill*(this: SmoothMover, flag: bool) {.importcpp: "#.set_default_to_standing_still(#)".} 966 | 967 | proc getDefaultToStandingStill*(this: SmoothMover): bool {.importcpp: "#.get_default_to_standing_still()".} 968 | 969 | proc output*(this: SmoothMover, `out`: ostream) {.importcpp: "#.output(#)".} 970 | 971 | proc write*(this: SmoothMover, `out`: ostream) {.importcpp: "#.write(#)".} 972 | 973 | proc getDuration*(this: CInterval): float64 {.importcpp: "#->get_duration()".} 974 | 975 | proc getOpenEnded*(this: CInterval): bool {.importcpp: "#->get_open_ended()".} 976 | 977 | proc getState*(this: CInterval): CInterval_State {.importcpp: "#->get_state()".} 978 | 979 | proc isStopped*(this: CInterval): bool {.importcpp: "#->is_stopped()".} 980 | 981 | proc setDoneEvent*(this: CInterval, event: string) {.importcpp: "#->set_done_event(nimStringToStdString(#))", header: stringConversionCode.} 982 | 983 | proc getDoneEvent*(this: CInterval): string {.importcpp: "nimStringFromStdString(#->get_done_event())", header: stringConversionCode.} 984 | 985 | proc setT*(this: CInterval, t: float64) {.importcpp: "#->set_t(#)".} 986 | 987 | proc getT*(this: CInterval): float64 {.importcpp: "#->get_t()".} 988 | 989 | proc setAutoPause*(this: CInterval, autoPause: bool) {.importcpp: "#->set_auto_pause(#)".} 990 | 991 | proc getAutoPause*(this: CInterval): bool {.importcpp: "#->get_auto_pause()".} 992 | 993 | proc setAutoFinish*(this: CInterval, autoFinish: bool) {.importcpp: "#->set_auto_finish(#)".} 994 | 995 | proc getAutoFinish*(this: CInterval): bool {.importcpp: "#->get_auto_finish()".} 996 | 997 | proc setWantsTCallback*(this: CInterval, wantsTCallback: bool) {.importcpp: "#->set_wants_t_callback(#)".} 998 | 999 | proc getWantsTCallback*(this: CInterval): bool {.importcpp: "#->get_wants_t_callback()".} 1000 | 1001 | proc setManager*(this: CInterval, manager: CIntervalManager) {.importcpp: "#->set_manager(#)".} 1002 | 1003 | proc getManager*(this: CInterval): CIntervalManager {.importcpp: "#->get_manager()".} 1004 | 1005 | proc start*(this: CInterval, startT: float64, endT: float64, playRate: float64) {.importcpp: "#->start(#, #, #)".} 1006 | 1007 | proc start*(this: CInterval, startT: float64, endT: float64) {.importcpp: "#->start(#, #)".} 1008 | 1009 | proc start*(this: CInterval, startT: float64) {.importcpp: "#->start(#)".} 1010 | 1011 | proc start*(this: CInterval) {.importcpp: "#->start()".} 1012 | 1013 | proc loop*(this: CInterval, startT: float64, endT: float64, playRate: float64) {.importcpp: "#->loop(#, #, #)".} 1014 | 1015 | proc loop*(this: CInterval, startT: float64, endT: float64) {.importcpp: "#->loop(#, #)".} 1016 | 1017 | proc loop*(this: CInterval, startT: float64) {.importcpp: "#->loop(#)".} 1018 | 1019 | proc loop*(this: CInterval) {.importcpp: "#->loop()".} 1020 | 1021 | proc pause*(this: CInterval): float64 {.importcpp: "#->pause()".} 1022 | 1023 | proc resume*(this: CInterval) {.importcpp: "#->resume()".} 1024 | 1025 | proc resume*(this: CInterval, startT: float64) {.importcpp: "#->resume(#)".} 1026 | 1027 | proc resumeUntil*(this: CInterval, endT: float64) {.importcpp: "#->resume_until(#)".} 1028 | 1029 | proc finish*(this: CInterval) {.importcpp: "#->finish()".} 1030 | 1031 | proc clearToInitial*(this: CInterval) {.importcpp: "#->clear_to_initial()".} 1032 | 1033 | proc isPlaying*(this: CInterval): bool {.importcpp: "#->is_playing()".} 1034 | 1035 | proc getPlayRate*(this: CInterval): float64 {.importcpp: "#->get_play_rate()".} 1036 | 1037 | proc setPlayRate*(this: CInterval, playRate: float64) {.importcpp: "#->set_play_rate(#)".} 1038 | 1039 | proc privDoEvent*(this: CInterval, t: float64, event: CInterval_EventType) {.importcpp: "#->priv_do_event(#, #)".} 1040 | 1041 | proc privInitialize*(this: CInterval, t: float64) {.importcpp: "#->priv_initialize(#)".} 1042 | 1043 | proc privInstant*(this: CInterval) {.importcpp: "#->priv_instant()".} 1044 | 1045 | proc privStep*(this: CInterval, t: float64) {.importcpp: "#->priv_step(#)".} 1046 | 1047 | proc privFinalize*(this: CInterval) {.importcpp: "#->priv_finalize()".} 1048 | 1049 | proc privReverseInitialize*(this: CInterval, t: float64) {.importcpp: "#->priv_reverse_initialize(#)".} 1050 | 1051 | proc privReverseInstant*(this: CInterval) {.importcpp: "#->priv_reverse_instant()".} 1052 | 1053 | proc privReverseFinalize*(this: CInterval) {.importcpp: "#->priv_reverse_finalize()".} 1054 | 1055 | proc privInterrupt*(this: CInterval) {.importcpp: "#->priv_interrupt()".} 1056 | 1057 | proc setupPlay*(this: CInterval, startTime: float64, endTime: float64, playRate: float64, doLoop: bool) {.importcpp: "#->setup_play(#, #, #, #)".} 1058 | 1059 | proc setupResume*(this: CInterval) {.importcpp: "#->setup_resume()".} 1060 | 1061 | proc setupResumeUntil*(this: CInterval, endT: float64) {.importcpp: "#->setup_resume_until(#)".} 1062 | 1063 | proc stepPlay*(this: CInterval): bool {.importcpp: "#->step_play()".} 1064 | 1065 | proc setEventQueue*(this: CIntervalManager, eventQueue: EventQueue) {.importcpp: "#->set_event_queue(#)".} 1066 | 1067 | proc getEventQueue*(this: CIntervalManager): EventQueue {.importcpp: "#->get_event_queue()".} 1068 | 1069 | proc addCInterval*(this: CIntervalManager, interval: CInterval, external: bool): int {.importcpp: "#->add_c_interval(#, #)".} 1070 | 1071 | proc findCInterval*(this: CIntervalManager, name: string): int {.importcpp: "#->find_c_interval(nimStringToStdString(#))", header: stringConversionCode.} 1072 | 1073 | proc getCInterval*(this: CIntervalManager, index: int): CInterval {.importcpp: "#->get_c_interval(#)".} 1074 | 1075 | proc removeCInterval*(this: CIntervalManager, index: int) {.importcpp: "#->remove_c_interval(#)".} 1076 | 1077 | proc interrupt*(this: CIntervalManager): int {.importcpp: "#->interrupt()".} 1078 | 1079 | proc getNumIntervals*(this: CIntervalManager): int {.importcpp: "#->get_num_intervals()".} 1080 | 1081 | proc getMaxIndex*(this: CIntervalManager): int {.importcpp: "#->get_max_index()".} 1082 | 1083 | proc step*(this: CIntervalManager) {.importcpp: "#->step()".} 1084 | 1085 | proc getNextEvent*(this: CIntervalManager): int {.importcpp: "#->get_next_event()".} 1086 | 1087 | proc getNextRemoval*(this: CIntervalManager): int {.importcpp: "#->get_next_removal()".} 1088 | 1089 | proc write*(this: CIntervalManager, `out`: ostream) {.importcpp: "#->write(#)".} 1090 | 1091 | proc getNode*(this: CConstrainHprInterval | CConstrainPosHprInterval | CConstrainPosInterval | CConstrainTransformInterval | CLerpNodePathInterval): NodePath {.importcpp: "#->get_node()".} 1092 | 1093 | proc getTarget*(this: CConstrainHprInterval | CConstrainPosHprInterval | CConstrainPosInterval | CConstrainTransformInterval): NodePath {.importcpp: "#->get_target()".} 1094 | 1095 | proc getBlendType*(this: CLerpInterval): CLerpInterval_BlendType {.importcpp: "#->get_blend_type()".} 1096 | 1097 | proc addControl*(this: CLerpAnimEffectInterval, control: AnimControl, name: string, beginEffect: float32, endEffect: float32) {.importcpp: "#->add_control(#, nimStringToStdString(#), #, #)", header: stringConversionCode.} 1098 | 1099 | proc getOther*(this: CLerpNodePathInterval): NodePath {.importcpp: "#->get_other()".} 1100 | 1101 | proc setStartPos*(this: CLerpNodePathInterval, pos: LVecBase3) {.importcpp: "#->set_start_pos((LVecBase3 const &)(#))".} 1102 | 1103 | proc setEndPos*(this: CLerpNodePathInterval, pos: LVecBase3) {.importcpp: "#->set_end_pos((LVecBase3 const &)(#))".} 1104 | 1105 | proc setStartHpr*(this: CLerpNodePathInterval, hpr: LVecBase3) {.importcpp: "#->set_start_hpr((LVecBase3 const &)(#))".} 1106 | 1107 | proc setEndHpr*(this: CLerpNodePathInterval, quat: LQuaternion) {.importcpp: "#->set_end_hpr(#)".} 1108 | 1109 | proc setEndHpr*(this: CLerpNodePathInterval, hpr: LVecBase3) {.importcpp: "#->set_end_hpr((LVecBase3 const &)(#))".} 1110 | 1111 | proc setStartQuat*(this: CLerpNodePathInterval, quat: LQuaternion) {.importcpp: "#->set_start_quat(#)".} 1112 | 1113 | proc setEndQuat*(this: CLerpNodePathInterval, quat: LQuaternion) {.importcpp: "#->set_end_quat(#)".} 1114 | 1115 | proc setEndQuat*(this: CLerpNodePathInterval, hpr: LVecBase3) {.importcpp: "#->set_end_quat((LVecBase3 const &)(#))".} 1116 | 1117 | proc setStartScale*(this: CLerpNodePathInterval, scale: LVecBase3) {.importcpp: "#->set_start_scale((LVecBase3 const &)(#))".} 1118 | 1119 | proc setStartScale*(this: CLerpNodePathInterval, scale: float) {.importcpp: "#->set_start_scale(#)".} 1120 | 1121 | proc setEndScale*(this: CLerpNodePathInterval, scale: LVecBase3) {.importcpp: "#->set_end_scale((LVecBase3 const &)(#))".} 1122 | 1123 | proc setEndScale*(this: CLerpNodePathInterval, scale: float) {.importcpp: "#->set_end_scale(#)".} 1124 | 1125 | proc setStartShear*(this: CLerpNodePathInterval, shear: LVecBase3) {.importcpp: "#->set_start_shear((LVecBase3 const &)(#))".} 1126 | 1127 | proc setEndShear*(this: CLerpNodePathInterval, shear: LVecBase3) {.importcpp: "#->set_end_shear((LVecBase3 const &)(#))".} 1128 | 1129 | proc setStartColor*(this: CLerpNodePathInterval, color: LVecBase4) {.importcpp: "#->set_start_color((LVecBase4 const &)(#))".} 1130 | 1131 | proc setEndColor*(this: CLerpNodePathInterval, color: LVecBase4) {.importcpp: "#->set_end_color((LVecBase4 const &)(#))".} 1132 | 1133 | proc setStartColorScale*(this: CLerpNodePathInterval, colorScale: LVecBase4) {.importcpp: "#->set_start_color_scale((LVecBase4 const &)(#))".} 1134 | 1135 | proc setEndColorScale*(this: CLerpNodePathInterval, colorScale: LVecBase4) {.importcpp: "#->set_end_color_scale((LVecBase4 const &)(#))".} 1136 | 1137 | proc setTextureStage*(this: CLerpNodePathInterval, stage: TextureStage) {.importcpp: "#->set_texture_stage(#)".} 1138 | 1139 | proc setStartTexOffset*(this: CLerpNodePathInterval, texOffset: LVecBase2) {.importcpp: "#->set_start_tex_offset((LVecBase2 const &)(#))".} 1140 | 1141 | proc setEndTexOffset*(this: CLerpNodePathInterval, texOffset: LVecBase2) {.importcpp: "#->set_end_tex_offset((LVecBase2 const &)(#))".} 1142 | 1143 | proc setStartTexRotate*(this: CLerpNodePathInterval, texRotate: float) {.importcpp: "#->set_start_tex_rotate(#)".} 1144 | 1145 | proc setEndTexRotate*(this: CLerpNodePathInterval, texRotate: float) {.importcpp: "#->set_end_tex_rotate(#)".} 1146 | 1147 | proc setStartTexScale*(this: CLerpNodePathInterval, texScale: LVecBase2) {.importcpp: "#->set_start_tex_scale((LVecBase2 const &)(#))".} 1148 | 1149 | proc setEndTexScale*(this: CLerpNodePathInterval, texScale: LVecBase2) {.importcpp: "#->set_end_tex_scale((LVecBase2 const &)(#))".} 1150 | 1151 | proc setOverride*(this: CLerpNodePathInterval, override: int) {.importcpp: "#->set_override(#)".} 1152 | 1153 | proc getOverride*(this: CLerpNodePathInterval): int {.importcpp: "#->get_override()".} 1154 | 1155 | proc setPrecision*(this: CMetaInterval, precision: float64) {.importcpp: "#->set_precision(#)".} 1156 | 1157 | proc getPrecision*(this: CMetaInterval): float64 {.importcpp: "#->get_precision()".} 1158 | 1159 | proc clearIntervals*(this: CMetaInterval) {.importcpp: "#->clear_intervals()".} 1160 | 1161 | proc pushLevel*(this: CMetaInterval, name: string, relTime: float64, relTo: CMetaInterval_RelativeStart): int {.importcpp: "#->push_level(nimStringToStdString(#), #, #)", header: stringConversionCode.} 1162 | 1163 | proc addCInterval*(this: CMetaInterval, cInterval: CInterval, relTime: float64, relTo: CMetaInterval_RelativeStart): int {.importcpp: "#->add_c_interval(#, #, #)".} 1164 | 1165 | proc addCInterval*(this: CMetaInterval, cInterval: CInterval, relTime: float64): int {.importcpp: "#->add_c_interval(#, #)".} 1166 | 1167 | proc addCInterval*(this: CMetaInterval, cInterval: CInterval): int {.importcpp: "#->add_c_interval(#)".} 1168 | 1169 | proc addExtIndex*(this: CMetaInterval, extIndex: int, name: string, duration: float64, openEnded: bool, relTime: float64, relTo: CMetaInterval_RelativeStart): int {.importcpp: "#->add_ext_index(#, nimStringToStdString(#), #, #, #, #)", header: stringConversionCode.} 1170 | 1171 | proc popLevel*(this: CMetaInterval, duration: float64): int {.importcpp: "#->pop_level(#)".} 1172 | 1173 | proc popLevel*(this: CMetaInterval): int {.importcpp: "#->pop_level()".} 1174 | 1175 | proc setIntervalStartTime*(this: CMetaInterval, name: string, relTime: float64, relTo: CMetaInterval_RelativeStart): bool {.importcpp: "#->set_interval_start_time(nimStringToStdString(#), #, #)", header: stringConversionCode.} 1176 | 1177 | proc setIntervalStartTime*(this: CMetaInterval, name: string, relTime: float64): bool {.importcpp: "#->set_interval_start_time(nimStringToStdString(#), #)", header: stringConversionCode.} 1178 | 1179 | proc getIntervalStartTime*(this: CMetaInterval, name: string): float64 {.importcpp: "#->get_interval_start_time(nimStringToStdString(#))", header: stringConversionCode.} 1180 | 1181 | proc getIntervalEndTime*(this: CMetaInterval, name: string): float64 {.importcpp: "#->get_interval_end_time(nimStringToStdString(#))", header: stringConversionCode.} 1182 | 1183 | proc getNumDefs*(this: CMetaInterval): int {.importcpp: "#->get_num_defs()".} 1184 | 1185 | proc getDefType*(this: CMetaInterval, n: int): CMetaInterval_DefType {.importcpp: "#->get_def_type(#)".} 1186 | 1187 | proc getCInterval*(this: CMetaInterval, n: int): CInterval {.importcpp: "#->get_c_interval(#)".} 1188 | 1189 | proc getExtIndex*(this: CMetaInterval, n: int): int {.importcpp: "#->get_ext_index(#)".} 1190 | 1191 | proc isEventReady*(this: CMetaInterval): bool {.importcpp: "#->is_event_ready()".} 1192 | 1193 | proc getEventIndex*(this: CMetaInterval): int {.importcpp: "#->get_event_index()".} 1194 | 1195 | proc getEventT*(this: CMetaInterval): float64 {.importcpp: "#->get_event_t()".} 1196 | 1197 | proc getEventType*(this: CMetaInterval): CInterval_EventType {.importcpp: "#->get_event_type()".} 1198 | 1199 | proc popEvent*(this: CMetaInterval) {.importcpp: "#->pop_event()".} 1200 | 1201 | proc timeline*(this: CMetaInterval, `out`: ostream) {.importcpp: "#->timeline(#)".} 1202 | 1203 | proc getDcFile*(this: CConnectionRepository): DCFile {.importcpp: "#.get_dc_file()".} 1204 | 1205 | proc hasOwnerView*(this: CConnectionRepository): bool {.importcpp: "#.has_owner_view()".} 1206 | 1207 | proc setHandleCUpdates*(this: CConnectionRepository, handleCUpdates: bool) {.importcpp: "#.set_handle_c_updates(#)".} 1208 | 1209 | proc getHandleCUpdates*(this: CConnectionRepository): bool {.importcpp: "#.get_handle_c_updates()".} 1210 | 1211 | proc setClientDatagram*(this: CConnectionRepository, clientDatagram: bool) {.importcpp: "#.set_client_datagram(#)".} 1212 | 1213 | proc getClientDatagram*(this: CConnectionRepository): bool {.importcpp: "#.get_client_datagram()".} 1214 | 1215 | proc setHandleDatagramsInternally*(this: CConnectionRepository, handleDatagramsInternally: bool) {.importcpp: "#.set_handle_datagrams_internally(#)".} 1216 | 1217 | proc getHandleDatagramsInternally*(this: CConnectionRepository): bool {.importcpp: "#.get_handle_datagrams_internally()".} 1218 | 1219 | proc setTcpHeaderSize*(this: CConnectionRepository, tcpHeaderSize: int) {.importcpp: "#.set_tcp_header_size(#)".} 1220 | 1221 | proc getTcpHeaderSize*(this: CConnectionRepository): int {.importcpp: "#.get_tcp_header_size()".} 1222 | 1223 | proc setConnectionHttp*(this: CConnectionRepository, channel: HTTPChannel) {.importcpp: "#.set_connection_http(#)".} 1224 | 1225 | proc getStream*(this: CConnectionRepository): SocketStream {.importcpp: "#.get_stream()".} 1226 | 1227 | proc tryConnectNet*(this: CConnectionRepository, url: URLSpec): bool {.importcpp: "#.try_connect_net(#)".} 1228 | 1229 | proc getQcm*(this: CConnectionRepository): QueuedConnectionManager {.importcpp: "#.get_qcm()".} 1230 | 1231 | proc getCw*(this: CConnectionRepository): ConnectionWriter {.importcpp: "#.get_cw()".} 1232 | 1233 | proc getQcr*(this: CConnectionRepository): QueuedConnectionReader {.importcpp: "#.get_qcr()".} 1234 | 1235 | proc connectNative*(this: CConnectionRepository, url: URLSpec): bool {.importcpp: "#.connect_native(#)".} 1236 | 1237 | proc getBdc*(this: CConnectionRepository): Buffered_DatagramConnection {.importcpp: "#.get_bdc()".} 1238 | 1239 | proc checkDatagram*(this: CConnectionRepository): bool {.importcpp: "#.check_datagram()".} 1240 | 1241 | proc getDatagram*(this: CConnectionRepository, dg: Datagram) {.importcpp: "#.get_datagram(#)".} 1242 | 1243 | proc getDatagramIterator*(this: CConnectionRepository, di: DatagramIterator) {.importcpp: "#.get_datagram_iterator(#)".} 1244 | 1245 | proc getMsgChannel*(this: CConnectionRepository, offset: int): clonglong {.importcpp: "#.get_msg_channel(#)".} 1246 | 1247 | proc getMsgChannel*(this: CConnectionRepository): clonglong {.importcpp: "#.get_msg_channel()".} 1248 | 1249 | proc getMsgChannelCount*(this: CConnectionRepository): int {.importcpp: "#.get_msg_channel_count()".} 1250 | 1251 | proc getMsgSender*(this: CConnectionRepository): clonglong {.importcpp: "#.get_msg_sender()".} 1252 | 1253 | proc getMsgType*(this: CConnectionRepository): int {.importcpp: "#.get_msg_type()".} 1254 | 1255 | proc isConnected*(this: CConnectionRepository): bool {.importcpp: "#.is_connected()".} 1256 | 1257 | proc sendDatagram*(this: CConnectionRepository, dg: Datagram): bool {.importcpp: "#.send_datagram(#)".} 1258 | 1259 | proc setWantMessageBundling*(this: CConnectionRepository, flag: bool) {.importcpp: "#.set_want_message_bundling(#)".} 1260 | 1261 | proc getWantMessageBundling*(this: CConnectionRepository): bool {.importcpp: "#.get_want_message_bundling()".} 1262 | 1263 | proc setInQuietZone*(this: CConnectionRepository, flag: bool) {.importcpp: "#.set_in_quiet_zone(#)".} 1264 | 1265 | proc getInQuietZone*(this: CConnectionRepository): bool {.importcpp: "#.get_in_quiet_zone()".} 1266 | 1267 | proc startMessageBundle*(this: CConnectionRepository) {.importcpp: "#.start_message_bundle()".} 1268 | 1269 | proc isBundlingMessages*(this: CConnectionRepository): bool {.importcpp: "#.is_bundling_messages()".} 1270 | 1271 | proc sendMessageBundle*(this: CConnectionRepository, channel: int, senderChannel: int) {.importcpp: "#.send_message_bundle(#, #)".} 1272 | 1273 | proc abandonMessageBundles*(this: CConnectionRepository) {.importcpp: "#.abandon_message_bundles()".} 1274 | 1275 | proc bundleMsg*(this: CConnectionRepository, dg: Datagram) {.importcpp: "#.bundle_msg(#)".} 1276 | 1277 | proc considerFlush*(this: CConnectionRepository): bool {.importcpp: "#.consider_flush()".} 1278 | 1279 | proc flush*(this: CConnectionRepository): bool {.importcpp: "#.flush()".} 1280 | 1281 | proc disconnect*(this: CConnectionRepository) {.importcpp: "#.disconnect()".} 1282 | 1283 | proc shutdown*(this: CConnectionRepository) {.importcpp: "#.shutdown()".} 1284 | 1285 | proc setSimulatedDisconnect*(this: CConnectionRepository, simulatedDisconnect: bool) {.importcpp: "#.set_simulated_disconnect(#)".} 1286 | 1287 | proc getSimulatedDisconnect*(this: CConnectionRepository): bool {.importcpp: "#.get_simulated_disconnect()".} 1288 | 1289 | proc toggleVerbose*(this: CConnectionRepository) {.importcpp: "#.toggle_verbose()".} 1290 | 1291 | proc setVerbose*(this: CConnectionRepository, verbose: bool) {.importcpp: "#.set_verbose(#)".} 1292 | 1293 | proc getVerbose*(this: CConnectionRepository): bool {.importcpp: "#.get_verbose()".} 1294 | 1295 | proc setTimeWarning*(this: CConnectionRepository, timeWarning: float32) {.importcpp: "#.set_time_warning(#)".} 1296 | 1297 | proc getTimeWarning*(this: CConnectionRepository): float32 {.importcpp: "#.get_time_warning()".} 1298 | 1299 | proc setRepository*(this: CDistributedSmoothNodeBase, repository: CConnectionRepository, isAi: bool, aiId: clonglong) {.importcpp: "#.set_repository(#, #, #)".} 1300 | 1301 | proc initialize*(this: CDistributedSmoothNodeBase, nodePath: NodePath, dclass: DCClass, doId: clonglong) {.importcpp: "#.initialize(#, #, #)".} 1302 | 1303 | proc sendEverything*(this: CDistributedSmoothNodeBase) {.importcpp: "#.send_everything()".} 1304 | 1305 | proc broadcastPosHprFull*(this: CDistributedSmoothNodeBase) {.importcpp: "#.broadcast_pos_hpr_full()".} 1306 | 1307 | proc broadcastPosHprXyh*(this: CDistributedSmoothNodeBase) {.importcpp: "#.broadcast_pos_hpr_xyh()".} 1308 | 1309 | proc broadcastPosHprXy*(this: CDistributedSmoothNodeBase) {.importcpp: "#.broadcast_pos_hpr_xy()".} 1310 | 1311 | proc setCurrL*(this: CDistributedSmoothNodeBase, l: clonglong) {.importcpp: "#.set_curr_l(#)".} 1312 | 1313 | proc printCurrL*(this: CDistributedSmoothNodeBase) {.importcpp: "#.print_curr_l()".} 1314 | 1315 | proc reset*(this: CMotionTrail) {.importcpp: "#->reset()".} 1316 | 1317 | proc resetVertexList*(this: CMotionTrail) {.importcpp: "#->reset_vertex_list()".} 1318 | 1319 | proc enable*(this: CMotionTrail, enable: bool) {.importcpp: "#->enable(#)".} 1320 | 1321 | proc setGeomNode*(this: CMotionTrail, geomNode: GeomNode) {.importcpp: "#->set_geom_node(#)".} 1322 | 1323 | proc addVertex*(this: CMotionTrail, vertex: LVector4, startColor: LVector4, endColor: LVector4, v: float) {.importcpp: "#->add_vertex((LVector4 &)(#), (LVector4 &)(#), (LVector4 &)(#), #)".} 1324 | 1325 | proc setParameters*(this: CMotionTrail, samplingTime: float, timeWindow: float, useTexture: bool, calculateRelativeMatrix: bool, useNurbs: bool, resolutionDistance: float) {.importcpp: "#->set_parameters(#, #, #, #, #, #)".} 1326 | 1327 | proc checkForUpdate*(this: CMotionTrail, currentTime: float): int {.importcpp: "#->check_for_update(#)".} 1328 | 1329 | proc updateMotionTrail*(this: CMotionTrail, currentTime: float, transform: LMatrix4) {.importcpp: "#->update_motion_trail(#, #)".} 1330 | 1331 | func `$`*(this: CInterval | CIntervalManager | DCClass | DCDeclaration | DCField | SmoothMover): string {.inline.} = 1332 | var str : StringStream 1333 | this.output(str) 1334 | str.data 1335 | 1336 | converter toBool*(this: CConstrainHprInterval | CConstrainPosHprInterval | CConstrainPosInterval | CConstrainTransformInterval | CConstraintInterval | CInterval | CIntervalManager | CLerpAnimEffectInterval | CLerpInterval | CLerpNodePathInterval | CMetaInterval | CMotionTrail | DCArrayParameter | DCAtomicField | DCClass | DCDeclaration | DCField | DCKeyword | DCPackerInterface | DCParameter | DCSwitch | DCTypedef | EaseInBlendType | EaseInOutBlendType | EaseOutBlendType | HideInterval | LerpBlendType | NoBlendType | ShowInterval | WaitInterval): bool {.importcpp: "(# != nullptr)".} 1337 | func `==`*(x: CConstrainHprInterval | CConstrainPosHprInterval | CConstrainPosInterval | CConstrainTransformInterval | CConstraintInterval | CInterval | CIntervalManager | CLerpAnimEffectInterval | CLerpInterval | CLerpNodePathInterval | CMetaInterval | CMotionTrail | DCArrayParameter | DCAtomicField | DCClass | DCDeclaration | DCField | DCKeyword | DCPackerInterface | DCParameter | DCSwitch | DCTypedef | EaseInBlendType | EaseInOutBlendType | EaseOutBlendType | HideInterval | LerpBlendType | NoBlendType | ShowInterval | WaitInterval, y: type(nil)): bool {.importcpp: "(# == nullptr)".} 1338 | 1339 | -------------------------------------------------------------------------------- /panda3d/helpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pointerTo.h" 4 | 5 | template PT(T) deconstify(CPT(T) value) { 6 | PT(T) result; 7 | result.cheat() = (T *)value.p(); 8 | value.cheat() = nullptr; 9 | return result; 10 | } 11 | 12 | template T *deconstify(const T *value) { 13 | return (T *)value; 14 | } 15 | -------------------------------------------------------------------------------- /panda3d/private.nim: -------------------------------------------------------------------------------- 1 | import std/time_t 2 | export time_t.Time 3 | 4 | from os import splitPath 5 | 6 | when defined(pandaDir): 7 | const pandaDir* {.strdefine.}: string = "" 8 | when len(pandaDir) < 1: 9 | {.error: "pandaDir must not be an empty string when defined".} 10 | 11 | when defined(vcc): 12 | {.passC: "/DNOMINMAX".} 13 | 14 | when defined(pandaDir): 15 | {.passC: "/I\"" & pandaDir & "/include\"".} 16 | 17 | # For memcpy, Notify 18 | {.emit: """ 19 | #include 20 | #include "pnotify.h" 21 | """.} 22 | 23 | const deconstifyCode* = "#include \"" & currentSourcePath().splitPath.head & "/helpers.hpp\""; 24 | 25 | when defined(nimSeqsV2): 26 | const stringConversionCode* = """ 27 | #include 28 | 29 | N_LIB_PRIVATE N_NIMCALL(std::string, nimStringToStdString)(struct NimStringV2 desc); 30 | N_LIB_PRIVATE N_NIMCALL(struct NimStringV2, nimStringFromStdString)(const std::string &s); 31 | """; 32 | else: 33 | const stringConversionCode* = """ 34 | #include 35 | 36 | N_LIB_PRIVATE N_NIMCALL(std::string, nimStringToStdString)(struct NimStringDesc *desc); 37 | N_LIB_PRIVATE N_NIMCALL(struct NimStringDesc*, nimStringFromStdString)(const std::string &s); 38 | """; 39 | 40 | type 41 | std_string* {.importcpp: "std::string", header: "string".} = object 42 | 43 | type 44 | std_string_const_ref* {.importcpp: "std::string const&", header: "string".} = object 45 | 46 | converter constRef(s: std_string): std_string_const_ref {.importcpp: "(#)".} 47 | 48 | func size(this: std_string_const_ref): int {.importcpp: "size".} 49 | 50 | when defined(nimSeqsV2): 51 | func nimStringFromStdString(s: std_string_const_ref): string {.noinit, exportcpp: "nimStringFromStdString".} = 52 | result = newString(s.size()) 53 | {.emit: "memcpy(result.p->data, `s`.data(), `s`.size());"} 54 | 55 | func nimStringToStdString(desc: string): std_string {.noinit, exportcpp: "nimStringToStdString".} = 56 | {.emit: "if (`desc`.len > 0) result.assign(`desc`.p->data, `desc`.len);"} 57 | else: 58 | func nimStringFromStdString(s: std_string_const_ref): string {.noinit, exportcpp: "nimStringFromStdString".} = 59 | result = newString(s.size()) 60 | {.emit: "memcpy(result->data, `s`.data(), `s`.size());"} 61 | 62 | func nimStringToStdString(desc: string): std_string {.noinit, exportcpp: "nimStringToStdString".} = 63 | {.emit: "if (`desc` != nullptr) result.assign(`desc`->data, `desc`->len);"} 64 | 65 | proc unrefEnv(envp: pointer) {.noinit, exportcpp: "unrefEnv".} = 66 | GC_unref(cast[RootRef](envp)) 67 | 68 | when not defined(release): 69 | type 70 | const_char {.importcpp: "const char", nodecl.} = object 71 | 72 | func assertHandler(expression: ptr[const_char], line: cint, sourceFile: ptr[const_char]): bool {.exportcpp: "nimAssertHandler".} = 73 | var cmsg : std_string 74 | {.emit: [cmsg, " = Notify::ptr()->get_assert_error_message();"].} 75 | raiseAssert(nimStringFromStdString(cmsg)) 76 | 77 | proc installAssertHandler() = 78 | {.emit: "Notify::ptr()->set_assert_handler(&nimAssertHandler);".} 79 | 80 | installAssertHandler() 81 | -------------------------------------------------------------------------------- /test.nim: -------------------------------------------------------------------------------- 1 | import direct/showbase 2 | import direct/task 3 | import direct/actor 4 | import direct/interval 5 | import panda3d/core 6 | import std/math 7 | 8 | var base = ShowBase() 9 | base.openDefaultWindow() 10 | base.disableMouse() 11 | 12 | var env = base.loader.loadModel("models/environment") 13 | env.reparentTo(base.render) 14 | env.setScale(0.25, 0.25, 0.25) 15 | env.setPos(-8, 42, 0) 16 | 17 | var pandaActor = Actor() 18 | pandaActor.loadModel("models/panda-model") 19 | pandaActor.loadAnims({"walk": "models/panda-walk4"}) 20 | pandaActor.setScale(0.005, 0.005, 0.005) 21 | pandaActor.reparentTo(render) 22 | pandaActor.loop("walk") 23 | 24 | # Create the four lerp intervals needed for the panda to 25 | # walk back and forth. 26 | var posInterval1 = pandaActor.posInterval(13, 27 | (0, -10, 0), 28 | startPos=(0, 10, 0)) 29 | var posInterval2 = pandaActor.posInterval(13, 30 | (0, 10, 0), 31 | startPos=(0, -10, 0)) 32 | var hprInterval1 = pandaActor.hprInterval(3, 33 | (180, 0, 0), 34 | startHpr=(0, 0, 0)) 35 | var hprInterval2 = pandaActor.hprInterval(3, 36 | (0, 0, 0), 37 | startHpr=(180, 0, 0)) 38 | 39 | # Create and play the sequence that coordinates the intervals. 40 | var pandaPace = Sequence(posInterval1, hprInterval1, 41 | posInterval2, hprInterval2, 42 | name="pandaPace") 43 | pandaPace.loop() 44 | 45 | proc spinCameraTask(task: Task): auto = 46 | var angleDegrees = task.time * 6.0 47 | var angleRadians = angleDegrees * (PI / 180.0) 48 | base.camera.setPos(20 * sin(angleRadians), -20 * cos(angleRadians), 3) 49 | base.camera.setHpr(angleDegrees, 0, 0) 50 | Task.cont 51 | 52 | base.taskMgr.add(spinCameraTask, "SpinCameraTask") 53 | 54 | base.run() 55 | --------------------------------------------------------------------------------