本文整理汇总了C++中Primitive::GetGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ Primitive::GetGeometry方法的具体用法?C++ Primitive::GetGeometry怎么用?C++ Primitive::GetGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Primitive
的用法示例。
在下文中一共展示了Primitive::GetGeometry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OutputMaterials
XSIPLUGINCALLBACK CStatus OutputMaterials( Selection& in_sel )
{
// prepare the mtl file
Project prj = app.GetActiveProject();
Scene scn = prj.GetActiveScene();
CString tmpLocation = Get3DCoatParam( L"tempLocation" ).GetValue();
ULONG npos = tmpLocation.ReverseFindString(L".");
CString substr = tmpLocation.GetSubString(0, npos+1);
CString strOut = substr + L"mtl";
//app.LogMessage(L"strOut:" + strOut);
std::ofstream matfw;
matfw.open(strOut.GetAsciiString(), std::ios_base::out | std::ios_base::trunc);
if (matfw.is_open())
{
CRefArray tempMats;
for(int i=0; i< in_sel.GetCount(); i++)
{
X3DObject xobj(in_sel.GetItem(i));
// Get a geometry accessor from the selected object
Primitive prim = xobj.GetActivePrimitive();
PolygonMesh mesh = prim.GetGeometry();
if (!mesh.IsValid()) return CStatus::False;
CGeometryAccessor ga = mesh.GetGeometryAccessor();
// get the material objects used by the mesh
CRefArray materials = ga.GetMaterials();
for (LONG n=0; n < materials.GetCount(); n++)
{
bar.PutStatusText( L"materials" );
Material mat(materials[n]);
bool inMats = false;
//app.LogMessage(CString(n) +L" : "+ CString(i)+ L" :" + mat.GetName());
for(int m = 0; m < tempMats.GetCount(); m++)
{
Material tmat(tempMats[m]);
if(mat.GetName() == tmat.GetName())
{
inMats = true;
break;
}
}
//app.LogMessage(CString(inMats));
if(!inMats)
{
CString string = L"newmtl " + mat.GetName() + L"\n";
matfw << string.GetAsciiString();
Parameter surf = mat.GetParameters().GetItem(L"surface");
Shader lShader(surf.GetSource());
//app.LogMessage(L"shader: " + lShader.GetFullName());
//app.LogMessage(L"shader: " + lShader.GetProgID());
if ( lShader.GetProgID() == L"Softimage.material-phong.1" )
{
float r, g, b, a;
lShader.GetColorParameterValue(L"ambient", r, g, b, a );
CString ka = L"Ka " + FormatNumber(r) + L" " + FormatNumber(g) + L" " + FormatNumber(b);
lShader.GetColorParameterValue(L"diffuse", r, g, b, a );
CString kd = L"Kd " + FormatNumber(r) + L" " + FormatNumber(g) + L" " + FormatNumber(b);
lShader.GetColorParameterValue(L"specular", r, g, b, a );
CString ks = L"Ks " + FormatNumber(r) + L" " + FormatNumber(g) + L" " + FormatNumber(b);
float ns = lShader.GetParameterValue(L"shiny");
float d = 1.0f;
CValue illum = 2;
matfw << ka.GetAsciiString();
matfw << "\n";
matfw << kd.GetAsciiString();
matfw << "\n";
matfw << ks.GetAsciiString();
matfw << "\n";
matfw << "Ns ";
matfw << FormatNumber(ns).GetAsciiString();
matfw << "\n";
matfw << "d ";
matfw << FormatNumber(d).GetAsciiString();
matfw << "\n";
matfw << "illum ";
matfw << illum.GetAsText().GetAsciiString();
matfw << "\n";
Parameter diff = lShader.GetParameters().GetItem(L"diffuse");
Shader lImageD(diff.GetSource());
if (lImageD.GetProgID() == L"Softimage.txt2d-image-explicit.1")
{
Parameter tex = lImageD.GetParameters().GetItem(L"tex");
ImageClip2 lTextureD(tex.GetSource());
//.........这里部分代码省略.........
示例2: ctxt
XSIPLUGINCALLBACK CStatus Coat3DExport_Execute( CRef& in_ctxt )
{
// Unpack the command argument values
Context ctxt( in_ctxt );
CValueArray args = ctxt.GetAttribute(L"Arguments");
CString string;
// A 3d object with a mesh geometry must be selected
Selection selection(app.GetSelection());
bool isPolymesh = true;
for(int i =0; i< selection.GetCount(); i++)
{
X3DObject obj(selection[i]);
//app.LogMessage(L"obj.IsA(siPolygonMeshID): " + CString(obj.GetType()));
if(obj.GetType() != L"polymsh" )
{
isPolymesh = false;
break;
}
}
if (selection.GetCount() > 0 && isPolymesh)
{
gV = 0; gVn = 0; gVt = 0;
gVprev = 0; gVnPrev = 0; gVtPrev = 0;
// prepare the output text file
CString strOut = Get3DCoatParam( L"tempLocation" ).GetValue();
std::ofstream mfw;
mfw.open(strOut.GetAsciiString(), std::ios_base::out | std::ios_base::trunc);
if (mfw.is_open())
{
bar.PutMaximum( selection.GetCount() );
bar.PutStep( 1 );
bar.PutVisible( true );
OutputHeader( mfw);
// output the data
for (int i=0; i < selection.GetCount(); i++)
{
gObjCnt = i;
gVprev = gV;
gVtPrev = gVt;
gVnPrev = gVn;
X3DObject xobj(selection.GetItem(i));
bar.PutValue(i);
bar.PutCaption( L"Exporting " + xobj.GetName());
mfw << "\n";
mfw << "# Hierarchy (from self to top father)\n";
string = L"g " + xobj.GetName() + L"\n";
mfw << string.GetAsciiString();
mfw << "\n";
// Get a geometry accessor from the selected object
Primitive prim = xobj.GetActivePrimitive();
PolygonMesh mesh = prim.GetGeometry();
if (!mesh.IsValid()) return CStatus::False;
CGeometryAccessor ga = mesh.GetGeometryAccessor();
OutputVertices( mfw, ga, xobj );
if (bar.IsCancelPressed()) return CStatus::False;
OutputPolygonComponents( mfw, ga );
if (bar.IsCancelPressed()) return CStatus::False;
//bar.Increment();
}
}
mfw.close();
if(Get3DCoatParam(L"bExpMat").GetValue())
{
OutputMaterials(selection );
}
bar.PutStatusText( L"import.txt" );
OutputImportTxt();
bar.PutVisible(false);
app.LogMessage(L"Export done!");
}
else
{
app.LogMessage(L"Please, select objects!", siWarningMsg);
return CStatus::False;
}
return CStatus::OK;
}
示例3: nurbSurfaceMesh
nurbMeshData::nurbMeshData( const Primitive &nurbMeshPrim, double atTime, bool usePref, double atPrefTime ) {
globals& g = const_cast< globals& >( globals::access() );
NurbsSurfaceMesh nurbSurfaceMesh( nurbMeshPrim.GetGeometry( atTime ) );
identifier = getAffogatoName( CStringToString( X3DObject( nurbMeshPrim.GetParent() ).GetFullName() ) );
// Add two surfaces to the mesh.
CNurbsSurfaceDataArray nurbSurfaceDataArray;
nurbSurfaceMesh.Get( siIGESNurbs, nurbSurfaceDataArray );
// set the type of geometry
if( g.geometry.nonRationalNurbSurface )
tokenValuePtrArray.push_back( tokenValue::tokenValuePtr( new tokenValue( nurbSurfaceDataArray[ 0 ].m_aControlPoints, "P", tokenValue::storageVertex, tokenValue::typePoint ) ) );
else
tokenValuePtrArray.push_back( tokenValue::tokenValuePtr( new tokenValue( nurbSurfaceDataArray[ 0 ].m_aControlPoints, "Pw" ) ) );
if( usePref ) {
NurbsSurfaceMesh nurbSurfaceMeshPref = nurbMeshPrim.GetGeometry( atPrefTime );
nurbSurfaceMeshPref.Get( siIGESNurbs, nurbSurfaceDataArray );
if( g.geometry.nonRationalNurbSurface )
tokenValuePtrArray.push_back( tokenValue::tokenValuePtr( new tokenValue( nurbSurfaceDataArray[ 0 ].m_aControlPoints, "__Pref", tokenValue::storageVertex, tokenValue::typePoint ) ) );
else
tokenValuePtrArray.push_back( tokenValue::tokenValuePtr( new tokenValue( nurbSurfaceDataArray[ 0 ].m_aControlPoints, "__Pref" ) ) );
}
// grab the order information
uOrder = nurbSurfaceDataArray[ 0 ].m_lUDegree + 1;
vOrder = nurbSurfaceDataArray[ 0 ].m_lVDegree + 1;
numCVsU = nurbSurfaceDataArray[ 0 ].m_lNbUControlPoints;
numCVsV = nurbSurfaceDataArray[ 0 ].m_lNbVControlPoints;
int numKnotsU = nurbSurfaceDataArray[ 0 ].m_aUKnots.GetCount();
uKnot = new float[ numKnotsU ];
for( int knot = 0; knot < numKnotsU; knot++ )
uKnot[ knot ] = ( float )nurbSurfaceDataArray[ 0 ].m_aUKnots[ knot ];
int numKnotsV = nurbSurfaceDataArray[ 0 ].m_aVKnots.GetCount();
vKnot = new float[ numKnotsV ];
for( int knot = 0; knot < numKnotsV; knot++ )
vKnot[ knot ] = ( float )nurbSurfaceDataArray[ 0 ].m_aVKnots[ knot ];
if( g.geometry.normalizeNurbKnotVector ) {
float start;
float scale;
// U
if( nurbSurfaceDataArray[ 0 ].m_bUClosed ) {
start = uKnot[ 3 ];
scale = 1 / ( uKnot[ numKnotsU - 4 ] - start );
} else {
start = uKnot[ 0 ];
scale = 1 / ( uKnot[ numKnotsU - 1 ] - start );
}
for( int knot = 0; knot < numKnotsU; knot++ )
uKnot[ knot ] = ( uKnot[ knot ] - start ) * scale;
// V
if( nurbSurfaceDataArray[ 0 ].m_bVClosed ) {
start = vKnot[ 3 ];
scale = 1 / ( vKnot[ numKnotsV - 4 ] - start );
} else {
start = vKnot[ 0 ];
scale = 1 / ( vKnot[ numKnotsV - 1 ] - start );
}
for( int knot = 0; knot < numKnotsV; knot++ )
vKnot[ knot ] = ( vKnot[ knot ] - start ) * scale;
}
uMin = uKnot[ uOrder - 1 ];
uMax = uKnot[ numKnotsU - uOrder ];
vMin = vKnot[ vOrder - 1 ];
vMax = vKnot[ numKnotsV - vOrder ];
if( g.animation.time == atTime ) {
bound = affogato::getBoundingBox( nurbMeshPrim, atTime );
} else {
bound.resize( 6 );
bound[ 5 ] = bound[ 3 ] = bound[ 1 ] = numeric_limits< float >::max();
bound[ 0 ] = bound[ 2 ] = bound[ 4 ] = numeric_limits< float >::min();
}
}