Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / Creating UVs with a custom operator in c++
  RSS 2.0 ATOM  

Creating UVs with a custom operator in c++
Rate this thread
 
30183
 
Permlink of this thread  
avatar
  • RedBjarne
  • Posted: 28 February 2009 01:00 PM
  • Location: Copenhagen
  • Total Posts: 50
  • Joined: 22 February 2008 02:47 AM

I’m writing a custom operator that rebuilds the object completely on each update. I use the PolygonMesh.Set() method for the vertex/poly creation and that works fine.

My question is, how to I create a set of UVs for my object?

I can see that creating clusters from a custom operator is not allowed?! or what? I noticed that all other generator operators have a ‘generate uv’s button (extrusions etc.). Does this mean that I have to run a custom command from the PPG that generates the uvs? My uv’s are dependent on data getting generated while creating the mesh so how do I store that data if I can’t create clusters (for a custom command uv-setter to use)?

I’m writing this in c++ but I guess I would have the same problem if I was scripting?

Cheers
Jacob



Replies: 0
avatar
  • RedBjarne
  • Posted: 28 February 2009 01:21 PM

small update..

I can add a sample cluster from the Custom Operator within the update section, but I cannot add the ClusterProperty that should hold the UVs?  ... I’m confused..



Replies: 0
avatar

I’m purely on Python so I cannot comment on C++, but from what I have heard from others who tried this before this seems to be a limitation in the SDK. From what I have heard this could be done by calling commands from C++ code directly, but I don’t know if this is feasible when you create geometry from scratch. I can imagine that this might also be the reason for gemetric primitives not being generated with UV’s - they always need to be created afterwards manually, which is kind of ok from a worflow point of view. Except for the polygonal torus, since there is no toric uv projection available in XSI, unless you create a nurbs torus and GATORthe uv’s back on the polygonal one. Yuck.) But I guess that’s not what you want. -> SDK feature request?



Replies: 0
avatar

hello, here is an old thread on xsibase, dealing with that problem…
http://www.xsibase.com/forum/index.php?board=14;action=display;threadid=35564

Hope this help, ben.



Replies: 0
avatar
  • MaxFox
  • Posted: 17 March 2009 07:01 AM

How are you getting on in the decision of this question?
I too try to solve this question.
Access to UV-co-ordinates is not difficult.
Here a principle of change of UV-co-ordinates on JScript:

[I]ob=CreatePrim ("Cube", “MeshSurface”, null, null);
//a=selection (0);
a=ob;
CreateProjection (ob, 11, 0, “tx_Support”, “tx_Property”, true, 1);//create UV-projection
b=a.ActivePrimitive.Geometry;
c=b.Clusters(0).Properties (0); //select UV property
d1=c.Elements.Array.toArray();
for (i=0; i <d1.length-1; i ++)
{
d1 =d1 +0.5; //offset texture coordinates
}
c.Elements.Array = d1;[/I]

But problems begin, when this code works as Update for Custom Op, if the operator change topology, with the help
i[B][I]n_ctxt. OutputTarget. Geometry.set (newgeometry.points, newgeometry.polygons); [/I][/B]- commands.

It is necessary to update UV-cluster that he included all samples object.
It is made by the command
[B][I]SIAddToCluster (inCluster, MeshName + “. sample [0-LAST]");[/I][/B]

But data with “tx_Property”, all the same are not updated, and the quantity samples cannot increase.

I do not know as to solve this problem.

p.s.:
Automatic updating cluster does not work at manual creation Uv-cluster , and at change of topology by a command [I]:in_ctxt. OutputTarget. Geometry.set (newgeometry.points, newgeometry.polygons);
[/I]p.s.:
[I]If to create in the operator 2 Out ports, as in function an update to divide for write these ports?
[/I]
I and have not understood how to update samples in UV-cluster, and in UV-cluster-property.



Replies: 0
avatar
  • Steve_C
  • Posted: 03 April 2009 10:03 AM

Just a thought.
there are several texture editing modes.
One of them is swim. Maybe that could be used to your advantage.
Not sure though. I do not quite fully understand what your trying to do with the uv’s



Replies: 0
avatar
  • Steve_C
  • Posted: 03 April 2009 10:07 AM

[quote=High5;20358]I’m purely on Python so I cannot comment on C++, but from what I have heard from others who tried this before this seems to be a limitation in the SDK. From what I have heard this could be done by calling commands from C++ code directly, but I don’t know if this is feasible when you create geometry from scratch. I can imagine that this might also be the reason for gemetric primitives not being generated with UV’s - they always need to be created afterwards manually, which is kind of ok from a worflow point of view. Except for the polygonal torus, since there is no toric uv projection available in XSI, unless you create a nurbs torus and GATORthe uv’s back on the polygonal one. Yuck.) But I guess
that’s not what you want. -> SDK feature request?

Just a note: A torus is a tube bent around so each end touches. You could effectively create a UV from a tube that matches the topology of the torus and then use gator.
I know that its a bad work around but if one really needs to have a set of UV’s for a torus that flow evenly then that’s one way.



Replies: 0
avatar

Thank’s Steve, the idea with the tube is good.
But ultimately I hope we’ll see an improvement on the SDK side soon. This has been a recurring issue on many forums and the Softimage mailling list.



Replies: 0
avatar
  • mantom
  • Posted: 09 April 2009 12:14 PM

[quote=RedBjarne;19715]small update..

I can add a sample cluster from the Custom Operator within the update section, but I cannot add the ClusterProperty that should hold the UVs? ... I’m confused..


Look for the ClusterPropertyBuilder method.  You need to build a clusterproperty of type “uvspace”.  Once created, you populate the uvspace clusterproperty with the UVW values for the samples (polygon nodes) of the object.



matt



Replies: 0