accessor param / attribute element count
Feeling Software Community
January 06, 2009, 06:06:11 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: accessor param / attribute element count  (Read 2573 times)
Erik Faye-Lund
Newbie
*
Posts: 3


View Profile
« on: January 04, 2008, 06:05:46 pm »

I'm working on a tool to convert COLLADA files to my engines own format, and I'm having some issues with fetching vertex attributes.

The FCDGeometrySource::GetValue(index) provide me with a pointer to the first element in an attribute. The problem is that for some of the vertex-attributes (like texture coordinates), the element count can vary - 2D textures can use 2 component coordinates, 3D textures or projected 2D textures can use 3 or 4 coordinates. And some COLLADA exporters vary the count of texture coordinates they output - the version of ColladaMax I have installed writes three component texture coordinates, whereas most other exporters writes two component texture coordinates.

The way I understand the COLLADA-spec, the amount of elements to utilize for a given vertex attribute is defined by the amount of param-subtags in the accessor-tag for the given source.

Is there some way of finding this count from the FCollada-API?

If not, I must make a guess, risking reading an invalid r-coordinate ("r" is OpenGL terminology - ColladaMax seems to call it "P") for a set of texture coordinates that doesn't have one, causing incorrect mapping of textures using those coordinates. Or worse, I could end up discarding important information for meshes that are using the vertex attributes for non-trivial purposes. I often use vertex-attributes to pre-calculate different kinds of usage-specific data, and I'd like to be able to do this before exporting from COLLADA.

I have seen some people using the stride to guess what the size should be. This is not a robust solution since vertex data can be interleaved inside a single float-array, causing mismatch between the size and stride. And in my case, they usually are.
Logged
Erik Faye-Lund
Newbie
*
Posts: 3


View Profile
« Reply #1 on: January 04, 2008, 06:30:47 pm »

In related news: FCDGeometrySource::GetValueCount() seems to be implemented in a non-robust way by dividing the elements in the source array by the stride in stead of using the count-attribute of the accessor-tag. While this works well in most practical cases, there are possible to construct cases where this breaks by padding the array with dummy values in the end.

To be honest, I haven't yet been able to figure out how to construct COLLADA files with multiple accessors to a single stream of data, even though the spec says explicitly that it is possible. Any clue on this so I can test it?
Logged
Erik Faye-Lund
Newbie
*
Posts: 3


View Profile
« Reply #2 on: January 23, 2008, 07:28:46 am »

Sorry for bumping this, but I'm really looking for a solution to this. I've been able to progress in my current project since the data is always exported from 3DS Max, but an upcoming project this isn't the case.
Logged
Guillaume Laforte
Administrator
Hero Member
*****
Posts: 713



View Profile
« Reply #3 on: January 24, 2008, 04:03:51 pm »

Quote
To be honest, I haven't yet been able to figure out how to construct COLLADA files with multiple accessors to a single stream of data, even though the spec says explicitly that it is possible. Any clue on this so I can test it?

FCollada doesn't support multiple accessors. In COLLADA, multiple accessors overwrite each other and you would have to use different <technique> to add some. Since we use FCDExtra to expose adding custom <technique> elements, you could write it yourself, but only the information from the <technique_common>'s <accessor> would be used by FCollada, on import.

Remember that you can also add your custom sources, using the EXTRA semantic (or adding your own in the FUDaeGeometryInput enumerated type).

If you want to interleave and mix data within one source, such as POSITION/NORMAL/TEXCOORD in a 8-stride data source, FCollada can handle the 8D data source, but will not help you identify the data values in any way, since we do not parse the <accessor><param> values.

I hope this clears things up a bit..
Logged

Guillaume Laforte
Feeling Software Inc.
Feeling Software is now hiring!
Send CV to hiring(at)feelingsoftware.com
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!