MCPcopy Create free account
hub / github.com/ImageEngine/cortex / DiskPrimitive

Method DiskPrimitive

src/IECoreGL/DiskPrimitive.cpp:48–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46IE_CORE_DEFINERUNTIMETYPED( DiskPrimitive );
47
48DiskPrimitive::DiskPrimitive( float radius, float z, float thetaMax )
49 : m_radius( radius ), m_z( z ), m_thetaMax( thetaMax ), m_nPoints( 0 )
50{
51
52 // build vertex attributes for P, N and st, and indexes for triangles.
53
54 IECore::V3fVectorDataPtr pData = new IECore::V3fVectorData;
55 IECore::V3fVectorDataPtr nData = new IECore::V3fVectorData;
56 IECore::V2fVectorDataPtr uvData = new IECore::V2fVectorData;
57
58 vector<V3f> &pVector = pData->writable();
59 vector<V3f> &nVector = nData->writable();
60 vector<V2f> &uvVector = uvData->writable();
61
62 // centre point
63 pVector.push_back( V3f( 0.0f, 0.0f, m_z ) );
64 nVector.push_back( V3f( 0.0f, 0.0f, 1.0f ) );
65 uvVector.push_back( V2f( 0.5f, 0.5f ) );
66
67 const unsigned int n = 20;
68 float thetaMaxRadians = m_thetaMax/180.0f * M_PI;
69 for( unsigned int i=0; i<n; i++ )
70 {
71 float t = thetaMaxRadians * i/(n-1);
72 float x = cosf( t );
73 float y = sinf( t );
74 pVector.push_back( V3f( m_radius * x, m_radius * y, m_z ) );
75 nVector.push_back( V3f( 0.0f, 0.0f, 1.0f ) );
76 uvVector.push_back( V2f( x/2.0f + 0.5f, y/2.0f + 0.5f ) );
77 }
78
79 m_nPoints = n + 1;
80
81 addVertexAttribute( "P", pData );
82 addVertexAttribute( "N", nData );
83 addVertexAttribute( "uv", uvData );
84}
85
86DiskPrimitive::~DiskPrimitive()
87{

Callers 3

testCopyAndEqualityMethod · 0.45
testSaveAndLoadMethod · 0.45

Calls 1

writableMethod · 0.45

Tested by 3

testCopyAndEqualityMethod · 0.36
testSaveAndLoadMethod · 0.36