• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineHow to override the DigitalRune.Geometry.Shapes.HeightField Content Processor?How to override the DigitalRune.Geometry.Shapes.HeightField Content Processor?
Previous
 
Next
New Post
1/31/2011 2:49 PM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
How to override the DigitalRune.Geometry.Shapes.HeightField Content Processor? 
Hi All, I would like to speed up the process of loading my "worlds" by extending the HeightField Processor to read in some data from an .xml file and use that data to automatically fill in the .Array attribute of the HeightField object. Ideally I'd like to save an .xml file that looked like this:

grid
row 51.63115311, 50.12641907, 48.21897507, 59.31640244, 62.18334961, 57.45678329 /row
row 49.28093719, 48.37781906, 61.30075455, 67.58383179, 68.23635864, 70.09233856 /row
/grid

etc . . . and end up with a compile .xnb of a HeightField type that I could just load in the Load Content() method like this

heightfield = _content.Load("Terrain/myTerrain.xml");

Right now I'm hard coding the creation inside of the loadContent() method and this works fine on the PC but on the Xbox it's extremely slow once the .Array[,] is over 60X60.

The good news is converting all my terrain to your HeightField method has DRAMATICALLY improved the framerate of collisions on the terrain, instead of using the actual mesh object. But I have got to get load times reduced as right now it's abysmal waiting on that array to intialize as I step down 3000 + lines of code.

I'm sure this is probably something really simple to implement, but I'm not very good with the XNA piepline.

I thought I could just extend your DigitalRune.Geometry.Shapes.HeightFieldProcessor but I can't find that class, I can find the Writer and the Reader, but not the processor. . .

Any help on the right way to do this would be very much appreciated!! Thanks1
 
New Post
1/31/2011 4:12 PM
 
MartinG
7th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 448
Re: How to override the DigitalRune.Geometry.Shapes.HeightField Content Processor? 
Hi,

there is no HeightFieldProcessor in DigitalRune Geometry. But you can create your own height-field processor.
If you already have the height data stored in an XML-file you could do something like this:

Create a custom content importer that loads the XML-file.
using System.Xml;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace CustomContentProcessor
{
[ContentImporter(".xml", DisplayName = "XML File Importer")]
public class XmlFileImporter : ContentImporter<XmlDocument>
{
public override XmlDocument Import(string filename, ContentImporterContext context)
{
XmlDocument document = new XmlDocument();
document.Load(filename);
return document;
}
}
}
Create a custom content processor that parses the XML-file and creates a height-field.
using System.Xml;
using DigitalRune.Geometry.Shapes;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace CustomContentProcessor
{
[ContentProcessor(DisplayName = "Height-Field Processor")]
public class HeightFieldProcessor : ContentProcessor<XmlDocument, HeightField>
{
public override HeightField Process(XmlDocument input, ContentProcessorContext context)
{
// 1. Parse XML data.
// 2. Create a HeightField.
HeightField heightField = new HeightField();

heightField.WidthX = ...
heightField.WidthZ = ...
heightField.Array = ...
return heightField;
}
}
}
At runtime you can simply load the height-field:
HeightField heightField = Content.Load<HeightField>("XmlFile");
You content pipeline extension project needs to reference the DigitalRune DLLs including DigitalRune.Mathematics.Content.Pipeline.dll and DigitalRune.Geometry.Content.Pipeline.dll.
 
New Post
1/31/2011 8:25 PM
 
winterkewl
No Ranking

Joined: 12/8/2010
Posts: 32
Re: How to override the DigitalRune.Geometry.Shapes.HeightField Content Processor? 
Oh, very cool thanks Martin I'll give this a go when I get home tonight!

This will save me quite a lot of headache if it works. :)
 
 Page 1 of 1
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineHow to override the DigitalRune.Geometry.Shapes.HeightField Content Processor?How to override the DigitalRune.Geometry.Shapes.HeightField Content Processor?


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement