texture coords

ok, i have 9 nodepaths each one holds one procedural mesh

i want to apply a single colormap texture such like this:


http://handeozerden.com/snaptothegrid/panda/cmap.bmp

but with some coords on each mesh for grab only the right rect of the texture

i already managed to do this when assigning uv data to the vertices of the first mesh, but i don’t know how to make the initial xy point of the texture to displace

an image should explain the problem:

http://handeozerden.com/snaptothegrid/panda/texcoords.jpg

pseudo-code for understand the process:

xs = (1./len(data))/3
ys = (1./len(data[0]))/3

for x,y:

  uv.addData2f(x*xs,y*ys)                   
  uv.addData2f((x+1)*xs,y*ys)                   
  uv.addData2f((x+1)*xs,(y+1)*ys)                  
  uv.addData2f(x*xs,y*ys)               
  uv.addData2f((x+1)*xs,(y+1)*ys)                 
  color.addData4f(*c4)

tx = loader.loadTexture(tex)
mesh.setTexture(tx)

thanks in advance
c
[/img]

every node you have will have different uv’s. So the 2nd node in every row/column will not start with u/v 0, but 1/3.

so i’d go for something like:

# pseudocode
for xMesh in xrange(3):
  for yMesh in xrange(3):
    mesh = createMesh(...)
    
    xs = (1./len(data))/3
    ys = (1./len(data[0]))/3

    for x,y:
      x0 = (x)*xs+(xMesh*1/3.)
      x1 = (x+1)*xs+(xMesh*1/3.)
      y0 = (y)*xs+(yMesh*1/3.)
      y1 = (y+1)*xs+(yMesh*1/3.)
      uv.addData2f(x0,y0)                   
      uv.addData2f(x1,y0)                   
      uv.addData2f(x1,y1)                 
      uv.addData2f(x0,y1)               
      color.addData4f(*c4)

    tx = loader.loadTexture(tex)
    mesh.setTexture(tx)

oh, i see now, thanks a lot for the info!
c

anyway, since the colormap texture are plain colors, i managed to assign the vertex colors instead of loading the texture

cool :slight_smile:

Quite nice in combination with some texture tiles!

c

Looks to be coming along great! Reminds me of populous.

Cant wait to finish my current 2d project so I can start coding more 3d as well. :smiley:

hehehe tks scooby
you shood, i mean,
there’s something between the frontier between 2d and 3d that really puts me on, i don’t know how to expain it :slight_smile:

1st time I messed around with panda3d I thought “Yay, now I’m a REAL programmer”. Is that the sort of feeling you mean? :smiley:

hahaha
not really it’s more about mixing isometric and 2d based aesthetic concepts and feelings with modern 3d representation

anyway, about this i have to say that yes, i was messing around years ago with lingo shockwave3d and more recently with blitz3d, but i needed something more, let’s say, real.

I felt so hard to start learning c++ and python looked as a good option
And, wow, in 2 weeks i’ve learned a lot, i think is a fantastic lang!

yes, congratulations to Panda3d makers !

p.d: only thing i wish is documentation was a bit more structured/finished :unamused: