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 / How can I get vertex color of a specific PolygonNode?
  RSS 2.0 ATOM  

How can I get vertex color of a specific PolygonNode?
Rate this thread
 
30139
 
Permlink of this thread  
avatar
  • SONIC3D
  • Posted: 02 December 2008 10:23 PM
  • Total Posts: 8
  • Joined: 03 December 2008 05:56 AM

Recently,I’m making a c# plug-in for XSI7 and confused with the vertexcolor of PolygonMesh.

My target is to get the vertex color info(RGBA) per vertex per facet.

Firstly I found there is a property VertexColors in PolygonMesh.But I think it is not the one I need.Then I tried to get color info from triangle point.But I believe it’s not the correct way.After digging the SDK doc for a whole day,I found in order to get vertex info per vertex per face,Facet.Samples must be used as index node.Finally,by set an array of Facet[x].Sample[y].Index as the second parameter,I’m managed using the function “PaintVertexColors” to set the vertex color.

But I still don’t know how to get the vertex color info by Geometry.Nodes or Facet.Samples.

Anyone done this before?

Thank you.



Replies: 0
avatar
  • ThE_JacO
  • Posted: 03 December 2008 01:03 PM

CAV maps in xsi are already on the samples, which are perpointperpoly.
CAV maps are properties of samples clusters, not of the activePrimitive directly.

If you fetch the map and get it’s elements array (Application.Selection(0).Elements.Array with the map under the cluster selected), assuming it lives on a samples cluster containing all samples, it should already be ordered the same way the samples are.
It will be 4list of values (RGBA) indexed like the cluster.



Replies: 0
avatar
  • SONIC3D
  • Posted: 04 December 2008 05:08 PM

[quote=ThE_JacO;15693]CAV maps in xsi are already on the samples, which are perpointperpoly.
CAV maps are properties of samples clusters, not of the activePrimitive directly.

If you fetch the map and get it’s elements array (Application.Selection(0).Elements.Array with the map under the cluster selected), assuming it lives on a samples cluster containing all samples, it should already be ordered the same way the samples are.
It will be 4list of values (RGBA) indexed like the cluster.


Thank you very much,ThE_JacO.The elements array works!And after referring the sample in ClusterProperty.I got these code.Hope it will be useful to someone who has the same requirement as me.

[COLOR=#008000]'VBScript example showing how to read UV values and Color values[/COLOR]
[COLOR=#008000]'Source modified from:XSI SDK Help->C# and scripting reference->Object->C->ClusterProperty[/COLOR]
set oRoot application.activeproject.activescene.root
set oObject 
oRoot.addgeometry"Cube""MeshSurface" )
set oFacet oObject.ActivePrimitive.Geometry.Facets(0)
set oSamples oFacet.Samples
indexArray 
oSamples.IndexArray
BlendInPresets 
"Image"oObject1False
CreateTextureSupport oObject
siTxtUVsiTxtDefaultSpherical"Texture_Support"
CreateVertexColorSupport "MyVertexColorProperty"oObject
SetInstanceDataValue 
oObject ".Scene_Material.UV""Texture_Support"
set oUVWProp oObject.Material.CurrentUV
set oVtxColorProp 
oObject.ActivePrimitive.Geometry.VertexColors(0)
[COLOR=#008000]' output uv text coords
[/COLOR]aUVW=oUVWProp.elements.array
[COLOR=#008000]' output color array
[/COLOR]aVtxArray=oVtxColorProp.elements.array
[COLOR=#008000]'Use this to map from index in the Cluster back to index in the Geometry
'If the cluster is not complete or if topology changes are done then
'
the geometry index is not necessarily the same as the cluster index
[
/COLOR]aClusterIndices oUVWProp.Parent.elements.array
[COLOR=#008000]' Print out just the first few elements
[/COLOR]for iIndex=0 to 3
   logmessage 
"Sample(" aClusterIndices(iIndex) & ") = UV(" _
          aUVW
(0,iIndex) & "," aUVW(1,iIndex) & ")" "        Color(" _
          aVtxArray
(0,iIndex) & "," aVtxArray(1,iIndex) & "," aVtxArray(2,iIndex) & "," aVtxArray(3,iIndex) & ")"
next
for lbound(indexArrayto ubound(indexArray)
   
LogMessage "The index of this sample is: " indexArray(i)
next
[COLOR
=#008000][/COLOR] 
[COLOR=#008000]'Result:[/COLOR]
[COLOR=#008000]' INFO : Sample(0) = UV(0.125,0.304086714982986)        Color(0.752941191196442,0.752941191196442,0.752941191196442,1)
' INFO : Sample(1) = UV(0.125,0.695913255214691)        Color(0.752941191196442,0.752941191196442,0.752941191196442,1)
INFO Sample(2) = UV(-0.125,0.695913255214691)        Color(0.752941191196442,0.752941191196442,0.752941191196442,1)
' INFO : Sample(3) = UV(-0.125,0.304086714982986)        Color(0.752941191196442,0.752941191196442,0.752941191196442,1)
INFO The index of this sample is0
' INFO : The index of this sample is: 1
INFO The index of this sample is2
' INFO : The index of this sample is: 3[/COLOR]


Replies: 0