1 /* 2 * Copyright 2006 Sony Computer Entertainment Inc. 3 * 4 * Licensed under the MIT Open Source License, for details please see license.txt or the website 5 * http://www.opensource.org/licenses/mit-license.php 6 * 7 */ 8 9 #include <dae.h> 10 #include <dae/daeDom.h> 11 #include <dom/domEffect.h> 12 #include <dae/daeMetaCMPolicy.h> 13 #include <dae/daeMetaSequence.h> 14 #include <dae/daeMetaChoice.h> 15 #include <dae/daeMetaGroup.h> 16 #include <dae/daeMetaAny.h> 17 #include <dae/daeMetaElementAttribute.h> 18 19 daeElementRef 20 domEffect::create(DAE& dae) 21 { 22 domEffectRef ref = new domEffect(dae); 23 return ref; 24 } 25 26 #include <dom/domProfile_GLSL.h> 27 #include <dom/domProfile_COMMON.h> 28 #include <dom/domProfile_CG.h> 29 #include <dom/domProfile_GLES.h> 30 31 daeMetaElement * 32 domEffect::registerElement(DAE& dae) 33 { 34 daeMetaElement* meta = dae.getMeta(ID()); 35 if ( meta != NULL ) return meta; 36 37 meta = new daeMetaElement(dae); 38 dae.setMeta(ID(), *meta); 39 meta->setName( "effect" ); 40 meta->registerClass(domEffect::create); 41 42 daeMetaCMPolicy *cm = NULL; 43 daeMetaElementAttribute *mea = NULL; 44 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 45 46 mea = new daeMetaElementAttribute( meta, cm, 0, 0, 1 ); 47 mea->setName( "asset" ); 48 mea->setOffset( daeOffsetOf(domEffect,elemAsset) ); 49 mea->setElementType( domAsset::registerElement(dae) ); 50 cm->appendChild( mea ); 51 52 mea = new daeMetaElementArrayAttribute( meta, cm, 1, 0, -1 ); 53 mea->setName( "annotate" ); 54 mea->setOffset( daeOffsetOf(domEffect,elemAnnotate_array) ); 55 mea->setElementType( domFx_annotate_common::registerElement(dae) ); 56 cm->appendChild( mea ); 57 58 mea = new daeMetaElementArrayAttribute( meta, cm, 2, 0, -1 ); 59 mea->setName( "image" ); 60 mea->setOffset( daeOffsetOf(domEffect,elemImage_array) ); 61 mea->setElementType( domImage::registerElement(dae) ); 62 cm->appendChild( mea ); 63 64 mea = new daeMetaElementArrayAttribute( meta, cm, 3, 0, -1 ); 65 mea->setName( "newparam" ); 66 mea->setOffset( daeOffsetOf(domEffect,elemNewparam_array) ); 67 mea->setElementType( domFx_newparam_common::registerElement(dae) ); 68 cm->appendChild( mea ); 69 70 mea = new daeMetaElementArrayAttribute( meta, cm, 4, 1, -1 ); 71 mea->setName( "fx_profile_abstract" ); 72 mea->setOffset( daeOffsetOf(domEffect,elemFx_profile_abstract_array) ); 73 mea->setElementType( domFx_profile_abstract::registerElement(dae) ); 74 cm->appendChild( mea ); 75 76 77 mea = new daeMetaElementArrayAttribute( meta, cm, 4, 1, -1 ); 78 mea->setName( "profile_GLSL" ); 79 mea->setOffset( daeOffsetOf(domEffect,elemFx_profile_abstract_array) ); 80 mea->setElementType( domProfile_GLSL::registerElement(dae) ); 81 cm->appendChild( mea ); 82 83 84 mea = new daeMetaElementArrayAttribute( meta, cm, 4, 1, -1 ); 85 mea->setName( "profile_COMMON" ); 86 mea->setOffset( daeOffsetOf(domEffect,elemFx_profile_abstract_array) ); 87 mea->setElementType( domProfile_COMMON::registerElement(dae) ); 88 cm->appendChild( mea ); 89 90 91 mea = new daeMetaElementArrayAttribute( meta, cm, 4, 1, -1 ); 92 mea->setName( "profile_CG" ); 93 mea->setOffset( daeOffsetOf(domEffect,elemFx_profile_abstract_array) ); 94 mea->setElementType( domProfile_CG::registerElement(dae) ); 95 cm->appendChild( mea ); 96 97 98 mea = new daeMetaElementArrayAttribute( meta, cm, 4, 1, -1 ); 99 mea->setName( "profile_GLES" ); 100 mea->setOffset( daeOffsetOf(domEffect,elemFx_profile_abstract_array) ); 101 mea->setElementType( domProfile_GLES::registerElement(dae) ); 102 cm->appendChild( mea ); 103 104 mea = new daeMetaElementArrayAttribute( meta, cm, 5, 0, -1 ); 105 mea->setName( "extra" ); 106 mea->setOffset( daeOffsetOf(domEffect,elemExtra_array) ); 107 mea->setElementType( domExtra::registerElement(dae) ); 108 cm->appendChild( mea ); 109 110 cm->setMaxOrdinal( 5 ); 111 meta->setCMRoot( cm ); 112 // Ordered list of sub-elements 113 meta->addContents(daeOffsetOf(domEffect,_contents)); 114 meta->addContentsOrder(daeOffsetOf(domEffect,_contentsOrder)); 115 116 117 // Add attribute: id 118 { 119 daeMetaAttribute *ma = new daeMetaAttribute; 120 ma->setName( "id" ); 121 ma->setType( dae.getAtomicTypes().get("xsID")); 122 ma->setOffset( daeOffsetOf( domEffect , attrId )); 123 ma->setContainer( meta ); 124 ma->setIsRequired( true ); 125 126 meta->appendAttribute(ma); 127 } 128 129 // Add attribute: name 130 { 131 daeMetaAttribute *ma = new daeMetaAttribute; 132 ma->setName( "name" ); 133 ma->setType( dae.getAtomicTypes().get("xsNCName")); 134 ma->setOffset( daeOffsetOf( domEffect , attrName )); 135 ma->setContainer( meta ); 136 137 meta->appendAttribute(ma); 138 } 139 140 meta->setElementSize(sizeof(domEffect)); 141 meta->validate(); 142 143 return meta; 144 } 145 146