Hey,
So this is my Code, it creates a cube with 8 vertices and 6 polygons. So some of the vertices are used by 2 polygons.
def makeTest(sx,sy,sz,breite,tiefe,hoehe,groupname, filename=None):
data = EggData()
group = EggGroup(groupname)
data.addChild(group)
cFlags = EggGroup.CFKeep+EggGroup.CFDescend
group.setCsType(EggGroup.CSTPolyset)
group.setCollideFlags(cFlags)
vPool = EggVertexPool('Cell')
wallTex = EggTexture("wallTex", "wall.jpg")
wallTex.setTextureType(Texture.TT3dTexture)
wallTex.setWrapMode(Texture.WMRepeat)
wallTex.setUvName("wallTex")
group.addChild(wallTex)
A = EggVertex()
B = EggVertex()
C = EggVertex()
D = EggVertex()
E = EggVertex()
F = EggVertex()
G = EggVertex()
H = EggVertex()
A.setUvw("wallTex",Point3D(0,0,0))
A.setPos(Point3D(sx,sy,sz))
B.setUvw("wallTex",Point3D(1,0,0))
B.setPos(Point3D(sx + breite,sy,sz))
C.setUvw("wallTex",Point3D(1,1,0))
C.setPos(Point3D(sx + breite,sy,sz + hoehe))
D.setUvw("wallTex",Point3D(0, 1, 0))
D.setPos(Point3D(sx,sy,sz + hoehe))
E.setUvw("wallTex",Point3D(0, 0, 1))
E.setPos(Point3D(sx,sy+tiefe,sz))
F.setUvw("wallTex",Point3D(1,0,1))
F.setPos(Point3D(sx+breite,sy+tiefe,sz))
G.setUvw("wallTex",Point3D(1,1,1))
G.setPos(Point3D(sx+breite,sy+tiefe,sz + hoehe))
H.setUvw("wallTex",Point3D(0, 1,1))
H.setPos(Point3D(sx,sy+tiefe,sz + hoehe))
#front
ABCD = EggPolygon()
ABCD.addVertex(vPool.addVertex(A))
ABCD.addVertex(vPool.addVertex(B))
ABCD.addVertex(vPool.addVertex(C))
ABCD.addVertex(vPool.addVertex(D))
ABCD.addTexture(wallTex)
group.addChild(ABCD)
#back
HGFE = EggPolygon()
HGFE.addVertex(vPool.addVertex(H))
HGFE.addVertex(vPool.addVertex(G))
HGFE.addVertex(vPool.addVertex(F))
HGFE.addVertex(vPool.addVertex(E))
HGFE.addTexture(wallTex)
group.addChild(HGFE)
#top
DCGH = EggPolygon()
DCGH.addVertex(vPool.findMatchingVertex(D))
DCGH.addVertex(vPool.findMatchingVertex(C))
DCGH.addVertex(vPool.findMatchingVertex(G))
DCGH.addVertex(vPool.findMatchingVertex(H))
#DCGH.triangulateInPlace(1)
DCGH.addTexture(wallTex)
group.addChild(DCGH)
#linke Seite
DHEA = EggPolygon()
DHEA.addVertex(vPool.findMatchingVertex(D))
DHEA.addVertex(vPool.findMatchingVertex(H))
DHEA.addVertex(vPool.findMatchingVertex(E))
DHEA.addVertex(vPool.findMatchingVertex(A))
DHEA.addTexture(wallTex)
group.addChild(DHEA)
#right side
BFGC = EggPolygon()
BFGC.addVertex(vPool.findMatchingVertex(B))
BFGC.addVertex(vPool.findMatchingVertex(F))
BFGC.addVertex(vPool.findMatchingVertex(G))
BFGC.addVertex(vPool.findMatchingVertex(C))
BFGC.addTexture(wallTex)
group.addChild(BFGC)
#bottom
EFBA = EggPolygon()
EFBA.addVertex(vPool.findMatchingVertex(E))
EFBA.addVertex(vPool.findMatchingVertex(F))
EFBA.addVertex(vPool.findMatchingVertex(B))
EFBA.addVertex(vPool.findMatchingVertex(A))
EFBA.addTexture(wallTex)
group.addChild(EFBA)
#nodeData = loadEggData(data)
#nPath = NodePath(nodeData)
#npath.reparentTo(render)
node = loadEggData(data)
return NodePath(node)
box = builder.makeTest(10,20,0,20,20,10,'wall')
box.reparentTo(render)
I got some problems with the UV coordinates and I hope someone could help me.
If i use wallTex.setTextureType(Texture.TTCubeMap) with wall.jpg changed to wall#.jpg and wall0.jpg-wall5.jpg created, i get the error:
:display:gsg:glgsg(error): GL texture creation failed for wall0 : invalid value
:display:gsg:glgsg(error): Could not load wall0
I hope someone can explain to me how to set the UVs right.Do I need more UVs for 1 vertex ?
Bye