First Person Camera tuorial

Hi,

I’ve just finished a tutorial on how to develop “a 1st person camera system with Panda3D and c++” and would like to show it to you.
You can find the download link in the manual section: “User Contributed Tutorials and Examples”
This thread is for you to comment on my work, once you have read it. Also, you are welcome to post any mistakes you may find, so I can correct them :slight_smile:
[size=134]
[color=red]!!!Please no spam!!![/size] :unamused:

I hope you’ll enjoy reading :wink:

i havent looked at the code yet. but providing c++ samples is an exccelent idea :slight_smile: so, thx for contributing and keep it up !

Thank you! :smiley: Maybe I’ll write more tutorials.

anything for python :unamused:

No! I wanted to write something for C++, because, in contrary to python, there are no tutorials for it.
Every sample or tutorial uses python code. SO it shouldn’t be you asking but me: “Anything for C++ :unamused:

100 downloads! :open_mouth:
Thank you for that, but I would really like to get some feedback.
So, if you have read (or will read) the tutorial, I would like you very much to tell me your opinion.
As an alternative to this thread (e.g. if you don’t want to register only for giving me some feedback) you can also write me an e-mail to
encytechsupport@googlemail.com

No idea how I could have missed that. (Thanks for bumping)

This paper is the first really extensive, detailed, hi-quality topic-related paper I’ve ever seen in connection with Panda3D.
The fact that it covers a very incomplete section of the documentation, C++, makes it even more valuable and from the first view I can say that it’ll be helpful for me as Pyton coder no less.

Big thanks for this! Hope to see more of the kind :slight_smile:

Nice information from you. I have seen this link, and Its working so wonderful and nice result too. Thank you for sharing this wonderful page. This is so interesting! .and your information is really increase my knowledge. I hope you send more information like this.

Nice to hear that someone considers my work helpful :slight_smile:

Hi,

I know this is an old post, but the tutorial you provided is excellent, it gave me a really good point to start using Panda with C++.

One thing I was trying to do was to make your sample application run in fullscreen:

    const WindowProperties wp = win->get_graphics_window()->get_properties();
    WindowProperties wpx = WindowProperties(wp);
    wpx.set_fullscreen(true);
    wpx.set_size(1440,900);
    win->get_graphics_window()->set_properties_now(wpx);

But the cursor doesn’t stay in the center of the screen and the image rotates really fast, even though the x_size and y_size are correct. Any idea why?

Also, how can I get rid of the set_size(1440,900) line? Without it the application runs in fullscreen, but with a different resolution and with black vertical margins.

And last, but not least, do you know a way to replace the mouse cursor with a crosshair/target?

Thanks & best regards,
Dumi.

Thank you very much, I’m glad you like it :slight_smile:

As to your problem: I wrote the tutorial more than two years ago, and I haven’t touched Panda in quite a while, because I’ve been working on a project that uses Ogre. That having been said, my (for the reasons I just mentioned rather amateurish) guess is that perhaps win->get_graphics_window()->get_x_size() doesn’t work in fullscreen (or maybe it’s outdated?). Try putting something like this at the top of the listing:

#define SCREEN_W 1440
#define SCREEN_H 990
#define SCREEN_W_HALF 720
#define SCREEN_H_HALF 495

Then use them like so:

/*
 * In CamRotationTask:
 */

//Subtract half the window size to retrieve
//the relative cursor movement
cursorX -= SCREEN_W_HALF;
cursorY -= SCREEN_H_HALF;

//[...]
//Reset the cursor to its default position (middle of the window) win->get_graphics_window()->move_pointer(0, SCREEN_W_HALF, SCREEN_H_HALF);

/*
 * In main
 */

wpx.set_size(SCREEN_W, SCREEN_H);

Now this may or may not solve your problem, but, anyways, it’s good programming practice :stuck_out_tongue:

If you want to change your cursor, I think you can simply add this line to your config.prc file:

cursor-filename your_cursor.ico

Alternatively, you could try the following in your main function:

wpx.set_cursor_filename("/c/yourproject/your_cursor.ico");

Thanks for your answer!

Here is how I’m starting in fullscreen and hide the mouse cursor:

    WindowFramework * win; 
    NodePath environ; 
    
    framework.open_framework(argc, argv); 
    framework.set_window_title("Panda3D Tests"); 
    
    GraphicsPipe *gp = framework.get_default_pipe(); 
    
    WindowProperties props; 
    framework.get_default_window_props(props); 
    props.set_fullscreen(true); 
    props.set_origin(0, 0); 
    props.set_mouse_mode(WindowProperties::M_relative); 
    props.set_size(gp->get_display_width(), gp->get_display_height()); 

    win = framework.open_window(props, 0);    

    props = WindowProperties(win->get_graphics_window()->get_properties()); 
    props.set_cursor_hidden(true); 
    
    win->get_graphics_window()->request_properties(props);

And this is how I show a target/crosshair:

    PT(Texture) tex = TexturePool::load_texture("crosshair.png");
        
    CardMaker cm("cardMaker");
    cm.set_frame(-50.0f/width, 50.0f/width, -50.0f/height, 50.0f/height);

    NodePath path(cm.generate());
    path.set_texture(tex);
    path.set_transparency(TransparencyAttrib::M_alpha);
    path.reparent_to(window->get_render_2d());

Thanks & best regards,
Dumi.

Will this work on my Macbook Pro? I use Eclipse