Hi, im currently working on a project in which i simulate planets orbits. I have not got very far as of yet. Spent several hours getting the maths together and got down to coding yesterday. An error was thrown up and i have spent hours both yesterday and today trying to figure out what is wrong. I am more a mathematician than a programmer, so it could be some stupid mistake like syntax.
Here is the code:
import direct.directbase.DirectStart from direct.showbase import DirectObject from panda3d.core import TextNode, Vec3, Vec4 from direct.interval.IntervalGlobal import * from direct.gui.DirectGui import * from direct.showbase.DirectObject import DirectObject import sys class mass(DirectObject): def __init__(self): base.setBackgroundColor(0, 0, 0) camera.setPos ( 0, 10, 0 ) camera.setHpr ( 0, -90, 0 ) def createMass(self, name, mass, posX, posY, posZ, velX, velY, velZ): self.name = name self.mass = mass self.posX = posX self.posY = posY self.posZ = posZ self.velX = velX self.velY = velY self.velZ = velZ def scaleRenderTexture(self, scale, tex): self = loader.loadModel("models/sphere") self.reparentTo(render) texture = loader.loadTexture("models/" + tex) self.setTexture(texture, 1) self.setPos(self.posX, self.posY, self.posZ) self.scale(scale) def calcNextPos(self, x, v, a, dt): return x + v*dt + 0.5*a*dt^2 def calcNextVel(self, v, a, a2, dt): return v + 0.5*(a2+a)*dt def calcA(self, m, a, b): posA = getpos(a) posB = getpos(b) r = posA - posB return (G*m)/(r^2) class sun(mass): def __init__(self): self.createMass('Sun', 100, 0, 0, 0, 0, 0, 0) self.scaleRenderTexture(10, 'sun.jpg') class earth(mass): def __init__(self): earth.createMass('Earth', 1, 20, 0, 0, 0, 0, 0) earth.scaleRenderTexture(1, 'earth.jpg') sun = sun() earth = earth() run()
The error that i get is:
Any help people can offer would be much appreciated.