Results 1 to 2 of 2

Thread: What's the meaning of source_array in deindexer()?

  1. #1

    What's the meaning of source_array in deindexer()?

    Hi there. What's the meaning of source_array in deindexer()?Is it the actual data of the positions, normals and texcoords? Here's the code:
    Code :
    std::map<domSource*,domSource*> source_map;
    		domSource_Array & source_array = mesh->getSource_array();
    		domUint source_count = source_array.getCount();
    		for(size_t i=0; i<source_count; i++)
    		{	//make a map of old source and new duplicat source
    			domSource* source = (domSource*) (domElement*) source_array[i];
    			domSourceRef newsource = (domSource*) (domElement*) source->clone();
    			ResetSource(newsource, vertexindex);
    			source_map[source] = newsource;
    What does the function ResetSource() do?Here's its definition:
    Code :
    void ResetSource(domSource * newsource, domUint new_vertex_size)
    	domUint stride = newsource->getTechnique_common()->getAccessor()->getStride();
    	domFloat_arrayRef newfloat_array = newsource->getFloat_array();
    	if (newfloat_array)
    		newfloat_array->setCount(new_vertex_size * stride);
    		newfloat_array->getValue().setCount((size_t)(new_vertex_size * stride));
    	domInt_arrayRef newint_array = newsource->getInt_array();
    	if (newint_array)
    		newint_array->setCount(new_vertex_size * stride);
    		newint_array->getValue().setCount((size_t)(new_vertex_size * stride));
    	domName_arrayRef newname_array = newsource->getName_array();
    	if (newname_array)
    		newname_array->setCount(new_vertex_size * stride);
    		newname_array->getValue().setCount((size_t)(new_vertex_size * stride));
    	domIDREF_arrayRef newidref_array = newsource->getIDREF_array();
    	if (newidref_array)
    		newidref_array->setCount(new_vertex_size * stride);
    		newidref_array->getValue().setCount((size_t)(new_vertex_size * stride));
    	domBool_arrayRef newbool_array = newsource->getBool_array();
    	if (newbool_array)
    		newbool_array->setCount(new_vertex_size * stride);
    		newbool_array->getValue().setCount((size_t)(new_vertex_size * stride));

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Foster City, CA
    Hi there. What's the meaning of source_array in deindexer()?Is it the actual data of the positions, normals and texcoords?
    Yes, the <source> elements contain the actual arrays of data. A mesh can have any number of <source>s, and these will be stored as an array in domMesh. That's what source_array is.
    What does the function ResetSource() do?
    A <source> element contains an array of data, but there are many different types of arrays it could contain. It might be an array of integers, or an array of floats, or an array of IDs. There are different uses for each of these in Collada. This function sets the length of the daeArray object, as well as the "count" attribute on the array (unfortunately the DOM client needs to maintain the "count" attribute manually) to the specified value, regardless of what the array type is. I would have worked around the type system to shorten this code and make it simpler, but this code should work fine.

    If you want to understand how the deindexer works you might find it useful to step through the code in a debugger.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean