ContentManager.load<MyClass>(filename)

hi i have a proplem

i have created a xml file

look like this:

< xml version="1.0" encoding="UTF-8" >

<XnaContent>

<Asset Type="EvoFxEngine.EvoFxMesh.EvoFxMeshProcessor">

<EvoFXMesh>

<EvoFXProperties>

<EvoFXVersion Version="0.5" />

<EvoFXName Name="SkyDomeMesh" />

<EvoFXClassification Classification="SkyObject" />

<EvoFXNumberOfVertex NumberOfVertex="55" />

<EvoFXNumberOfFaces NumberOfFaces="80" />

</EvoFXProperties>

<VertexData>

<Vertex X="2102,924" Y="3402,603" Z="-4,999756" />

<Vertex X="649,8392" Y="3402,603" Z="1995" />

<Vertex X="-0,000122" Y="4000" Z="-4,999756" />

<Vertex X="2752,764" Y="2102,924" Z="1995" />

<Vertex X="1105,573" Y="1788,854" Z="3397,604" />

<Vertex X="-1051,463" Y="2102,924" Z="3231,068" />

<Vertex X="-1701,302" Y="3402,603" Z="1231,068" />

<Vertex X="-0,000122" Y="4000" Z="-4,999756" />

<Vertex X="3577,709" Y="1788,854" Z="-4,999756" />

<Vertex X="3804,226" Y="0" Z="1231,068" />

<Vertex X="2351,141" Y="0" Z="3231,068" />

<Vertex X="-0,000234" Y="0" Z="3995" />

<Vertex X="2752,764" Y="2102,924" Z="-2005" />

<Vertex X="3804,226" Y="0" Z="-1241,067" />

<Vertex X="3402,603" Y="-2102,924" Z="-4,999236" />

<Vertex X="2894,427" Y="-1788,854" Z="2097,925" />

<Vertex X="1051,462" Y="-2102,924" Z="3231,068" />

<Vertex X="649,8395" Y="3402,603" Z="-2005" />

<Vertex X="1105,573" Y="1788,854" Z="-3407,603" />

<Vertex X="2351,142" Y="0" Z="-3241,067" />

<Vertex X="2894,428" Y="-1788,854" Z="-2107,923" />

<Vertex X="-0,000122" Y="4000" Z="-4,999756" />

<Vertex X="-2894,427" Y="1788,854" Z="2097,924" />

<Vertex X="-2351,141" Y="0" Z="3231,068" />

<Vertex X="-3804,226" Y="0" Z="1231,068" />

<Vertex X="-2752,764" Y="-2102,924" Z="1995" />

<Vertex X="-1105,573" Y="-1788,854" Z="3397,603" />

<Vertex X="-649,8396" Y="-3402,603" Z="1995" />

<Vertex X="1701,302" Y="-3402,603" Z="1231,068" />

<Vertex X="-0,000122" Y="-4000" Z="-4,999756" />

<Vertex X="1701,302" Y="-3402,603" Z="-1241,067" />

<Vertex X="-0,000122" Y="-4000" Z="-4,999756" />

<Vertex X="1051,462" Y="-2102,925" Z="-3241,067" />

<Vertex X="-649,8397" Y="-3402,603" Z="-2005" />

<Vertex X="-0,000122" Y="-4000" Z="-4,999756" />

<Vertex X="-7,8E-05" Y="0" Z="-4005" />

<Vertex X="-1105,573" Y="-1788,854" Z="-3407,603" />

<Vertex X="-2752,764" Y="-2102,924" Z="-2005" />

<Vertex X="-2102,924" Y="-3402,603" Z="-4,99994" />

<Vertex X="-0,000122" Y="-4000" Z="-4,999756" />

<Vertex X="-1051,462" Y="2102,924" Z="-3241,068" />

<Vertex X="-2351,141" Y="0" Z="-3241,068" />

<Vertex X="-3804,226" Y="0" Z="-1241,068" />

<Vertex X="-3577,709" Y="-1788,854" Z="-5,000068" />

<Vertex X="-1701,302" Y="3402,603" Z="-1241,068" />

<Vertex X="-2894,427" Y="1788,854" Z="-2107,925" />

<Vertex X="-3402,603" Y="2102,924" Z="-5,000248" />

<Vertex X="-3804,226" Y="0" Z="1231,068" />

<Vertex X="-2752,764" Y="-2102,924" Z="1995" />

<Vertex X="-0,000122" Y="4000" Z="-4,999756" />

<Vertex X="-649,8396" Y="-3402,603" Z="1995" />

<Vertex X="-0,000122" Y="-4000" Z="-4,999756" />

<Vertex X="-2894,427" Y="1788,854" Z="2097,924" />

<Vertex X="-1701,302" Y="3402,603" Z="1231,068" />

<Vertex X="-0,000122" Y="4000" Z="-4,999756" />

</VertexData>

<FaceData>

<Face A="0" B="1" C="2" />

<Face A="3" B="1" C="0" />

<Face A="3" B="4" C="1" />

<Face A="4" B="5" C="1" />

<Face A="5" B="6" C="1" />

<Face A="1" B="6" C="7" />

<Face A="8" B="3" C="0" />

<Face A="3" B="8" C="9" />

<Face A="3" B="9" C="10" />

<Face A="4" B="3" C="10" />

<Face A="10" B="11" C="4" />

<Face A="5" B="4" C="11" />

<Face A="12" B="8" C="0" />

<Face A="8" B="12" C="13" />

<Face A="13" B="9" C="8" />

<Face A="14" B="9" C="13" />

<Face A="14" B="15" C="9" />

<Face A="10" B="9" C="15" />

<Face A="15" B="16" C="10" />

<Face A="16" B="11" C="10" />

<Face A="12" B="0" C="17" />

<Face A="18" B="12" C="17" />

<Face A="12" B="18" C="19" />

<Face A="12" B="19" C="13" />

<Face A="13" B="19" C="20" />

<Face A="20" B="14" C="13" />

<Face A="17" B="0" C="21" />

<Face A="5" B="22" C="6" />

<Face A="22" B="5" C="23" />

<Face A="23" B="24" C="22" />

<Face A="25" B="24" C="23" />

<Face A="26" B="25" C="23" />

<Face A="25" B="26" C="27" />

<Face A="5" B="11" C="23" />

<Face A="23" B="11" C="26" />

<Face A="16" B="26" C="11" />

<Face A="26" B="16" C="27" />

<Face A="16" B="28" C="27" />

<Face A="27" B="28" C="29" />

<Face A="16" B="15" C="28" />

<Face A="15" B="14" C="28" />

<Face A="14" B="30" C="28" />

<Face A="28" B="30" C="31" />

<Face A="14" B="20" C="30" />

<Face A="20" B="32" C="30" />

<Face A="32" B="33" C="30" />

<Face A="30" B="33" C="34" />

<Face A="32" B="20" C="19" />

<Face A="32" B="19" C="35" />

<Face A="36" B="32" C="35" />

<Face A="32" B="36" C="33" />

<Face A="36" B="37" C="33" />

<Face A="37" B="38" C="33" />

<Face A="33" B="38" C="39" />

<Face A="35" B="19" C="18" />

<Face A="18" B="40" C="35" />

<Face A="40" B="41" C="35" />

<Face A="35" B="41" C="36" />

<Face A="37" B="36" C="41" />

<Face A="37" B="41" C="42" />

<Face A="43" B="37" C="42" />

<Face A="37" B="43" C="38" />

<Face A="40" B="18" C="17" />

<Face A="40" B="17" C="44" />

<Face A="45" B="40" C="44" />

<Face A="40" B="45" C="41" />

<Face A="42" B="41" C="45" />

<Face A="45" B="46" C="42" />

<Face A="46" B="47" C="42" />

<Face A="42" B="47" C="43" />

<Face A="48" B="43" C="47" />

<Face A="43" B="48" C="38" />

<Face A="44" B="17" C="49" />

<Face A="48" B="50" C="38" />

<Face A="38" B="50" C="51" />

<Face A="46" B="52" C="47" />

<Face A="52" B="46" C="53" />

<Face A="46" B="44" C="53" />

<Face A="53" B="44" C="54" />

<Face A="46" B="45" C="44" />

</FaceData>

<MaterialData>

<AmbientColor Alpha="1" Red="0" Green="0" Blue="0" />

<DiffuseColor Alpha="1" Red="1" Green="1" Blue="1" />

<EmissiveColor Alpha="1" Red="0" Green="0" Blue="0" />

<SpecularColor Alpha="1" Red="1" Green="1" Blue="1" />

<SpecularSharpness Sharpness="2" />

</MaterialData>

</EvoFXMesh>

</Asset>

</XnaContent>

and the loader class and namespace

using System;

using System.Collections.Generic;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework.Content;

using System.Xml;

using EvoFX.EvoFormatDescription.SkyDome;

using EvoFX.EvoFormatDescription.Common;

namespace EvoFxEngine.EvoFxMesh

{

[Serializable]

public class EvoFxMeshProcessor

{

private Int32 NumberOfVertex = 0;

private Int32 NumberOfFaces = 0;

private EvoSkyDomeVertex[] MyVertex;

private EvoFaceFormat[] MyFace;

public void Load(string assetName)

{

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(assetName);

Int32 Counter = 0;

//////////////////////////////////////////////////////////////////////////////////////////

XmlNode vertices = xmlDoc.SelectSingleNode("/XnaContent/EvoFXMesh/VertexData");

MyVertex = new EvoSkyDomeVertex[vertices.ChildNodes.Count];

foreach (XmlNode vertex in vertices.ChildNodes)

{

MyVertex[Counter] = new EvoSkyDomeVertex(

float.Parse(vertex.Attributes["x"].Value),

float.Parse(vertex.Attributes["y"].Value),

float.Parse(vertex.Attributes["z"].Value)

);

Counter += 1;

NumberOfVertex += 1;

}

Console.WriteLine("num vertex : " + NumberOfVertex.ToString());

//////////////////////////////////////////////////////////////////////////////////////////

Counter = 0;

XmlNode faces = xmlDoc.SelectSingleNode("/XnaContent/EvoFXMesh/FaceData");

MyFace = new EvoFaceFormat[faces.ChildNodes.Count];

foreach (XmlNode face in faces.ChildNodes)

{

MyFace[Counter + 0] = new EvoFaceFormat(Int32.Parse(face.Attributes["a"].Value));

MyFace[Counter + 1] = new EvoFaceFormat(Int32.Parse(face.Attributes["b"].Value));

MyFace[Counter + 2] = new EvoFaceFormat(Int32.Parse(face.Attributes["c"].Value));

Counter += 3;

NumberOfFaces += 3;

}

Console.WriteLine("num faces : " + NumberOfFaces.ToString());

//////////////////////////////////////////////////////////////////////////////////////////

}

public EvoFxMeshProcessor()

{

}

}

}

the main proplem is i am trying to use content xml importer widt

no processoing requrie

but i keep getting this error

Error 6 There was an error while deserializing intermediate XML. Cannot find type "EvoFxEngine.EvoFxMesh.EvoFxMeshProcessor". C:\Documents and Settings\Michael Hansen\Desktop\Vista\EvoFXTEST\EvoFXTEST\Content\Skydome\SkyDome1.xml 3 8 EvoFXTEST

hope some one can help




Answer this question

ContentManager.load<MyClass>(filename)

  • nattylife

    I think you have a misunderstanding of how this works, here's a sample

    code:

    namespace MyGame
    {
    public class MyObject
    {
    public int MyInt { get; set; }
    public String MyString { get; set; }
    }
    }


    xml:

    <XnaContent>
    <Asset Type="MyGame.MyObject">
    <MyInt>10</MyInt>
    <MyString>This is my string</MyString>
    </Asset>
    </XnaContent>

    The XmlImporter will create a MyObject and assign its properties based on the Xml definition. You can use attributes on the class to tell the XmlImporter to ignore properties, or make them optional.

    You don't want the importer to create an instance of your processor :) You want it to create an instance of your object, it will then get passed to a processor. I think what you want to do is write your own importer and send it to the mesh processor.

  • ContentManager.load<MyClass>(filename)