Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Multi-Colored Triangles

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Location
    Denver, CO
    Posts
    11

    Multi-Colored Triangles

    I'm exporting a triangle mesh with multiple colors and I'm wondering what the best approach would be.

    1. Use a 1D Texture - any examples?

    2. Sort the triangles by color and create separate geometries for each material.

    I'm favoring the first solution but the second might be more robust, except that my models may have 10-100 different colors. I'm new to DAE so let me know if I missed another way to d this.

    Mitch

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Another option would be to have a color array in your geometry. Then each vertex gets its own color, which gives you a lot of control. I think this solution is best because it's both simple to implement and efficient.

    Steve

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Location
    Denver, CO
    Posts
    11
    Just what I'm looking for. Since the documentation and samples don't seem to have much on this I assume I still need to set up a material. If so do I set the diffuse color to white?

    Thanks

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    It gets a little complicated because the Collada spec is vague with some of this.

    For example in OpenGL, in order to use per-vertex colors you have to disable lighting, in which case the material properties are ignored. However in Collada there is no standard way to specify that lighting should be disabled in the common profile materials (I used to use an <extra> for this). So when an implementation loads your geometry that has a color array, will it know to disable lighting? Because if it doesn't disable lighting, then the materials will be used and your colors will just be ignored. Unfortunately I've never used color arrays in Collada so I have no idea how well implementations work with them in practice. If you have a specific program in mind you plan to use you could do some testing and find out.

    This brings up a flaw in my suggestion of color arrays, which is that you can't use them with lighting (at least, not using the fixed function pipeline). If you need lighting also and you have to use the fixed function pipeline, the 1D texture is your best bet.

    But to answer your question, yes, a material is required for all geometry.

    Steve

  5. #5
    Junior Member
    Join Date
    Apr 2008
    Location
    Denver, CO
    Posts
    11
    Collada does seem to take simple things and make them more complicated.

    The lighting issue isn't that important right now since I;m looking to export to Google Earth. When the next version of ArcScene supports DAE this fall I'll worry about lighting if it's necessary.

    I did try a simple 1D texture (2 triangles + 2 colors) but only succeeded in creating infinite loops in GE and CollView. I tried downloading the verifier but it doesn't seem to work on Windows XP.

    I'll experiment with the Color Arrays and see how it goes.

    Mitch

  6. #6
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    When the next version of ArcScene supports DAE this fall I'll worry about lighting if it's necessary.
    Are you an ESRI employee then? Welcome to collada.org!
    Collada does seem to take simple things and make them more complicated.
    Heh, tell me about it.
    I did try a simple 1D texture (2 triangles + 2 colors) but only succeeded in creating infinite loops in GE and CollView. I tried downloading the verifier but it doesn't seem to work on Windows XP.
    If you post your Collada file I can probably help track down what the problem is.

  7. #7
    Junior Member
    Join Date
    Apr 2008
    Location
    Denver, CO
    Posts
    11
    Nope, I work for a RockWare, a geological software company, but I appreciate your help.

    Here's the code for my color array test. It shows the 2 triangles but it's ignoring the color array in GE and I don't see anything at all in CollView.

    Code :
     
    <?xml version="1.0"?>
     
    <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
    	<asset>
    		<contributor>
    			<author>Mitch</author>
    			<authoring_tool>RockPlot3D</authoring_tool>
    			<comments>my comments</comments>
    			<copyright>RockWare, Inc.</copyright>
    		</contributor>
    		<created>2008-4-7</created>
    		<modified>2008-4-7</modified>
    		<unit meter="0.01" name="centimeter"/>
    		<up_axis>Z_UP</up_axis>
    	</asset>
    	<library_cameras/>
    	<library_lights/>
    	<library_materials>
    		<material id="Blue" name="Blue">
    			<instance_effect url="#Blue-fx"/>
    		</material>
    	</library_materials>
    	<library_effects>
    		<effect id="Blue-fx">
    			<profile_COMMON>
    				<technique sid="common">
    					<phong>
    						<emission>
    							<color>0 0 0 1</color>
    						</emission>
    						<ambient>
    							<color>0 0 0 1</color>
    						</ambient>
    						<diffuse>
    							<color>0.137255 0.403922 0.870588 1</color>
    						</diffuse>
    						<specular>
    							<color>0.5 0.5 0.5 1</color>
    						</specular>
    						<shininess>
    							<float>16</float>
    						</shininess>
    						<reflective>
    							<color>0 0 0 1</color>
    						</reflective>
    						<reflectivity>
    							<float>0.5</float>
    						</reflectivity>
    						<transparent>
    							<color>0 0 0 1</color>
    						</transparent>
    						<transparency>
    							<float>1</float>
    						</transparency>
    						<index_of_refraction>
    							<float>0</float>
    						</index_of_refraction>
    					</phong>
    				</technique>
    			</profile_COMMON>
    		</effect>
    	</library_effects>
    	<library_geometries>
    		<geometry id="tri1-lib" name="tri1">
    			<mesh>
    				<source id="tri1-lib-positions" name="position">
    					<float_array id="tri1-lib-positions-array" count="18">
                        -150   150    0  
                           0     0  150  
                         150   150    0   
                        -150  -150    0  
                           0     0  150  
                         150  -150    0   
                         </float_array>
    					<technique_common>
    						<accessor count="6" offset="0" source="#tri1-lib-positions-array" stride="3">
    							<param name="X" type="float"/>
    							<param name="Y" type="float"/>
    							<param name="Z" type="float"/>
    						</accessor>
    					</technique_common>
    				</source>
    				<source id="tri1-lib-color" name="color">
    					<float_array id="tri1-lib-color-array" count="8">
    							0.137255 0.403922 0.870588 1                     
    							0.870588 0.403922 0.137255 1
    					</float_array>
    					<technique_common>
    						<accessor count="2" offset="0" source="#tri1-lib-color-array" stride="4">
    							<param name="R" type="float"/>
    							<param name="G" type="float"/>
    							<param name="B" type="float"/>
    							<param name="A" type="float"/>
    						</accessor>
    					</technique_common>
    				</source>
    				<vertices id="tri1-lib-vertices">
    					<input semantic="POSITION" source="#tri1-lib-positions"/>
    				</vertices>
    				<triangles count="2">
    					<input offset="0" semantic="VERTEX" source="#tri1-lib-vertices"/>
    					<input offset="1" semantic="COLOR" source="#tri1-lib-color"/>
     
     
    0 0   1 0   2 0  5 1  4 1  3 1</p>
    				</triangles>
    			</mesh>
    		</geometry>
    	</library_geometries>
    	<library_visual_scenes>
    		<visual_scene id="VisualSceneNode" name="untitled">
    			<node id="Tri1" name="Tri1">
    				<rotate sid="rotateZ">0 0 1 0</rotate>
    				<rotate sid="rotateY">0 1 0 0</rotate>
    				<rotate sid="rotateX">1 0 0 0</rotate>
    				<instance_geometry url="#tri1-lib">
                <bind_material>
                  <technique_common>
                     <instance_material symbol="BlueSG" target="#Blue"/>
                  </technique_common>
                </bind_material>
    				</instance_geometry>
    			</node>
    		</visual_scene>
    	</library_visual_scenes>
    	<scene>
    		<instance_visual_scene url="#VisualSceneNode"/>
    	</scene>
    </COLLADA>

  8. #8
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    xmllint reports some validation errors for your model.
    Code :
    ~/misc/domapp$ xmllint --noout --schema ~/misc/collada.xsd ~/models/mitch.dae
     
    /home/sthomas/models/mitch.dae:11: element created: Schemas validity error : Element '{http://www.collada.org/2005/11/COLLADASchema}created': '2008-4-7' is not a valid value of the atomic type 'xs:dateTime'.
     
    /home/sthomas/models/mitch.dae:12: element modified: Schemas validity error : Element '{http://www.collada.org/2005/11/COLLADASchema}modified': '2008-4-7' is not a valid value of the atomic type 'xs:dateTime'.
     
    /home/sthomas/models/mitch.dae:16: element library_cameras: Schemas validity error : Element '{http://www.collada.org/2005/11/COLLADASchema}library_cameras': Missing child element(s). Expected is one of ( {http://www.collada.org/2005/11/COLLADASchema}asset, {http://www.collada.org/2005/11/COLLADASchema}camera ).
     
    /home/sthomas/models/mitch.dae:17: element library_lights: Schemas validity error : Element '{http://www.collada.org/2005/11/COLLADASchema}library_lights': Missing child element(s). Expected is one of ( {http://www.collada.org/2005/11/COLLADASchema}asset, {http://www.collada.org/2005/11/COLLADASchema}light ).
    /home/sthomas/models/mitch.dae fails to validate
    I doubt that's why Google Earth isn't loading up the vertex colors though. Your data looks ok to me. GE probably just doesn't support vertex colors. You could report the problem to them, but who knows when it'd get fixed.

    I also tried loading your model into RT, but it looks like it doesn't support vertex colors either. Lame. Looks like your best bet is the 1D texture. GE does support textured Collada models.

  9. #9
    Junior Member
    Join Date
    Apr 2008
    Location
    Denver, CO
    Posts
    11
    Thanks, I'll follow up on the GE website.

    I'll work on my 1D texture attempt and if I have questions (which I'm sure I will) I'll start a new topic.

    One more semirelated question: I downloaded xmllint but it only seems to work with a DTD. Is there a Collada DTD available or is there a way to get it to work with Schema?

    Mitch

  10. #10
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Use xmllint to validate against a schema like this: xmllint --noout --schema collada.xsd model.dae

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •