certain COLLADA-DOM 2.2 objects fail

When programming with the COLLADA-DOM, there are 3 sections that refuse to initialize properly. I don’t know what it is i’m doing wrong, could you please look over these small snippets? I’ve removed everything but the necessary parts.

	DAE dae;
	domCOLLADA * root = dae.add(file_name);
		domMaterial*               lowmat = (domMaterial*) matlib->add("material");
		domInstance_effect*               loweff = (domInstance_effect*) lowmat->add("instance_effect");
		material_id = lexical_cast<std::string>(i) + "-material-low";
		lowmat->setId(material_id.c_str());
		loweff->setUrl("#lambert-fx");

			domInstance_effect::domSetparam* lwprmdf = (domInstance_effect::domSetparam*) loweff->add("setparam");
			lwprmdf->setRef("diffuse");
			domCommon_color_or_texture_type* lwtexdf = (domCommon_color_or_texture_type*) lwprmdf->add("texture");

Here, I can not add any children to the domInstance_effect::domSetparam* object. When I compile it the element doesn’t add itself, and when I try set a parameter the compiler fails and says: use of undefined type ‘domCommon_color_or_texture_type’

I have the same problems for these snippets too:

	domLibrary_effects* libeff = (domLibrary_effects*) root->add("library_effects");
	domEffect* lambert = (domEffect*) libeff->add("effect");
	lambert->setId("lambert-fx");
	domProfile_COMMON* lamprof = (domProfile_COMMON*) lambert->add("profile_COMMON");
	domTechnique* lamtech = (domTechnique*) lamprof->add("technique");

domTechnique doesn’t show up and when I set parameters I get the same compile errors as above.

Also

	domTriangles* triangles = (domTriangles*) mesh->add("triangles");
	domInputLocal* triinput = (domInputLocal*) triangles->add("input");
	domP*              trip = (domP*) triangles->add("p");

Here I can’t set any of the parameters for the domInputLocal object, it compiles okay but the fields are blank. Same when I set chardata for the domP* object.

I reconstructed your code snippets, and recompiled the code without problem. I also disabled most of the code to run just the last part, it ran without problem. Please see the test code below:

DefineTest(autoResolve) {
   DAE dae;
	const char* uri = "cube.dae";
#if 0
	// Test the new 'add' functions
	daeElement* root = dae.add(uri);
     domMaterialRef lib;
     domMaterial* matlib = (domMaterial*)(domElement*)lib; 
     domMaterial* lowmat = (domMaterial*) matlib->add("material");
     domInstance_effect* loweff = (domInstance_effect*) lowmat->add("instance_effect");

     std::string material_id = "-material-low";

     lowmat->setId(material_id.c_str());
     loweff->setUrl("#lambert-fx");

     domInstance_effect::domSetparam* lwprmdf = (domInstance_effect::domSetparam*) loweff->add("setparam");
     lwprmdf->setRef("diffuse");
     domCommon_color_or_texture_type* lwtexdf = (domCommon_color_or_texture_type*) lwprmdf->add("texture");

	
     domLibrary_effects* libeff = (domLibrary_effects*) root->add("library_effects");
     domEffect* lambert = (domEffect*) libeff->add("effect");
     lambert->setId("lambert-fx");
     domProfile_COMMON* lamprof = (domProfile_COMMON*) lambert->add("profile_COMMON");
     domTechnique* lamtech = (domTechnique*) lamprof->add("technique");

#endif
    CheckResult(dae.open(lookupTestFile("cube.dae")));

    int count = (int)(dae.getDatabase()->getElementCount(NULL, "geometry" ));
    daeElement * element = 0;
    for (int current = 0; current < 1; current++) {
	    dae.getDatabase()->getElement(&element, current, NULL, "geometry");
    }

    domGeometry*	thisGeometry = (domGeometry *) element;
    domMesh* mesh = thisGeometry->getMesh();
    domTriangles* triangles = (domTriangles*) mesh->add("triangles");
    domInputLocal* triinput = (domInputLocal*) triangles->add("input");
    domP*              trip = (domP*) triangles->add("p");

    return testResult(true);

Perhaps you forgot to include the needed DOM dae header files?

What does it mean when you say “domTechnique doesn’t show up”?

Can you narrow the problem down by including the compiler error messages along with the offending code section? It is not entirely clear to me which code section does not compile and which compiles OK but runs with logic error.

I also compiled and ran the first of the several sections of code without problem. See below:


    DAE dae;
    const char* file_name = "cube.dae"
    domCOLLADA * root = dae.add(file_name);

If the code was compiled OK, is the “file_name” path valid? i.e. is the app finding “filen_ame”
If so, is file_name validated OK against the COLLADA 1.4 schema?

There are the headers I’ve included:
#include <dom/domCOLLADA.h>
#include <dom/domAsset.h>
#include “dae.h”

Even with your modified snippet I still get the compiler error:
1>.\convert_mesh.cpp(273) : error C2027: use of undefined type ‘domProfile_COMMON’
1> Z:\Projects\Revival\external-libs\collada-dom\dom\include\1.4\dom/domElements.h(774) : see declaration of ‘domProfile_COMMON’

Sorry for not being clearer. When I say that the domTechnique doesn’t show up, what I mean is that the element is not being appended to the DAE document when I write it to disk.

The problem with this snippet:

    domTriangles* triangles = (domTriangles*) mesh->add("triangles");
    domInputLocal* triinput = (domInputLocal*) triangles->add("input");
    domP*              trip = (domP*) triangles->add("p");

is when I set the attributes for domInputLocal and domP, the values fail to append to the document when I write it. So when i’ve set the semantic and source of the input and the char data for p, the DAE looks like this below. (I have no problem setting the triangle count).

				<triangles count="2936">
					<input offset="0" semantic="" source="" set="0"/>
					


				</triangles>

Thanks for the help, I’m really stuck here.

Perhaps you forgot to include the needed DOM dae header files?

Thanks for that, I didn’t realize I had to include more header files because I havn’t had problems up until now. 8)

Now I include #include “dom/domProfile_COMMON.h” for example there are no more problems.

Actually, I have 2 more problems.

	domTriangles* triangles = (domTriangles*) mesh->add("triangles");
	domInputLocal* triinput = (domInputLocal*) triangles->add("input");
	domP*              trip = (domP*) triangles->add("p");

	triangles->setCount(index[0].index_s / 3);  // Works

	triinput->setSemantic("VERTEX"); // Doesn't write to the DAE document.
	triinput->setSource("#this");  // Access Violation when I compile the program.
	trip->setCharData(index_arr.c_str()); // Doesn't write to the DAE document. 

Check the comments on the side to indicate the problem. I have included the headers (which previously I hadn’t):
#include <dom/domTriangles.h>
#include <dom/domInputLocal.h>
#include <dom/domP.h>

Also, I can’t find any methods to set the protected members in the shader class (for example, domProfile_COMMON::domTechnique::domPhong).
domPhong has the member domPhong::elemAmbient, how do I set this? I’ve scanned the wiki, programming guide and programming reference but I can’t find it. :?:

Please look at addSource() addInput(), addGeometry() in sample code
\colladadom\dom est\1.4\export.cpp

They show the correct usage of these methods.

Also, I can’t find any methods to set the protected members in the shader class (for example, domProfile_COMMON::domTechnique::domPhong).
domPhong has the member domPhong::elemAmbient, how do I set this? I’ve scanned the wiki, programming guide and programming reference but I can’t find it. :?:

Check out domProfile_COMMON::domTechnique::domPhong::registerElement(DAE& dae) in colladadom\dom\src\1.4\dom[b]domProfile_COMMON.cpp
[/b]

	mea = new daeMetaElementAttribute( meta, cm, 1, 0, 1 );
	mea->setName( "ambient" );
	mea->setOffset( daeOffsetOf(domProfile_COMMON::domTechnique::domPhong,elemAmbient) );
	mea->setElementType( domCommon_color_or_texture_type::registerElement(dae) );
	cm->appendChild( mea );

Thanks for the links, this has really helped. Cheers!