Roaming Ralph in C++

Hi all,

Several people requested or suggested me that a Roaming Ralph (or one alike) sample would be helpful. So, I started doing it, and I succeeded making a duplicate of Roaming Ralph, but now in C++.

Goal
Making C++ users of Panda3D familiar with basic things like animation and collision.

Screenshot
Something like this:

Notes
For sorting the CollisionEntries, I’ve just grabbed some sorting function from the internet, and after some vector and pointer hell, I got it to work. You could perhaps to this much easier with std::sort. After all, I’m not a C++ professional.

Download
You can download it here:
Roaming-Ralph-CXX.tar.gz

Build instrustions
Pretty basic. Same as you would do with any other Panda3D C++ program.
Oh, by the way, when linking, I just needed to link to p3framework and p3pystub.


And I have a few questions/remarks to the Panda3D developers/maintainers:
*Any chance if this would be included in Panda3D distro?
*Do you think we need more samples like this?
*Roaming Ralph defines a SPEED variable, and never uses it afterwards. Could be removed, huh?
*Roaming Ralph defines a MYDIR variable to detect the application path. Never uses it though when loading models, though. I’d suggest that it should be used, to make ralph roamable from other directories than where it’s in.
*Roaming Ralph uses matrices to detect its forward vectors. This is very confusing to beginners. Couldn’t we let ralph roam with a setY relative to itself?

That would be all for today :wink: I hope this helps somebody.

– pro-rsoft

I do plan on adding some C++ examples to the distro. This seems like it would be a good example. Of course, I’m swamped, as usual.

I don’t quite follow your method of getting the forward vector - could you post code?

To move ralph forward, it uses the getNetTransform method. Though, I find this method more efficient:

self.ralph.setY(self.ralph,-speed)

Works the same.

Thank you very much. If you are up to programming more sample programs in C++ I would appreciate it (if you have time). Otherwise nice stuff :smiley:

pro-rsoft, I saw you sort the collision points distances yourself. Where did you get that algo from ? It’s not even QuickSort !? o_O
So, what’s wrong with CollisionHandlerQueue::sort_entries ?
IMO, it would be better using CH Floor or CH Gravity. There is no rule to translate it 1:1, isn’t it ?

Oh, didn’t know about sort_entries, Sorry about that. (roaming ralph in python doesn’t do that either!)
Unfortunately, I don’t have time to fix that now, but once I have time I will take a closer look at that (unless someone else does it of course.)

Sorry, I try to make it a 1:1 copy, so people can compare it with the python one.

keep it a 1:1 copy please :slight_smile:

the link to the source is borken.
is there a place one could get it?
would hate to redo work already done.

Hi

check out this post from C++ forum
[url]Roaming Ralph In C++]