CC3Mesh* CC3MeshNode::prepareParametricMesh() { if (getVertexContentTypes() == kCC3VertexContentNone) { setVertexContentTypes( (CC3VertexContent)(kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinates) ); } return _mesh; }
/** Particles are not copied. */ void CC3ParticleEmitter::populateFrom( CC3ParticleEmitter* another ) { super::populateFrom( another ); setMesh( NULL ); // Emitters can't share meshes setVertexContentTypes( another->getVertexContentTypes() ); // Use setter to establish a new mesh setParticleNavigator( (CC3ParticleNavigator*)another->getParticleNavigator()->copy()->autorelease() ); // Use setter to retain & link back here m_maximumParticleCapacity = another->getMaximumParticleCapacity(); m_particleCapacityExpansionIncrement = another->getParticleCapacityExpansionIncrement(); m_emissionInterval = another->getEmissionInterval(); m_emissionDuration = another->getEmissionDuration(); m_shouldRemoveOnFinish = another->shouldRemoveOnFinish(); m_shouldUpdateParticlesBeforeTransform = another->shouldUpdateParticlesBeforeTransform(); m_shouldUpdateParticlesAfterTransform = another->shouldUpdateParticlesAfterTransform(); }
void CC3MeshParticleEmitter::setParticleTemplateMesh( CC3Mesh* aMesh ) { if (aMesh == m_pParticleTemplateMesh) return; CC_SAFE_RELEASE( m_pParticleTemplateMesh ); m_pParticleTemplateMesh = aMesh; CC_SAFE_RETAIN( aMesh ); // Add vertex content if not already set, and align the drawing mode if ( getVertexContentTypes() == kCC3VertexContentNone ) setVertexContentTypes( aMesh->getVertexContentTypes() ); setDrawingMode( aMesh->getDrawingMode() ); CC3_TRACE( "[ptc]Particle template mesh of CC3MeshParticleEmitter set to %s drawing %s with %d vertices and %d vertex indices", aMesh->fullDescription().c_str(), stringFromGLEnum(getDrawingMode()).c_str(), aMesh->getVertexCount(), aMesh->getVertexIndexCount() ); }
/** Overridden because we only need vertex locations, and to allocate and populate indices. */ CC3Mesh* CC3TouchBox::prepareParametricMesh() { if (m_pMesh) return m_pMesh; if (getVertexContentTypes() == kCC3VertexContentNone) setVertexContentTypes( kCC3VertexContentLocation ); // Prepare the vertex content and allocate space for vertices and indices. m_pMesh->setAllocatedVertexCapacity( 8 ); m_pMesh->setAllocatedVertexIndexCapacity( 36 ); GLuint vIdx = 0; // Front m_pMesh->setVertexIndex( 1, vIdx++ ); m_pMesh->setVertexIndex( 5, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 3, vIdx++ ); m_pMesh->setVertexIndex( 1, vIdx++ ); // Back m_pMesh->setVertexIndex( 0, vIdx++ ); m_pMesh->setVertexIndex( 2, vIdx++ ); m_pMesh->setVertexIndex( 6, vIdx++ ); m_pMesh->setVertexIndex( 6, vIdx++ ); m_pMesh->setVertexIndex( 4, vIdx++ ); m_pMesh->setVertexIndex( 0, vIdx++ ); // Left m_pMesh->setVertexIndex( 0, vIdx++ ); m_pMesh->setVertexIndex( 1, vIdx++ ); m_pMesh->setVertexIndex( 3, vIdx++ ); m_pMesh->setVertexIndex( 3, vIdx++ ); m_pMesh->setVertexIndex( 2, vIdx++ ); m_pMesh->setVertexIndex( 0, vIdx++ ); // Right m_pMesh->setVertexIndex( 4, vIdx++ ); m_pMesh->setVertexIndex( 6, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 5, vIdx++ ); m_pMesh->setVertexIndex( 4, vIdx++ ); // Top m_pMesh->setVertexIndex( 2, vIdx++ ); m_pMesh->setVertexIndex( 3, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 7, vIdx++ ); m_pMesh->setVertexIndex( 6, vIdx++ ); m_pMesh->setVertexIndex( 2, vIdx++ ); // Bottom m_pMesh->setVertexIndex( 0, vIdx++ ); m_pMesh->setVertexIndex( 4, vIdx++ ); m_pMesh->setVertexIndex( 5, vIdx++ ); m_pMesh->setVertexIndex( 5, vIdx++ ); m_pMesh->setVertexIndex( 1, vIdx++ ); m_pMesh->setVertexIndex( 0, vIdx++ ); return m_pMesh; }