On 05/12/2017 at 05:04, xxxxxxxx wrote:
Originally posted by xxxxxxxx
To properly handle this, you need to have two vertices (or more, depending on how many polygons share this point), where each vertex stores the position of the Point and also its individual UV (and normal).
It's actually the case since as said in my previous post, UVVertexID belong to CPolygon vertex(a,b,c,d). Maybe I missunderstand something about how you do your UV stuff but basicly here is a code that show you that you have 2 UVVertexID for VertexID 1 (2 in your schema, since ID start at 0 and not 1)
import c4d
def CreateObject() :
obj = c4d.BaseObject(c4d.Opolygon)
points = [c4d.Vector(0, 0, -100), # Coordonnées des points
c4d.Vector(0, 0, 0),
c4d.Vector(0, 0, 100),
c4d.Vector(100, 0, -100),
c4d.Vector(100, 0, 0),
c4d.Vector(100, 0, 100)]
polys = [c4d.CPolygon(0, 1, 4, 3), # Points ABCD du polygone
c4d.CPolygon(1, 2, 5, 4)]
obj.ResizeObject(len(points), len(polys))
obj.SetAllPoints(points)
for i, p in enumerate(polys) :
obj.SetPolygon(i, p)
obj.Message(c4d.MSG_UPDATE)
doc.InsertObject(obj)
return obj
def CreateUVTag(obj) :
tag = c4d.UVWTag(obj.GetPolygonCount())
obj.InsertTag(tag)
return tag
def main() :
obj = CreateObject()
if not obj: return
uvTag = CreateUVTag(obj)
if not uvTag: return
# Now everything is setup, let's change VertexID 1 (2 in your schema, since ID start at 0 and not 1)
nbr = c4d.utils.Neighbor()
nbr.Init(obj)
polys = nbr.GetPointPolys(1) # Get all the PolygonID shared with vertexID 1
polys_data = obj.GetAllPolygons()
# Loop for each CPolygon and add to list_id, the PolygonID["poly_id"], and the actual CPolygon vertex ID (a,b,c,d are mapped to 0,1,2,3)["pt_num"]
list_id = list()
for poly_id in polys:
poly = polys_data[poly_id]
found_id = poly.Find(1) # here we search for want VertexID 1
if found_id != c4d.NOTOK:
buffer_data = dict()
buffer_data["poly_id"] = poly_id
buffer_data["pt_num"] = found_id
list_id.append(buffer_data)
# Now we get list of all Cpolygon with the corresponding (a,b,c,d) that are equal to VertexID 1
for pt in list_id:
buffer_uv = uvTag.GetSlow(pt["poly_id"])
list_uv = [buffer_uv["a"],
buffer_uv["b"],
buffer_uv["c"],
buffer_uv["d"]]
# change the value only for the corresponding CPolygon vertexID look comment at line 48
list_uv[pt["pt_num"]] = c4d.Vector(0.5, 0.0, 0.0)
# Set the point where you want
uvTag.SetSlow(pt["poly_id"],
list_uv[0],
list_uv[1],
list_uv[2],
list_uv[3]
)
c4d.EventAdd()
if __name__=='__main__':
main()
Please take a look at my script linked in my previous post
But maybe I complettly missunderstand your question and someone else get it ! ;)