Panda3D Manual: Start Guide For The Absolute Beginner
<<prev | top | next>> |
## Installing Panda3D and Creating A New Folder 1. First, go to the Downloads section and download the latest version of Panda3D (as of writing this is version 1.2.2). For Windows users download panda3d-1.2.2.exe. 2. When the download has finished, double-click the Panda3D icon to begin the installation process. 3. When finished, make sure that Panda3D has been successfully installed by running the ‘Panda Greeting Card’ program (if it does not run automatically when the installation finishes, click Start > All Programs > Panda3D 1.2.2 > Panda Greeting Card). 4. Now, a very important thing to note, Panda3D is a development tool; NOT an application. What does this mean? It means, that unlike all the other programs on your computer, you won’t find any program icons or shortcuts to start it. To run Panda3D you must write a python script which tells it what to do (this is a great way to learn programming, because you’re basically starting from the ground up). 5. So, you now need to create a place where you can save all your scripts. Panda3D is very clever, it can run a script from anywhere on your computer, but it looks for models and other assets in the folder that it is run from. If those assets aren’t present, then you’ll get an error message when you try to run it. So, I believe that the easiest thing for the beginner to do, is to make a new folder in the main Panda3D directory itself (which already contains all the models and other assets that you’ll need). 6. To do this, click your computers ‘Start’ button, then ‘My Computer’. Then double-click ‘Local Disk (C)’ (if the contents of this drive are hidden, just click ‘Show the contents of this folder’). Now find the Panda3D-1.2.2 folder and double-click on it to open it. 7. On the top menu bar click ‘File > New > Folder’. This will create a new folder in the Panda3D directory, backspace out the name and type a new name for it (I called mine mystuff). Good! You’re almost ready to begin. Missing image Pic021ey.jpg Image:pic021ey.jpg ## Writing Your First Script ### Download a Python Editor One of python’s strong points, is that you don’t need a fancy or expensive compiler to write your scripts. Python scripts can be written in a simple text editor such as ‘Notepad’ (which is already installed on all Windows computers). However, because Notepad isn’t really designed for writing scripts, it will make learning to program much, much harder. So, I think the best thing you can do, is to use a proper python editor. I use PyPE (which is completely free and makes writing python scripts a whole lot easier) here's the link: http://sourceforge.net/projects/pype/ If you're using Windows, download the PyPE 2.4-win-anzi.zip (as of writing this was the latest version). You don't need to install this program, you just download and unzip it somewhere, then open the unzipped folder and double-click on the PyPE icon to run it (or right-click on the icon and send it to the desktop as a shortcut, then simply run it by double-clicking the icon on your desktop). ### Write the script 1. Open PyPE, then click ‘File > New’ on the top menu bar to open a new work environment. 2. Now type the following code (or just copy and paste it):
import direct.directbase.DirectStart run()
(Notice that PyPE automatically highlights certain words and numbers the lines for you. This is a very nice feature which makes finding errors much easier Very Happy). 3. Well done! You’ve just written your first Panda3D script Very Happy. It’s not much, but those few lines of code tell Panda3D to start. But before you can run this script, you must save it. So click ‘File > Save As’ on the top menu bar and a new window should open. 4. At the top of this new window there is a ‘Save in:’ text box, which is pointing to ‘PyPE-2.4-win-ansi’, you DON’T want to save your script there, so click the little down arrow beside the text box, then scroll down the list and click ‘Local Disk (C)’, then double-click on the ‘Panda3D-1.2.2’ folder to open it. 5. Find the ‘mystuff’ folder that we created earlier and double-click on it to open it. 6. Good! Now type a name for your script in the ‘File name:’ text box. I called mine myscript.py (make sure you put .py on the end of the name). Then click the ‘Save’ button. 7. Very good! You can now close PyPE. ### Running Your Script and Starting Panda3D 1. You now run your script by using your computer’s ‘Command Prompt’. You access this by clicking ‘Start > All Programs > Accessories > Command Prompt’. When it opens, it should look something like this: 2. At the moment it’s pointing to its default directory, which in my case is ‘Documents and Settings’ (it doesn’t matter if yours is different). We need to change the directory to the one where we saved our script. To do this, we type cd. This stands for ‘change directory’. So type the following text behind the > symbol. cd C:\Panda3D-1.2.2\mystuff\ Please note that it’s case sensitive and must match exactly. Then press the ‘Enter’ key on your keyboard. You should now have the following on the Command Prompt: 3. Good! This means that it’s now pointing to the right directory. To run your script, and start Panda3D, type the following text behind the > symbol: ppython myscript.py Make sure you type ppython (the extra ‘p’ tells it to use the special Panda3D version of python and not just the regular version of python). 4. Now press the ‘Enter’ key on your keyboard. If all is well, Panda3D will start and you should see the main rendering window appear. This is a empty program it won't do anything. Now you hopefully understand how to write a panda programm
<<prev | top | next>> |