• Welcome to SC4 Devotion Forum Archives.

Panda3D Specific Help (learning)

Started by Nique, January 23, 2010, 07:33:58 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Nique

Hello, i opened this thread (for my self and others) to solve problems we might have with the engine.

I kick off with a very noob question..

I try to render a image to the window, but this image is being scaled up to the window. I dont want the images to be scaled up conforming the window width. Why is everything 'relative' to the panda window?



+

# Function to draw the splash
def addSplashImage(image):
    return OnscreenImage(image = image, pos = (0,0,0), scale = 1)

class Game(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0.22,0.22,0.22)
        self.accept("escape",sys.exit)
        self.title = addTitle("CityMania TestWindow")
        self.splashImg = addSplashImage("logo.png")
        self.splashImg.setTransparency(TransparencyAttrib.MAlpha)

=





What the hell?
This is insane. Please dont tell me the app need to recalculate the actual image size ? by getting window width's etc etc etc etc..? For each image?! Who ever invented this , this is insane  ()what()
Proudly developer of

croxis

There are two major branches in the panda render tree, render, and render2d. render2d is fairly dumb and will stretch images like you see. However there is a child node, aspect2d, that will maintain the aspect ratio. You will need the Node.reparentTo(aspect2d) command.



# Function to draw the splash
def addSplashImage(image):
    image = OnscreenImage(image = image, pos = (0,0,0), scale = 1)
    image.reparentTo(apect2d)
    return

class Game(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0.22,0.22,0.22)
        self.accept("escape",sys.exit)
        self.title = addTitle("CityMania TestWindow")
        self.splashImg = addSplashImage("logo.png")
        self.splashImg.setTransparency(TransparencyAttrib.MAlpha)


There is also a pixel2d layer which coordinate system is based on pixels instead.

Nique

Thanks,

This tells me some more, i did read a lot of the manual but i guess i accidentally skipped it. Anyway, i still get the same result..


# Function to draw the splash
def addSplashImage(image):
    img=OnscreenImage(image = image, pos = (0,0,0), scale = 1)
    img.reparentTo(aspect2d)
    img.setTransparency(TransparencyAttrib.MAlpha)   
    return img

class Game(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0.22,0.22,0.22)
        self.accept("escape",sys.exit)
        self.title = addTitle("CityMania TestWindow")
        self.splashImg = addSplashImage("logo.png")
Proudly developer of

croxis

This is curious. OnScreenImage should be parented to aspect2d by default. Try removing the scale parameter.

croxis

Also, My irc client auto signs in to #citymania and #panda3d (both on freenode), so you can catch me in either location. There is also my wave account too :)

Nique

#5
Roger that,

I have problems to get 1.7.0 working on windows as the buildbot provides a 'not working' version. So i decided to build panda3d my self, but that also is impossible....

because... you can't download the thirdparty dir anywhere... (this is bad and frustrating me bigtime)
So none of these 2 options seems to work. I want 1.7.0 (seems to be released this week.. but pages on home page arent updated) because of it's pixel2d function.

Is there somehow, another way to get this working? Do you have the thirdparty dir of 1.7.0 croxis?


Nevermind, they released 1.7.0 now
Proudly developer of

Nique

#6
<?php



from pandac
.PandaModules import loadPrcFileData
loadPrcFileData
("""""    
    window-title CityMania
    fullscreen 0
    win-size 1024 768
    cursor-hidden 1
    sync-video 0
    frame-rate-meter-update-interval 0.5
    show-frame-rate-meter 1
"""
)

import direct.directbase.DirectStart
from pandac
.PandaModules import TextNode,Vec3,PNMImageHeader,Filename
from pandac
.PandaModules import TransparencyAttrib
from direct
.showbase.DirectObject import DirectObject
from direct
.gui.OnscreenText import OnscreenText
from direct
.gui.OnscreenImage import OnscreenImage

import sys
font 
loader.loadFont("cmss12")

# Function to put title on the screen.
def addTitle(text):
    return 
OnscreenText(text=textstyle=1fg=(1,1,1,1), font font
                
pos=(1,-0.8), align=TextNode.ARightscale .07)

# Function to draw the splash
def addSplashImage(image):
    
iH=PNMImageHeader()
    
iH.readHeader(Filename(image))
    
img=OnscreenImage(image image)
    
img.reparentTo(pixel2d)
    
img.setPos(base.win.getXSize()/2,0,0-base.win.getYSize()/2)
    
img.setScale(iH.getXSize(),1,iH.getYSize())
    
img.setTransparency(TransparencyAttrib.MAlpha)    
    return 
img

class Game(DirectObject):
    
def __init__(self):
        
base.setBackgroundColor(0.22,0.22,0.22)
        
self.accept("escape",sys.exit)
        
self.title addTitle("CityMania TestWindow")
        
self.splashImg addSplashImage("logo.png")

t=Game()

#Run app
run()


?>



Gave me:


Now, when power of 2 is turned off (textures-power-2 none):

It looks more like it, but still blurry...

I devided the scale.. (god may know why it is still scaled up)
img.setScale(iH.getXSize() / 2,1,iH.getYSize() / 2)
and got this

Now this is 'allmost' there, but notice, its STILL FREAKING BLURRY.. and WHY do i have to devide the original width/height of the image that i got from PNMImageHeader()

its a battlefield here, why is it SO DAMN HARD to just render a normal 2d picture to the screen in panda, in all other engines i did this in just 2 minutes... here i am.. : DAY 2

the original image looks like this sharp:



Croxis, do you have an example of a 'well' rendered pic.. i mean.. this is rubbish
Proudly developer of

croxis

It would help if I actually had the pic to work with. Could you attach it?

Nique

Proudly developer of

croxis

from pandac.PandaModules import loadPrcFileData
loadPrcFileData("", """   
    window-title CityMania
    fullscreen 0
    win-size 1024 768
    cursor-hidden 1
    sync-video 0
    frame-rate-meter-update-interval 0.5
    show-frame-rate-meter 1
""")

import direct.directbase.DirectStart
from pandac.PandaModules import TextNode,PNMImageHeader,Filename
from pandac.PandaModules import TransparencyAttrib
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenText import OnscreenText
from direct.gui.OnscreenImage import OnscreenImage

import sys
font = loader.loadFont("cmss12")

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1), font = font,
                pos=(1,-0.8), align=TextNode.ARight, scale = .07)

# Function to draw the splash
def addSplashImage(image):
    iH=PNMImageHeader()
    iH.readHeader(Filename(image))
    img=OnscreenImage(image = image, parent = pixel2d)
    img.setPos(base.win.getXSize()/2,0,0-base.win.getYSize()/2)
    img.setScale(iH.getXSize()/2,1,iH.getYSize()/2)
    img.setTransparency(TransparencyAttrib.MAlpha)   
    return img

class Game(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0.22,0.22,0.22)
        self.accept("escape",sys.exit)
        self.title = addTitle("CityMania TestWindow")
        self.splashImg = addSplashImage("logo.png")

t=Game()

#Run app
run()