Official Solar System Tutorial Discussion

Hi Everyone, I was studying the Solar System tutorial, and I’m moving on to carousel, today, I think. I ran into a few type-o’s and stuff, and of course I had questions. So, I searched the forums and didn’t find an official place to discuss the Solar System tutorial. So, I decided to make one! :slight_smile: So, this is it! Please post questions and comments and hopefully answers! ^^

I noticed, in line 36 of Solar System Tut Part 2, a type-o. The line says:

    #Make the background color black (R=0, B=0, G=0)

When it probably should say:

    #Make the background color black (R=0, G=0, B=0)

So, Green and Blue are mixed up. ^^

I also noticed a type-o in the 6th tutorial a type-o on 81 and 82:

    #event "newYear" is not tied to a physical input device, but rather is
    #is sent by the function that rotates the Earth whenever a revolution

As you can see, there is a repeat word: “Is”.

Finally, another type-o exists on line 76 of the same tutorial (#6 of Solar System):

   #Each self.accept statement creates a event handler object that will call

Should say “an” rather than “a”. ^^

Well, that’s all for my nitpicking. In my next post I’ll add the two question that I had while reading the tutorials.

  1. When going through the solar system tutorials, I noticed that self.handleEarth on line 86 of Tutorial #6 became handleEarth(self) when defined on line 203. Is it typical to make such a change? It seems like it was changed out of necessity for syntax, but I’m surprised that handlEarth(self) is the def that we will use for self.handlEarth. I guess it just generated a lot of confusion. Can someone try to explain this?

  2. When I looked through Tutorial #6 I ran into line 72 and was confused as heck.

    self.simRunning = True          #boolean to keep track of the
                                    #state of the global simulation

What is a Boolean? As I recall from the graphical programs, it’s a way to cut out portions of 3d models. From my math classes it refers to and/or/not, etc. So, it seems like a very ambiguous term. I looked through the manual and reference material but didn’t find simRunning or sim. It seems like an unnecessary line, seeing as how each individual planet is coded to stop at a mouse click, and not with something like “if self.simRunning is true make it false”, or what-have-you.
Anyway, if I talk about it a lot I’ll make myself look foolish, because I don’t understand, it seems. I’m looking for a little more info or discussion about self.simRunning. Please help. :slight_smile:

This is python syntax. A method defined in a class needs to accept at least one argument which is the object instance. By convention this argument is called ‘self’. Line 86 is in the method init and if you look at its declaration there is also a self argument, so ‘self.handleEarth’ in the context of the init method calls the method handleEarth in the same class instance. When it’s called python automagically passes the object as the first argument to the handleEarth method.

You might also want to quickly run through Dive into Python to pick up some python basics, it might help with more python questions in later tutorials.

In graphics programs boolean probably refers to boolean algebra en.wikipedia.org/wiki/Boolean_algebra_(logic. In the script, the context is programming so it refers to boolean datatypes which is basically a fancy boffin way of saying a value that is only either True or False.

As for the proofreading of the tutorial scripts I think its a good extra level of polish for panda and would give a better first impression for panda beginners. I think drwr would happily include it if you put up a cleaned up version of the script files.

Hi ZeroByte, Thanks for replying to my inquiries. I’ve got to admit, it was tough for me to keep up, because I am an extreme beginner, but I did learn a lot. I especially appreciated the boolean thing. The only question that remains with me is, why use simRunning? It seems unnecessary. I guess I’ll pick it up eventually.
Anyway, I’m going to add to my signature that I’m not really an experienced beginner. But, the book you recommended looks great. I’m trying to start and finish Tom Gutschmidt’s Game Programming with Python, Ruby, and Lua tonight (just everything up through the Python section), then I want to read the Python tutorials from the website, because they were written by the guy who made Python. After that, I really want to look into the book you recommended, because it seems most advanced, ZeroByte. ^^ We should discuss that, also.
About uploading the spell checked versions, I am sort of a spelling junkie. I’ll put the entire set of edited tutorials up on my server in about a week or two, when I’m finished with them. I kind of go through them during the day and then read books at night.
Gosh, I read about half of a book on Python a few days ago, and it was terrible, because it didn’t touch on anything related to game design, and even though it was entitled “Python for the Non-Programmer”, it was obviously for progammers. The first thing they mentioned in Python was iteration, without definition. ^^

So anyway, just wanted to say thanks for all the help. Hope I see you in more topics, because you seem pretty nice and knowledgeable.

Peace

Hi all, I have been having trouble understanding this function

camera.setHpr ( 0, -90, 0 ) 

I understand that it changes the “pitch” angle, (if this is what it should be called), but…

First of all I do not understand why is it used, and why dont we just use

camera.setHpr ( 0, 0, 0 ) 

when i change it a little bit, the camera only shows a completely black screen, although I do see that the planets where positioned somewhere specific

I do not understand why if we use

[code]

camera.setHpr ( 0, -90, 0 )

it would show the same thing, but from the opposite side.

I did my own little project, where the earth rotates under its access, and the moon rotates around the earth, it doesnt seem to work properly, I suspect it is because of the -90, here is the complete code



import direct.directbase.DirectStart

from direct.gui.DirectGui import *

from panda3d.core import Vec3, Vec4

import sys



class World:

  def __init__(self):

    #This is the initialization we had before

	    self.title = OnscreenText(          #Create the title

	      text="Panda3D: Tutorial 1 - Solar System",

	      style=1, fg=(1,1,1,1), pos=(0.8,-0.95), scale = .07)

  

	    base.setBackgroundColor(0, 0, 0)    #Set the background to black

	    base.disableMouse()                 #disable mouse control of the camera

	    camera.setPos ( 0, 0, 90 )          #Set the camera position (X, Y, Z)

	    camera.setHpr ( 0, -90,0 )         #Set the camera orientation

		                                #(heading, pitch, roll) in degrees



	    #Here again is where we put our global variables. Added this time are

	    #variables to control the relative speeds of spinning and orbits in the

	    #simulation

	    self.yearscale = 60

	    self.dayscale = self.yearscale / 365.0 * 13	

	    #Number of seconds a full rotation of Earth around the sun should take

	    #Number of seconds a day rotation of Earth should take.

	    #It is scaled from its correct value for easier visability

	    self.orbitscale = 20                #Orbit scale

	    self.sizescale = 0.3                #Planet size scale



	    self.loadPlanets()                  #Load and position the models



	    #Finally, we call the rotatePlanets function which puts the planets,

	    #sun, and moon into motion.

	    self.rotatePlanets()



  def loadPlanets(self):

    #This is the same function that we completed in the previous step

    #It is unchanged in this version



    #Create the dummy nodes

    self.orbit_root_moon = render.attachNewNode('orbit_root_moon')





    ###############################################################



    #Load the sky

    #self.sky = loader.loadModel("models/solar_sky_sphere")

    #self.sky_tex = loader.loadTexture("models/stars_1k_tex.jpg")

    #self.sky.setTexture(self.sky_tex, 1)

    #self.sky.reparentTo(render)

    #self.sky.setScale(40)



   



    #Load Earth

    self.earth = loader.loadModel("mymodels/geosphere X.X")

    self.earth_tex = loader.loadTexture("mymodels/earth-map-huge.jpg")

    self.earth.setTexture(self.earth_tex, 1)

    self.earth.reparentTo(render)

    self.earth.setScale(self.sizescale)

    self.earth.setPos(0,0,0)

    self.earth.setP(-90)







    #Offest the moon dummy node so that it is positioned properly

    self.orbit_root_moon.setPos( self.orbitscale, 0, 0)



    #Load the moon

    self.moon = loader.loadModel("mymodels/geosphere X.X")

    self.moon_tex = loader.loadTexture("mymodels/moon map.jpg")

    self.moon.setTexture(self.moon_tex, 1)

    self.moon.reparentTo(self.orbit_root_moon)

    self.moon.setScale(0.4 * self.sizescale)

    self.moon.setPos(0.5 * self.orbitscale, 0, 0)

  #end loadPlanets()





   





  def rotatePlanets(self):

    #rotatePlanets creates intervals to actually use the hierarchy we created

    #to turn the sun, planets, and moon to give a rough representation of the

    #solar system. The next lesson will go into more depth on intervals.



 



    self.day_period_earth = self.earth.hprInterval(

       self.dayscale, Vec3(0,360,0))

	











    self.orbit_period_moon = self.orbit_root_moon.hprInterval(

      (.0749 * self.yearscale), Vec3(360, 0, 0))















    self.day_period_earth.loop()

    self.orbit_period_moon.loop()













  #end RotatePlanets()

#end class world



w = World()

run() 

you will ofcorse notice that this is a complete reck…
you can use the objects from the solar system sample instead of mine, as I made mine in 3d max and exported it in .x format

also notice that I did not use a back ground image

I am very sorry for being this unclear, but this is just how much I am confused, I hope someone helps me soon

Thank you for your time