cube mapping not working at all

Look at this code

c=loader.loadModelCopy('models/primitives/box')
#c.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldNormal)
c.setTexture(loader.loadCubeMap('./textures/cubemap2/v_#.jpg'),1)
c.reparentTo(render)
c.setScale(100)
c.setPos(0,210,0)

box is a model taken from /usr/share/panda3d/models, it has u,v set to 0,1 in all faces.

I used 6 jpg images with numbered images, and i also tried with png images. The result is that the scale of texture is terribly wrong, i don’t understand how to get cube map working correctly. Thanks.

I’m using python 2.5 with panda 1.5.

First you have to explain what you mean by “correctly”. How can the scale be wrong when you are just applying an abstract image to an abstract model? What scale do you really want it to be?

Cube maps are mainly used for effects like reflection mapping. They’re not usually used to just to apply a different texture to each face of a cube. If you want to do this, model the cube that way in the first place, with a different texture on each face.

Also, just for the record, don’t use loader.loadModelCopy(). Use loader.loadModel() instead. loader.loadModelCopy() is deprecated, along with all the other funny variants on loadModel.

David

Is there a list somewhere of which functions are considered deprecated?

I’m using cube mapping as the manual explains it, and eventually transform it in a skybox.

But the main issue is that the scale is not respected. If i set a single image texture, the texture vertices are attacched to the edge vertices of the cube correctly.

With a cube map i would assume the same behaviour but that is not what i see. The texture is scaled (it seems) so i can see only the first pixel of an only one of the six images in all of the faces.

I will explain.
The model is the /usr/share/panda3d/models/box.egg.pz
The textures are 6 jpeg with a number painted inside them.

The result is a cube with every face with apparently the same texture, and not from 0 to 1 UV but from 0 to 0.001 (for example).

Can you explain me (as guide) how to draw a die with custom textures and this box??

No, I don’t think so; sorry. That does sound like a good idea. I do try to put nuisance messages in deprecated functions, though it’s not always possible to do so.

Cube mapping is different from regular texture mapping. In particular, it uses three-dimensional UVW texture coordinates, instead of the standard two-dimensional UV texture coordinates. I believe the manual explains this pretty well.

The cube model in question has only two-dimensional UV texture coordinates. Most models do. You can generate new, three-dimensional texture coordinates with the line you have commented out, but when you do this you have to understand what you are doing. I think the manual explains this process pretty well too; is there a part that is particularly confusing?

I believe there were some recent threads about modeling a cube with a different texture on each face in Blender.

David

Thanks drwr, i was wrong , but the manual is not clearing it with a simple example.

Anyway i found a method to create a skybox with a class of my own that works similar to a cube map but it uses planes instead of a cube.

If someone is interested there it is :

class MySkyBox(object):
    # Assuming that the string texPath is of type xxxx_#.xxx where # go from 0 to 6
    # and the images are in order left,right,back,front,down,upper faces.
    # WARNING : sometimes down and upper faces must be rotated in a way that they 
    #           match the other faces borders.
    def __init__(self,texPath,size):
        c=NodePath("skybox_center")
        s=[]
        for i in range(0,6):
            tp=texPath.replace("#",str(i))
            t=loader.loadTexture(tp)
            p=loader.loadModel('models/primitives/plane')
            p.setTexture(t,1)
            p.reparentTo(c)
            p.setScale(size)
            s.append(p)
        #TODO positioning all planes
        #...
        os=float(size)/2.0
        s[0].setPosHpr(-os,0,0,90,0,0)
        s[1].setPosHpr(os,0,0,-90,0,0)
        s[2].setPosHpr(0,-os,0,180,0,0)
        s[3].setPos(0,os,0)
        s[4].setPosHpr(0,0,-os,0,-90,0)
        #here upper face require adjusting the roll
        s[5].setPosHpr(0,0,os,0,90,-90)
        
        c.setEffect(CompassEffect.make(render))
        c.setBin('background', 0)
        c.setDepthWrite(False)
 
        self.mainObj=c
        self.planes=s
        
    def activate(self):
        self.mainObj.reparentTo(camera)