Panda2D

Hi, i love panda3d i think is the right way to make a real engine and not a graphical library with “game” in it’s name.
---- skippable
rationale:
I really want to make 2D Games because of (lots of) reasons.
And i would love to be able to use Panda3d. For now i’m using libGDX for work. which in fact uses 3d environ just like panda3d. So i started building my own implementation of a 2d library on panda3d.
so far i got some interesing stuff (spritesheets and tilemap vimeo.com/59118155 ) but i have lots of problems trying to understand how panda3d work and choosing the apropiate and most efficient methods.
I have many doubts that i couldn’t solve just by using Google, and instead of flooding the irc channel i thought maybe it was better to just start a thread here, to be able to share the code [ jerobarraco@bitbucket.org/jerobarraco/panda2d ]. Also so the answers can help other people just like some old answers helped me.

So i hope someone can help me, and it doesn’t bother anyone that i ask many questions.


[color=green][Solved] 1) Why pixel2d uses -Z coords?
already readed about is a matter of taste and that texture coords are the same. But i really want to know the reason behind that desition.

  1. Is there any good way i could make +Z coords (just like a 2d pixel screen)
    Having also +V texture coords. Mostly for doing Texture offsets.
    For now i just faked that by doing :
base.cam2d.setZ(2)

[color=green][Solved by rdb] 3) How can i set up the camera so that it moves on pixel coords? Or how can i create a new one with that effect?

  1. Is ok to generate a card with
    (-0.5, 0.5, -0.5, 0.5) with no UVs ?
    Then set the node scale to (w, h)
    and finally set the texOffset to (dx, -(h+dy))
    it works, but i don’t like much the transformation on the texOfset.

  2. I made a simple tilemap renderer. Does someone has an example on how to use OccluderNode, i’m not sure if i’m using it right ( bitbucket.org/jerobarraco/panda … ault#cl-47 ) or if its working.
    I’m grouping and flatten my tiles ( bitbucket.org/jerobarraco/panda … ault#cl-25 ) i don’t know if that’s enough.

  3. The tilemap works pretty well (with Tiled )
    but when i move the camera, sometimes, a line shows between the tiles (because they’re different geometries) puu.sh/20psH
    Can this be fixed? How?

Thanks :slight_smile:

  1. because the top-left corner is expected by most users to be the (0, 0) point, and because Panda is z-up-right, this would have otherwise caused all textures and text to be upside down. We figured that simply putting a - in front of the coordinates is a trivial step.

  2. Change the coordinate system using the “coordinate-system” configuration variable if you don’t like Panda’s default coordinate conventions.

  3. Reparent a camera (like base.cam2d) to pixel2d, and give its lens a film size and film offset in pixels.

  4. You can generate a card with a frame set to (0, w, 0, h) and the default UV range and it should work fine, or not?

Thanks a lot for the reply rdb

  1. “this would have otherwise caused all textures and text to be upside down” So that means i can’t have (0,0) on bottom-left without having all my textures fliped? I tried some stuff like moving the camera “Up” so that the origin gets on the bottom. It works pretty well, but texture coords are also different.

I’m not completely aware of the full implications of the coordinate system (in 3d). The bad thing is that sometimes i find myself using negative numbers and sometimes dont. And gets confusing often.

  1. I tried using something like :
 
base.cam2d.node().getLens().setCoordinateSystem

but it doesnt change, and i couldnt find any constant for having the origin at bottom-left. I assumed it was something like ZDown but there’s only ZUpLeft and ZUpRight. I’ve googled for it but i don’t know what’s the difference or how to use it.

  1. Thanks! i hope it works :slight_smile:

  2. I’m using spritesheet animations, so i don’t want to generate lots of Cards and nodes for each frame. Instead, i generate 1 card and 1 node per sprite.
    The card has the size of (1, 1). So when i change the frame i set the scale on the node to (w, h), re-scale the texture to show only the size of the sprite, and set the offset accordingly.
    I hope this is a correct way ( bitbucket.org/jerobarraco/panda … ult#cl-133 )

( i added one question )

Sure, you can use bottom-left. In that case, all you need to do is reposition base.pixel2d (or cam2d as you did).

I’ve made some improvements.
Also i made a new game for the GlobalGameJam 2017
globalgamejam.org/2017/games/whales-0
bitbucket.org/jerobarraco/panda … at=default