Roger James wrote:
>>> It fixes the file name but I still don't get any textures. I cannot see
>>> where my "material_effect-sampler" is referenced.
>> It would properly be referenced by <diffuse> or one of the others (eg
>> <ambient>, <specular>, etc.). They are defined by either a <color> or a
>> <texture>. For your example, fix:
>>
>>
>> <diffuse>
>> <texture texture="material_effect-sampler" texcoord="texcoord0"/>
>> </diffuse>
>>
>> ... on whichever of the shaders (eg <phong> is a conceptual shader) you
>> want using the texture.
>>
>> Regards,
>> Marcus
>>
>
> The dae file was generated by the OSG dae writer.
>
> I tracked this problem down to the following code in
> daeWriter::processMaterial
>
> cot = daeSafeCast< domCommon_color_or_texture_type >( phong->createAndPlace(
> "ambient" ) );
>
> ... (stuff deleted
>
> //### check if we really have a texture
> if ((tex == NULL) || (!cot->getTexture()))
> {
>
> cot->getTexture will always return NULL because the texture if any has been
> set on the <diffuse> element. This means that if you have a diffuse colour
> set the diffuse element that has been setup is replaced with one which just
> references the diffuse colour.
>
> I removed the call to cot->getTexture and the code now generates
>
> <diffuse>
> <texture texture="material_effect-sampler" texcoord="texcoord0">
> <extra type="color">
> <technique profile="SCEI">
> <color> 0 0 0 1</color>
> </technique>
> </extra>
> </texture>
> </diffuse>
>
> rather then the
>
> <diffuse>
> <color>0.7 0.7 0.7 1 </color>
> </diffuse>
>
> generated previously.
>
> Andy, can you tell me what the code was intended to do and what I should
> replace the call to cot->getTexture with if anything.
Yeah I'm sorry. That's definately a bug.
The code is trying to map openGL fixed function to a COLLADA phong
shader. The assumption I made is that openGL's texturing is only
diffuse. You can multitexture but it all works on the diffuse color of a
material. (I may be wrong.. I am not an openGL expert). So in the code
in processMaterial, before the snippet in question, I process the osg
texture and create a <surface> and <sampler> <newparam>s and the
<diffuse> element with the <texture> reference.
Then the code in question is supposed to check if there was a texture
processed. If there wasn't one it creates the <color> child for
<diffuse>. If there was one it adds the <extra> with a <color> because
COLLADA allows only a <color> or a <texture> while openGL you can
specify both for <diffuse>.
The if statement should be
if ( phong->getDiffuse() == NULL )
This works because if there was no texture there would not be a diffuse
element created already.
And as you figured out in your more recent emails the %20 encoding
problem has been fixed. And in a few minutes (time to take to update the
svn) the crash because xmlns is missing will be fixed too.
-Andy
>
> Putting in a temporary hack has allowed me to see that I am still not
> getting the file name generation right on Windows.
>
>
> <init_from>../../../environ%20project/environ/terraindata/vtp-apps-data-and-
> plantlib/buildingmodels/cement_block1_256.jpg</init_from>
>
> C:\Temp\colladatest\models>osgviewer brantholme.dae
> processTexture(./material_effect-sampler)
> Warning: could not find file
> "C:/environ%20project/environ/terraindata/vtp-apps-
> data-and-plantlib/buildingmodels/cement_block1_256.jpg"
> Time to load = 0.0273278
>
> I guess it is back to reading RFCs again to see if % encoding should be
> being done/undone.
>
> Roger
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/