How do you disable rendering output?

I want to write a server for a game that does all the work of object interactions but does not display stuff. The positions are then sent to the client and it does the display. A standard game Server/client rig, right?

How do you disable rendering output for the server side?


I searched 6 times for that and very found it!

I did this with roaming ralph. It does not work unless you remove all the statements that have the word base in them. I assume this is because base is not loaded do to this command.

My question is can ralph be rewritten in a way that the base statements are not needed? I was thinking that having a server where you can turn on viewing is a good thing for debugging. If it can only be done with the removal of these statements, a lot of ifs could be added to take them out with a constant.

Any insights that you have would be wonderful.

Actually, “base” commands should work fine. Since “run” is also part of base, you won’t be able to run the program at all without ShowBase.
“base” should be imported right when you import DirectStart – if not, then there’s something wrong.

All I can say to that is that the program is just the standard roaming ralph running on Linux 64 bit kubuntu. I have not changed anything.
Please try it and let me know what you find.

Well, please show us some code. You probably forgot to import DirectStart or so.

# Author: Ryan Myers
# Models: Jeff Styers, Reagan Heller

# Last Updated: 6/13/2005
# This tutorial provides an example of creating a character
# and having it walk around on uneven terrain, as well
# as implementing a fully rotatable camera.

from pandac.PandaModules import loadPrcFileData # turn off graphics
loadPrcFileData("", "window-type none") # turn off graphics

import direct.directbase.DirectStart
from pandac.PandaModules import CollisionTraverser,CollisionNode
from pandac.PandaModules import CollisionHandlerQueue,CollisionRay
from pandac.PandaModules import Filename
from pandac.PandaModules import PandaNode,NodePath,Camera,TextNode
from pandac.PandaModules import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from import Actor
from direct.task.Task import Task
from direct.showbase.DirectObject import DirectObject
import random, sys, os, math
import readNumPad

SPEED = 0.5

# Figure out what directory this program is in.

# Function to put instructions on the screen.
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1),
            pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1),
                    pos=(1.3,-0.95), align=TextNode.ARight, scale = .07)

class World(DirectObject):

    def __init__(self):

        self.keyMap = {"left":0, "right":0, "forward":0, "cam-left":0, "cam-right":0},0,0,1))

        # Post the instructions

        self.title = addTitle("Panda3D Tutorial: Roaming Ralph (Walking on Uneven Terrain)")
        self.inst1 = addInstructions(0.95, "[ESC]: Quit")
        self.inst2 = addInstructions(0.90, "[Left Arrow]: Rotate Ralph Left")
        self.inst3 = addInstructions(0.85, "[Right Arrow]: Rotate Ralph Right")
        self.inst4 = addInstructions(0.80, "[Up Arrow]: Run Ralph Forward")
        self.inst6 = addInstructions(0.70, "[A]: Rotate Camera Left")
        self.inst7 = addInstructions(0.65, "[S]: Rotate Camera Right")

        # Set up the environment
        # This environment model contains collision meshes.  If you look
    # in the egg file, you will see the following:
    #    <Collide> { Polyset keep descend }
    # This tag causes the following mesh to be converted to a collision
    # mesh -- a mesh which is optimized for collision, not rendering.
    # It also keeps the original mesh, so there are now two copies ---
    # one optimized for rendering, one for collisions.

        self.environ = loader.loadModel("models/world")

        # Create the main character, Ralph

        ralphStartPos = self.environ.find("**/start_point").getPos()
        self.ralph = Actor("models/ralph",

        # Create a floater object.  We use the "floater" as a temporary
        # variable in a variety of calculations.

        self.floater = NodePath(PandaNode("floater"))

        # Accept the control keys for movement and rotation
        h = readNumPad.ReadNumPad(.4, .6, .6)
        self.accept("escape", sys.exit)
        self.accept("44", self.setKey, ["left",1])
        self.accept("66", self.setKey, ["right",1])
        self.accept("8", self.setKey, ["forward",1])
        self.accept("666", self.setKey, ["cam-left",1])
        self.accept("444", self.setKey, ["cam-right",1])
        self.accept("44-up", self.setKey, ["left",0])
        self.accept("66-up", self.setKey, ["right",0])
        self.accept("8-up", self.setKey, ["forward",0])
        self.accept("666-up", self.setKey, ["cam-left",0])
        self.accept("444-up", self.setKey, ["cam-right",0])


        # Game state variables
        self.prevtime = 0
        self.isMoving = False

        # Set up the camera


        # We will detect the height of the terrain by creating a collision
        # ray and casting it downward toward the terrain.  One ray will
        # start above ralph's head, and the other will start above the camera.
        # A ray may hit the terrain, or it may hit a rock or a tree.  If it
        # hits the terrain, we can detect the height.  If it hits anything
        # else, we rule that the move is illegal.

        self.cTrav = CollisionTraverser()

        self.ralphGroundRay = CollisionRay()
        self.ralphGroundCol = CollisionNode('ralphRay')
        self.ralphGroundColNp = self.ralph.attachNewNode(self.ralphGroundCol)
        self.ralphGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.ralphGroundColNp, self.ralphGroundHandler)

        self.camGroundRay = CollisionRay()
        self.camGroundCol = CollisionNode('camRay')
        self.camGroundColNp =
        self.camGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.camGroundColNp, self.camGroundHandler)

        # Uncomment this line to see the collision rays

        #Uncomment this line to show a visual representation of the
        #collisions occuring

    #Records the state of the arrow keys
    def setKey(self, key, value):
        print "setKey", key, value
        self.keyMap[key] = value

    # Accepts arrow keys to move either the player or the menu cursor,
    # Also deals with grid checking and collision detection
    def move(self, task):

        elapsed = task.time - self.prevtime

        # If the camera-left key is pressed, move camera left.
        # If the camera-right key is pressed, move camera right.
        camright =
        if (self.keyMap["cam-left"]!=0):
   - camright*(elapsed*20))
        if (self.keyMap["cam-right"]!=0):
   + camright*(elapsed*20))

        # save ralph's initial position so that we can restore it,
        # in case he falls off the map or runs into something.

        startpos = self.ralph.getPos()

        # If a move-key is pressed, move ralph in the specified direction.

        if (self.keyMap["left"]!=0):
            self.ralph.setH(self.ralph.getH() + elapsed*300)
        if (self.keyMap["right"]!=0):
            self.ralph.setH(self.ralph.getH() - elapsed*300)
        if (self.keyMap["forward"]!=0):
            backward = self.ralph.getNetTransform().getMat().getRow3(1)
            self.ralph.setPos(self.ralph.getPos() - backward*(elapsed*5))

        # If ralph is moving, loop the run animation.
        # If he is standing still, stop the animation.

        if (self.keyMap["forward"]!=0) or (self.keyMap["left"]!=0) or (self.keyMap["right"]!=0):
            if self.isMoving is False:
                self.isMoving = True
            if self.isMoving:
                self.isMoving = False

        # If the camera is too far from ralph, move it closer.
        # If the camera is too close to ralph, move it farther.

        camvec = self.ralph.getPos() -
        camdist = camvec.length()
        if (camdist > 10.0):
   + camvec*(camdist-10))
            camdist = 10.0
        if (camdist < 5.0):
   - camvec*(5-camdist))
            camdist = 5.0

        # Now check for collisions.


        # Adjust ralph's Z coordinate.  If ralph's ray hit terrain,
        # update his Z. If it hit anything else, or didn't hit anything, put
        # him back where he was last frame.

        entries = []
        for i in range(self.ralphGroundHandler.getNumEntries()):
            entry = self.ralphGroundHandler.getEntry(i)
        entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
        if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):

        # Keep the camera at one foot above the terrain,
        # or two feet above ralph, whichever is greater.

        entries = []
        for i in range(self.camGroundHandler.getNumEntries()):
            entry = self.camGroundHandler.getEntry(i)
        entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
        if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
        if ( < self.ralph.getZ() + 2.0):
   + 2.0)

        # The camera should look in ralph's direction,
        # but it should also try to stay horizontal, so look at
        # a floater which hovers above ralph's head.

        self.floater.setZ(self.ralph.getZ() + 2.0)

        # Store the task time and continue.
        self.prevtime = task.time
        return Task.cont

w = World()

The import of readnumpad is this code.
Thanks again.

Hmm, the problem is probably that readNumPad itself imports DirectStart and calls run(), and so you end up importing it twice. Instead, remove the DirectStart import line and run() line from

Also, why do you want to read numpad input anyways, without a window?

I had the run commented out on my copy. I just commented out the DirectStart in rumpad but the same error. Pasted it to the bottom.

The reason I did this little test was to see how much faster Roaming Ralph ran without being rendered. I was running to copies, one rendered and one not. I wanted them to be the same. Also I am doing tests before I write my server. I might want to turn on the window of the server and move a camera around for debugging or something. I am very new to writing servers.

DirectStart: Starting the game.
Warning: DirectNotify: category ‘Interval’ already exists
:audio(error): LoadLibrary() failed, will use NullAudioManager
:audio(error): No error.
:util(warning): Adjusting global clock’s real time by 0.187404 seconds.
Traceback (most recent call last):
File “”, line 270, in
w = World()
File “”, line 47, in init,0,0,1))
AttributeError: ‘NoneType’ object has no attribute ‘setClearColor’ is the pointer to your window. If you don’t create a window, will be None. This shouldn’t really be a surprise. :slight_smile:

There are lots and lots of elements of base which are still valid if you don’t create a window, but is certainly not one of them. There are probably a few others, too, like and whatnot, which Roaming Ralph is no doubt trying to directly manipulate.

Just because a graphical program like Roaming Ralph is written to assume it has a valid window, doesn’t mean that you can’t write your own server program without a window. But you probably won’t be able to take any of the demo programs and just run them with “window-type none”.


I run “window-type none” on my servers and they all are running great.

I am a bit lost with these answers.
What does windo-type none really do?
Why does base not exist? (This does make sense to me but then how does treeforms server work without it? Treeform can you view what your server is doing with the server? Did you write the server just using collision info or what?
Thanks for all the help and any advice you can give.

window-type none actually makes sure no window will appear.
“base” exists, although “” doesn’t (is None), because without a window there’s no, eh?