require assistance

I am a student and is a beginner scripter learning to use panda3d, i have faced a few problems and requires some assistance about scripts on certain situations.

This is the main script

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from direct.task import Task
from direct.actor import Actor
import math, random, sys, os, math
from direct.showbase.DirectObject import DirectObject
from direct.interval.IntervalGlobal import *
from direct.gui.OnscreenImage import OnscreenImage

import Camera#class camera
import Environment

#figure the directory
MYDIR = os.path.abspath(sys.path[0])
MYDIR = Filename.fromOsSpecific(MYDIR).getFullpath()

class World(DirectObject):
def init(self):

    self.accept("enter",self.startGame)
    
    #start screen
    self.imageObject = OnscreenImage ( image = "StartScreen.jpeg",
                                      pos = (0,0,0),
                                      scale = (800/600.0,1,1)
                                      
    

def UpdateWorld(task): 
    #update all objects in World-----------------Camera
    Camera.cam.UpdateCamera()
    return Task.cont
        


taskMgr.add(UpdateWorld, "UpdateWorldTask")

def startGame(self):
    self.imageObject.destroy()

#dlight = DirectionalLight(‘dlight’)
#dlnp = render.attachNewNode(dlight.upcastToPandaNode())
#render.setLight(dlnp)

alight = AmbientLight(‘alight’)
alight.setColor(VBase4(0.4, 0.4, 0.4, 1))
alnp = render.attachNewNode(alight.upcastToPandaNode())
render.setLight(alnp)

dlight = DirectionalLight(‘dlight’)
dlight.setColor(VBase4(0.4, 0.4, 0.4, 1))
dlnp = render.attachNewNode(dlight.upcastToPandaNode())
dlnp.setHpr(0, -60, 0)
render.setLight(dlnp)

#fog
myFog = Fog(“Fog”)
myFog.setColor(0.2,0.5,0.7)
myFog.setExpDensity(0.01)
render.setFog(myFog)

w=World()
run()

the class camera script

#Camera Class
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
from direct.actor import Actor
from direct.interval.IntervalGlobal import *
import math,sys,os,random

class Camera(DirectObject):
def init(self):
self.userControlled= 1
self.prevMouseX= 0
self.deltaX=0
self.xpos=0
self.ypos=0
self.zpos=0
self.zrot=0
self.xrot=0

    self.accept('w-repeat', self.goForward)
    self.accept('s-repeat', self.goBackward)
    self.accept('w', self.goForward)
    self.accept('s', self.goBackward)
    self.accept('a-repeat', self.rotateLeft)
    self.accept('d-repeat',self.rotateRight)
    self.accept('a', self.rotateLeft)
    self.accept('d', self.rotateRight)
    self.accept('arrow_up-repeat', self.tiltDown)
    self.accept('arrow_down-repeat', self.tiltUp)
    self.accept('arrow_up', self.tiltDown)
    self.accept('arrow_down', self.tiltUp)
    #self.accept('u-repeat', self.goUp)
    #self.accept('d-repeat', self.goDown)
    #self.accept('u', self.goUp)
    #self.accept('d', self.goDown)
    #end of init
    
def UpdateCamera(self):
    #ise mouse horizontal movement
    #if base.mouseWatcherNode.hasMouse():
    #    x= base.mouseWatcherNode.getMouseX()
    #    self.deltaX= x-self.prevMouseX
    #    self.prevMouseX=x
    #    if self.deltaX>0:
    #        self.rotateRight()
    #    else:
    #        if self.deltaX<0:
    #                self.rotateLeft()
                            
    base.camera.setPos(self.xpos, self.ypos, self.zpos)
    base.camera.setHpr(self.zrot, self.xrot,0)

def goForward(self):
    if self.userControlled==1:
        angleradians= self.zrot*(math.pi/180)
        deltaX=0.5*math.sin(angleradians)
        deltaY= -0.5*math.cos(angleradians)
            
        self.xpos-=deltaX
        self.ypos-=deltaY
            
def goBackward(self):
    if self.userControlled==1:
        angleradians= self.zrot*(math.pi/180)
        deltaX=0.5*math.sin(angleradians)
        deltaY= -0.5*math.cos(angleradians)
            
        self.xpos+=deltaX
        self.ypos+=deltaY
            
def rotateLeft(self):
    self.zrot+=2
    
def rotateRight(self):
    self.zrot-=2

def tiltUp(self):
    self.xrot+=2
    
def tiltDown(self):
    self.xrot-=2

def goUp(self):
    self.zpos+=0.5
    
def goDown(self):
    self.zpos-=0.5

cam = Camera()

The problems

  1. Textures files are not loading from the same directory(It is using the same directory during the export to egg file)
  2. Camera is not working as if it is not loaded
  3. Start screen is not loading (the script comes out error on the “def UpdateWorld” too)

Things that require more scripts

  1. A collision between camera and an object that enable a talk scene when camera is facing the object and when play hit the mouse left click
  2. A starting cinematic followed by a loading screen then to the start screen.(the cinematic can be skipped by pressing any button)
  3. An event to open another python file when the camera reach a location in the scene.(instancing into another scene)
  4. If possible i would like an API documentation of panda3d

Thanks.

for the camera thing… you basically created a function with nothing in it… . at least add something like “return”. … or you added something but your indentation(i’m pretty sure this word is wrong) is messed up. you might wannt to use the {code] " yourcode {/code] … and subtitude the {with an [

the texture loading might be due to absolute-path-names in your *.egg file. since egg files are human readable it should be easy to correct the absolute to relative path.

for your additional things.->1. check the picker example for clicking on objects and interact with them.

  1. cinematic is sorta tricky. i think its beeing rewritten or its already done at some parts. guess this would make use of the animated texture. see manual or animated texture-example.

hm. for point 3… you could just remove all nodes from render. and create an instanve of a class like you did with the camera which loads your new objects and everything and reparents it to render.

point4 is easy. right on this webside. check Documentation->manual/the other 3 entries.
it pretty much lists everything inside panda.

Is there an example where i can do that? I’m a little lost on what should i do about it.