|
|
|
Return to Code Snippets
by MMichaud » Wed Mar 10, 2010 1:27 pm
I dont think I am explaining my troubles correctly. I'm not a n00b when it comes to programming. I have know Python for 3 years now and know Java pretty extensively too. I'm only new to the 3D scene. I dont know how to edit the model files so that they are collision-able.
"heartCollider = heartModel.find("**/collider_heart")"
where is it looking for "**/collider_heart"? How do I give my models a "**/collider_heart" (obviously without the "heart")?
If it isn't broken, it doesn't have enough features.
-
MMichaud
-
- Posts: 15
- Joined: Sat Feb 27, 2010 11:26 am
- Location: Cheshire High School
by astelix » Wed Mar 10, 2010 4:27 pm
MMichaud wrote:I dont think I am explaining my troubles correctly. I'm not a n00b when it comes to programming. I have know Python for 3 years now and know Java pretty extensively too. I'm only new to the 3D scene. I dont know how to edit the model files so that they are collision-able.
"heartCollider = heartModel.find("**/collider_heart")"
where is it looking for "**/collider_heart"? How do I give my models a "**/collider_heart" (obviously without the "heart")?
no fear that when you said "newbie" I got indeed you're just a panda3D newbie, not a newbie in everything  Anyhow, not getting what you're asking for reveals you haven't read or got the infos I provided in the models.blend file in the beginners package that cite: ================= Settling the colliders The logic view is the place where to 'tag' a mesh as collider, so select the heart collider 'collider_heart' from the outliner below and then select the logic panel to the lower left: you'll see a property named 'Collide' with a string value of 'Sphere descend' - this is the way to make the panda3D loder know that this is a sphere-shaped collider. Look into the panda3D manual for more infos and to know how many other shapes [are] available.
so now I'm asking you: did you opened the models.blend file and read that? And if yes, what it is not clear to you there, so that I try to make it clear the better?
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by MMichaud » Wed Mar 10, 2010 6:14 pm
I did not open models.blend. How did you make the sphere in Blender?
Other than that last question I think I understand everything now. That was really the last piece of the puzzle. Thank you so much for you help I really appreciate it.
If it isn't broken, it doesn't have enough features.
-
MMichaud
-
- Posts: 15
- Joined: Sat Feb 27, 2010 11:26 am
- Location: Cheshire High School
by astelix » Thu Mar 11, 2010 2:33 am
MMichaud wrote:I did not open models.blend. How did you make the sphere in Blender?
can't help you out here fella, by lack of time - here you're on you own - I assumed Blender knowledge in this tutorial so you gotta check the blender documentation on Blender's website I guess. Keep up
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by MMichaud » Thu Mar 11, 2010 9:23 pm
Well I know how to make spheres, I'm not a moron. But how do you specify a certain object to being for collision purposes?
If it isn't broken, it doesn't have enough features.
-
MMichaud
-
- Posts: 15
- Joined: Sat Feb 27, 2010 11:26 am
- Location: Cheshire High School
by astelix » Fri Mar 12, 2010 4:06 am
MMichaud wrote:Well I know how to make spheres, I'm not a moron. But how do you specify a certain object to being for collision purposes?
why do you assume I'm offending ppl like that? I'm here trying to help you not to making you see as a moron, but you are doing no effort to look otherwise. If you inquire me with: I did not open models.blend. How did you make the sphere in Blender?
what do you think I understand off that sentence? Then you said: But how do you specify a certain object to being for collision purposes?
I already pointed you above. Can't see how to be more clear than that. The last suggestion I can do above this topic is to read again more carefully the beginner step1.py and to look again inside the models.blend file with the same care and you'll certainly succeed.
good luck
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by Anon » Fri Mar 12, 2010 5:23 am
MMichaud wrote:Well I know how to make spheres
... MMichaud wrote:How did you make the sphere in Blender?
Did you by any chance mean how to make a COLLISION sphere? Because what you wrote was a bit confusing. MMichaud wrote:I did not open models.blend.
You should have, the text in the Text Editor view explained what you wanted. Basically, 1. select your object (the sphere) 2. go to the Logic Panel (from Buttons Window):  3.  If you want to set your object to be exported as a panda collision object, youll need to Add Property ,change the Types to String ,write 'Collide' as the name and on the left window from the Name window, add the parameters. I think you can change their order but write them separeted with spaces (no commas). 'Sphere' parameter tells the chicken exporter to export it as a sphere collision geometry, dont remember what 'descend' does , but the chicken manual found in the chicken archive explains that: To append an object type or a tag to your object, simply go into the logic panel and use the Add Property button. A string property with the name ObjectType will be exported as the object type (which is shorthand notation for any egg syntax; the defaults are defined in your Confauto.prc file but you can define new ones if you like). A typical usage of this might be an ObjectType of barrier to export collision geometry. Alternativly a string property with the name Collide will be exported as a collide tag in the egg file, so an alternative to setting the ObjectType to barrier is to have a Collide tag with Polyset. Keep, Descend etc. can of course be used. Any other property will be exported as a normal Panda tag.
...okay, maybe it doesnt?...
The html doc can be found in bpydata/chicken/doc.html
-
Anon
-
- Posts: 1556
- Joined: Thu Oct 29, 2009 3:07 am
by drozzy » Fri Mar 12, 2010 11:53 pm
Haha! I found more resources! Great stuff. Should keep me busy for a while...
MMichaud wrote:Well I know how to make spheres, I'm not a moron. But how do you specify a certain object to being for collision purposes?
I think you should show more respect here. Otherwise you won't get any questions answered.
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by MMichaud » Sat Mar 13, 2010 12:12 am
I apologize for sounding disrespectful. I highly revere this dude, he has helped me more than I can say. I think I'm good for now. Thank you again for your help, you're a saint.
If it isn't broken, it doesn't have enough features.
-
MMichaud
-
- Posts: 15
- Joined: Sat Feb 27, 2010 11:26 am
- Location: Cheshire High School
by astelix » Sat Mar 13, 2010 4:55 am
MMichaud wrote:Thank you again for your help, you're a saint.
 haha that's what my woman say every time she made something that needs to be forgiven, but that's not your case MMichaud and you never sounded disrespectful to me. Just a little lazy to read manuals and comments, a very used habit by coders, especially young ones (like I was) - that's what I tried to point you out so far.
keep up dude 
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Sat Mar 13, 2010 12:42 pm
I have a question:
How come you don't set any INTO or FROM flags in step0.py tutorial?
Is it because all objects are automatically assumed to be INTO, unless they are added to CollisionTraverser?
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by drozzy » Sat Mar 13, 2010 12:59 pm
Also I have a question, why is it that I get "name base is not defined" error if I do my imports like this:
- Code: Select all
import snipstuff import direct.directbase.DirectStart
but it works if I do them the other way? - Code: Select all
import direct.directbase.DirectStart import snipstuff
EDIT: I think I figured this one out... DirectStart initializes a whole bunch of global variables (including base), and snipstuff accesses base - so it has to be imported after DirectStart.
Last edited by drozzy on Sat Mar 13, 2010 3:25 pm, edited 1 time in total.
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by drozzy » Sat Mar 13, 2010 3:23 pm
Also, in the traverseTask function, why do you need a for loop, it never runs more than one iteration:
- Code: Select all
def traverseTask(task=None): # as soon as a collison is detected, the collision queue handler will contain all the objects taking part in the collison for i in range(collisionHandler.getNumEntries()): # we'll turn on the lights, to visually show this happy event snipstuff.dlight.setColor((.5, .5, .5, 1)) snipstuff.info_message("Smiley is now touching Frowney!") if task: return task.cont
# If there are no collisions the collision queue will be empty so the program flow arrives here and we'll shut down the lights and clear the text message snipstuff.dlight.setColor((.0, .1, .0, 1)) snipstuff.info_message("") if task: return task.cont
Can't we just replace it with this?: - Code: Select all
def traverseTask(task=None): if collisionHandler.getNumEntries() > 0: snipstuff.dlight.setColor((.5, .5, .5, 1)) snipstuff.info_message("Smiley is now touching Frowney!") else: snipstuff.dlight.setColor((.0, .1, .0, 1)) snipstuff.info_message("")
if task: return task.cont
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Sat Mar 13, 2010 4:56 pm
yo, cool down you submerged me with questions!
one thing at a time:
drozzy wrote: How come you don't set any INTO or FROM flags in step0.py tutorial? Is it because all objects are automatically assumed to be INTO, unless they are added to CollisionTraverser?
It is all wrote - citing line 50:
- Code: Select all
# ...and then we add it to the panda collision routines telling also that this is handled by the collision handler defined above. Afte issued this command the smiley become a true FROM collider object. base.cTrav.addCollider(smileyCollider, collisionHandler)
and this is line 53: - Code: Select all
#** This is the frowney model that will intereact with the smiley - it is shaped and settled exactly as smiley so there isn't much to say here, other than this time we won't add this object to the main traverser because we wanna assign to him just a INTO role.
I find not hard to admit my English is not awesome but: is it so bad or rather you guys really do not read what I wrote there?
About the second post yes you figured that alone correctly.
The third answer is obviously yes, but it is true just for that situation and that solution is off the logic of that routine. However you found indeed a piece of code screwed I must fix even if works right now, because may confuse ppl. To see a better CollisionHandlerQueue sample jump to step3.py
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Sat Mar 13, 2010 5:42 pm
Thanks for responses!
astelix wrote:It is all wrote - citing line 50: - Code: Select all
# ...and then we add it to the panda collision routines telling also that this is handled by the collision handler defined above. Afte issued this command the smiley become a true FROM collider object. base.cTrav.addCollider(smileyCollider, collisionHandler)
and this is line 53: - Code: Select all
#** This is the frowney model that will intereact with the smiley - it is shaped and settled exactly as smiley so there isn't much to say here, other than this time we won't add this object to the main traverser because we wanna assign to him just a INTO role.
I find not hard to admit my English is not awesome but: is it so bad or rather you guys really do not read what I wrote there?
I guess the words "true FROM collider" confused me. I guess something like this would've been more clear: - Code: Select all
# ...and then we add it to the panda collision routines telling also that this is handled by the collision handler defined above. After this command the smiley becomes a FROM collider object.
and: Code: - Code: Select all
#** This is the frowney model that will intereact with the smiley - it is shaped and settled exactly as smiley so there isn't much to say here, other than this time we won't add this object to the main traverser. This makes him an INTO object.
It's just I was expecting you to set some kind of BIT masks here (like in some panda sample tutorials). But now I am more clear - all objects are INTO objects by default, and if you adding them as colliders, they also become FROM objects.
Thanks!
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Sun Mar 14, 2010 2:32 am
drozzy wrote:Thanks for responses!
you're welcome drozzy wrote:I guess the words "true FROM collider" confused me. I guess something like this would've been more clear...
suggestion taken and snippet fixed - keep pointing kinda discrepancies if you'll find others (I bet you will  ) drozzy wrote:It's just I was expecting you to set some kind of BIT masks here
you'll find bitmasks in following steps - go ahead, you passed the novice levels bigtime 
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Sun Mar 14, 2010 10:04 pm
Well I'm on step5 of beginner and absolutely love it.
I can actually write collision from scratch now and understand how it works (more or LESS!)
Another minor point: Took me a while to figure out what "ASA" means. I assume it's "as soon as"?
Maybe global find-and-replace of ASA with explicit wording will be nicer
Also I have a bone to pick with you over something completely silly! In the tutorial step4.py you say that you "slim" the code by pointing both accept calls to the same function:
- Code: Select all
def collideEventIn(entry): colliderNode = entry.getIntoNode() if colliderNode.getName() == 'smileycnode': smileyModel.setColor(1,1,1,1) heartModel.setScale(1.5) elif colliderNode.getName() == 'frowneycnode': frowneyModel.setColor(1,1,1,1) brkheartModel.setScale(1.5) #... and this when they leave each other alone. def collideEventOut(entry): colliderNode = entry.getIntoNode() if colliderNode.getName() == 'smileycnode': smileyModel.setColor(.4,.4,.4,1) heartModel.setScale(1.0) elif colliderNode.getName() == 'frowneycnode': frowneyModel.setColor(.4,.4,.4,1) brkheartModel.setScale(1.0)
However, when I did it myself, I pointed it to different functions and I had less lines of code  - Code: Select all
def heartCollisionEnter(event): smileyModel.setColor(1,1,1,1) heartModel.setScale(1.5) def heartCollisionLeave(event): smileyModel.setColor(1,1,1,1) heartModel.setScale(1.5) def brokenHeartCollisionEnter(event): smileyModel.setColor(1,1,1,1) heartModel.setScale(1.5) def brokenHeartCollisionLeave(event): smileyModel.setColor(1,1,1,1) heartModel.setScale(1.5)
(Ignore the actual parameters).
But I think you should keep it pointing to the same function - because I actually didn't know that you could do that. Maybe just remove the claim that it's "to slim the code".
Then again, this is really stupid thing, and I probably just need to sleeps more...
Thanks again for the tutorial.
Can't believe this is not sticky!
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Mon Mar 15, 2010 3:36 am
drozzy wrote:Another minor point: Took me a while to figure out what "ASA" means. I assume it's "as soon as"? Maybe global find-and-replace of ASA with explicit wording will be nicer
that was put on purpose to keep your brain awake and working  drozzy wrote:Also I have a bone to pick with you over something completely silly! In the tutorial step4.py you say that you "slim" the code by pointing both accept calls to the same function:
But I think you should keep it pointing to the same function - because I actually didn't know that you could do that. Maybe just remove the claim that it's "to slim the code".
Then again, this is really stupid thing, and I probably just need to sleeps more...
no that is neither silly nor stupid - seems you're not the only one in need of more rest: you indeed catch another glitch and now it is fixed - I suggest you to download again the beginner package and see step4.py how looks now for you. drozzy wrote:Can't believe this is not sticky!
well I appreciate your endorsement but I guess as long as we keep finding these inconsistencies is better avoid it
keep up dude
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by MMichaud » Mon Mar 15, 2010 7:45 am
Just as a suggestion: Maybe you should put some note in the documentation that says that models.blend has info about setting up the models so that they can be collision-able. I think that will help to point other super noobs in the right direction.
If it isn't broken, it doesn't have enough features.
-
MMichaud
-
- Posts: 15
- Joined: Sat Feb 27, 2010 11:26 am
- Location: Cheshire High School
by drozzy » Mon Mar 15, 2010 7:57 am
I think that's all in the tutorials. He says you should go dig around in models.blend file to understand how to setup your models correctly.
At least I figured it out
I guess you just can't rush and have to read everything.
MMichaud wrote:Just as a suggestion: Maybe you should put some note in the documentation that says that models.blend has info about setting up the models so that they can be collision-able. I think that will help to point other super noobs in the right direction.
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Mon Mar 15, 2010 9:11 am
you know guys: it is all written - the problem is it is written by an Italian pretending to write English.
anyhow MMichaud, drozzy is right about to not rush while peeking this stuff - the panda3D manual itself, in the first page point very clearly this:
Panda3D is not a Beginner's Tool or a Toy
To successfully use Panda3D, you must be a skilled programmer. If you do not know what an "API" is, or if you don't know what a "tree" is, you will probably find Panda3D overwhelming. This is no point-and-click game-maker: this is a tool for professionals. While It is important to point that out so you have accurate expectations, it's also relevant to be aware that Panda3d is one of the easiest and most powerful engines you will ever use, and we welcome your participation.
I'm a 20y skilled programmer and I'd found difficult to put my feet into this stuff nonetheless - not much about to understand what a python or even C++ line of code means, but rather all the knowledge that turn around a game engine - a huge lot of stuff to know. So my friends take your time, read carefully and don't rush is a lesson to learn quick if you wanna learn quickly. (what a pun)
But keep digging an pointing any stuff you find off here though - I'll try to make my best to fix it for you - provided to have enough spare time of course.
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Mon Mar 15, 2010 6:19 pm
Hey, I'm on step6.py, and I found this line:
- Code: Select all
collisionHandler.addAgainPattern( "ray_again_all%(""rays"")fh%(""balls"")ih" )
Please don't tell me you put the "" empty quotes there just to keep me awake??? Or are they needed? Looks like an empty string ... and could be replaced with: - Code: Select all
collisionHandler.addAgainPattern( "ray_again_all%(rays)fh%(balls)ih" )
which works.
I am still not sure what the part before the first % is - the "ray_again_all". Or how that string is built up... I looked at the manual - but they show no examples. Any way you can expand on that?
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by drozzy » Mon Mar 15, 2010 6:30 pm
Hm.. I think I am beginning to understand this stuff...
If you specify a pattern like this:
- Code: Select all
%(rays)ft-into-%(balls)it
it means look for any colliders that are in the groups "rays" and "balls" respectively, and substitute these strings with the actual tag values. So it will match if a ray "ray1" collides with a ball "smiley", and will use these values in forming the function name: ray1-into-smiley. On the other hand if you got something like this: - Code: Select all
some_name%(rays)fh%(balls)ih
it will still match a collision between "ray1" and "smiley" ball, but it will no longer use these specific tag names in the collision. It will just use whatever string is left-over after you remove all the special characters. So in the above case it will be just: some_name.
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by drozzy » Mon Mar 15, 2010 9:56 pm
I find this wierd. Maybe someone can enlighten me.
How come this:
model = loader.loadModel('heart') collider_path = model.find("**/collider_heart") collider_path.node().setTag('hearts', 'whole_heart')
and this: model = loader.loadModel('heart') collider_path = model.find("**/collider_heart") collider_path.setTag('hearts', 'whole_heart')
does the same thing? Notice the lack of node().
It seems like both PandaNode and NodePath both have setTag() methods...
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Tue Mar 16, 2010 2:39 am
drozzy wrote:does the same thing? Notice the lack of node(). It seems like both PandaNode and NodePath both have setTag() methods...
can't get your question - you may for sure set and read a tag for both kind of nodes but what do you need to know about that?
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Tue Mar 16, 2010 7:06 am
Well, I want to know which one I should set the tag on.
collider_path or collider_path.node()?
And does it make a difference?
astelix wrote:drozzy wrote:does the same thing? Notice the lack of node(). It seems like both PandaNode and NodePath both have setTag() methods...
can't get your question - you may for sure set and read a tag for both kind of nodes but what do you need to know about that?
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by astelix » Tue Mar 16, 2010 8:51 am
I guess should be clear to you setTag() is simply a way to make a node or nodepath carry on a string value to be read somewhere in your application - which one you'll decide to apply - either on nodepath or on a pandanode - it's up to you and your code logic. What I'm not sure to understand is if you found something strange related with the subject on my code or is outside that.
My Rig: P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
-

astelix
-
- Posts: 866
- Joined: Mon Mar 27, 2006 4:36 pm
- Location: Milano, ITA
by drozzy » Tue Mar 16, 2010 9:02 am
No, this is just a general question, unrelated to the tutorial.
I was just surprised that it worked when I changed it... anyways thanks.
astelix wrote:I guess should be clear to you setTag() is simply a way to make a node or nodepath carry on a string value to be read somewhere in your application - which one you'll decide to apply - either on nodepath or on a pandanode - it's up to you and your code logic. What I'm not sure to understand is if you found something strange related with the subject on my code or is outside that.
-

drozzy
-
- Posts: 68
- Joined: Mon Mar 08, 2010 9:17 pm
by drwr » Tue Mar 16, 2010 12:48 pm
It is true that both NodePath and PandaNode have a setTag() method. They both do the same thing--the NodePath.setTag() method is a pass-through to the PandaNode.setTag() method. It's just there as a convenience.
In fact, (almost) all of the NodePath methods are technically just conveniences--(almost) anything you can do with a NodePath, you can do with the underlying PandaNode, but sometimes the PandaNode interface is a lot clumsier. The exceptions are the methods that have to do with a particular instance of a PandaNode, which is the main reason we have a NodePath class in the first place.
David
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
Return to Code Snippets
Who is online
Users browsing this forum: No registered users and 0 guests
| | |