• 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 Would I make a maze (XML i would assume)How Would I make a maze (XML i would assume)
Previous
 
Next
New Post
5/12/2012 9:22 PM
 
falconmick
No Ranking

Joined: 5/12/2012
Posts: 17
How Would I make a maze (XML i would assume) 

I was wondering, inside of this engine how would I create a height map which has a couple of hundered objects placed in precise places without having to hard code it, I would assume it would be done through XML some how, but is there an easy way to do so?

 
New Post
5/14/2012 10:23 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 567
Re: How Would I make a maze (XML i would assume) 

Our engine does not yet have tools for content creation. You have to come up with your own description of the level.
The height field data is usually stored in a grayscale bitmap image. The object placement can be stored in an XML, a textfile with your own custom format, or any other format. If your maze is very simply, it might be enough to paint a 2D bitmap image of your maze in MS Paint.
Then you have to load this file at runtime. Or you create an XNA content pipeline processor that preprocesses this file for faster loading.

To create the content of  the level description, there are several methods:
- Manual editing of the file.
- Create a tool with which you can edit the file - your own little level editor.
- Use a 3D modelling tool (e.g. Blender, 3ds Max) to place objects (e.g. real models or empty dummy nodes with special names). Export this scene in a standard format like FBX. Use a custom XNA content processor to extract the level information from the FBX.
- Use  a 3D modelling tool and write your own exporter that creates the level description (e.g. XML).

Perhaps someone has come up with another solution?

 
New Post
5/14/2012 5:23 PM
 
falconmick
No Ranking

Joined: 5/12/2012
Posts: 17
Re: How Would I make a maze (XML i would assume) 

ive made a very basic 3ds loader.. (made/taken from others)

LevelExporter.ms (taken from Ploobs engine)

-- Variable Definitions
 
global currentFile                              -- name of currently open file
 
global numNodes
 
 
fn getFileName val =
(
fname = filterString val ": \\"
fname = fname[fname.count]
 
return fname
)
 
rollout main "Level Exporter"
(
        label comments "Comments:"
        editText noteList text:"Comments:" height:100
        button writeFile "Export Level" across:1
 
        on writeFile pressed do
        (
                currentIn       = getSaveFileName caption:"Export File" types:"XML(*.xml)|*.xml|All|*.*|"
                if currentIn != undefined do
                (
                        currentFile = openFile currentIn mode: "wt"
 
                        -- Comments --
                        format "<!-- " to:currentFile
                        for a = 1 to Main.noteList.text.count do
                        (
                                if Main.noteList.text[a] == "\n" then format "\n" to:currentFile
                                else format "%" Main.noteList.text[a] to:currentFile
                        )
                        format " -->\n" to:currentFile
 
 
                        
                        format "<SCENE>\n" to:currentFile
 
                        for numNodes = 1 to objects.count do
                        (
                                if( objects[numNodes] == undefined) do continue
 
                                body = objects[numNodes] -- collision body to export
                                shape = classOf body
 
                                if(shape == dummy) then
                                (
                                        if( getUserProp body "Particle" != undefined)do
                                        (
 
                                        format "\t<Particle>" to: currentFile
                                        --format getUserProp body "Particle" to:currentFile
                                        format "\t\t\t<position value =\"%\" />\n" body.position  to:currentFile
                                        format "\t</Particle>" to:currentFile
                                        )
 
                                        if(getUserProp body "Constraint" != undefined) then
                                        (
                                                format "\t<Constraint  " to:currentFile
                                                --local coord of distance from a to b
 
                                                if(getUserProp body "BodyA" != undefined) do
                                                (
                                                        s = getUserProp body "BodyA"
                                                        format "\t\tBodyA=\"%\"\n" s  to:currentFile
                                                        bodyA = execute ("instance $"+s)
                                                        centerpivot bodyA
                                                        pivotA = in coordsys world(length (body.pos - bodyA.pos)) * (normalize (in coordsys bodyA.transform body.pos) )
                                                        format "\t\tPivotA=\"% % %\"\n" pivotA[1] pivotA[3] -pivotA[2] to:currentFile
 
                                                        if(getUserProp body "Constraint" == "Hinge") do
                                                        (
                                                                axisA = normalize (in coordsys bodyA.transform body.dir)
                                                                format "\t\tAxisA=\"% % %\"\n" axisA[1] axisA[3] -axisA[2] to:currentFile
                                                        )
                                                        delete bodyA
                                                )
                                                if(getUserProp body "BodyB" != undefined) do
                                                (
                                                        s = getUserProp body "BodyB"
                                                        format "\t\tBodyB=\"%\"\n" s  to:currentFile
                                                        bodyB = execute ("instance $"+s)
                                                        centerpivot bodyB
                                                        pivotB = in coordsys world(length (body.pos - bodyB.pos)) * (normalize (in coordsys bodyB.transform body.pos) )
                                                        format "\t\tPivotB=\"% % %\"\n" pivotB[1] pivotB[3] -pivotB[2] to:currentFile
 
                                                        if(getUserProp body "Constraint" == "Hinge") do
                                                        (
                                                                axisB = normalize (in coordsys bodyB.transform body.dir)
                                                                format "\t\tAxisB=\"% % %\"\n" AxisB[1] AxisB[3] -AxisB[2] to:currentFile
                                                        )
                                                        delete bodyB
                                                )
                                                format "\t\t/>" to:currentFile
                                        )
                                        else
                                        (
                                         
                                        format "\t\t<dummy name=\"%\">\n" body.name to:currentFile
                                        format "\t\t<position>\n" to:currentFile                                   
                                        format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                        format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                        format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile                               
                                        format "\t\t</position>\n" to:currentFile
                                        format "\t</dummy>\n" to:currentFile                                       
                                        )
                                )
                                else if(shape == Omnilight) then
                                (
                                rgb = body.rgb
                                multiplier = body.multiplier
                                decay = body.farAttenEnd
                                 
                                format "\t\t<pointlight name=\"%\">\n" body.name to:currentFile
                                format "\t\t<position>\n" to:currentFile                                   
                                format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile                               
                                format "\t\t</position>\n" to:currentFile
                                 
                                 
                                format "\t\t<color>\n" to:currentFile
                                format "\t\t\t<x> % </x>\n" rgb.red  to:currentFile
                                format "\t\t\t<y> % </y>\n" rgb.green  to:currentFile
                                format "\t\t\t<z> % </z>\n" rgb.blue  to:currentFile                               
                                format "\t\t</color>\n" to:currentFile
                                 
                                 
                                format "\t\t\t<multiplier amount=\"%\" />\n" multiplier to:currentFile
                                format "\t\t\t<decay value =\"%\" />\n" decay to:currentFile               
                                format "\t</pointlight>\n" to:currentFile                      
                                 
                                )
                                else if(shape == TargetCamera) then
                                (
                                format "\t\t<camera name=\"%\">\n" body.name to:currentFile
                                format "\t\t<position>\n" to:currentFile
                                format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile   
                                format "\t\t</position>\n" to:currentFile
                                format "\t\t</camera>\n" to:currentFile
                                     
                                )
                                else if(shape == Targetobject) then
                                (
                                format "\t\t<target name=\"%\">\n" body.name to:currentFile
                                format "\t\t<position>\n" to:currentFile
                                format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile   
                                format "\t\t</position>\n" to:currentFile
                                format "\t\t</target>\n" to:currentFile
                                     
                                )
                                else if(shape == Spray) then
                                (
                                format "\t<particle name=\"%\">\n" body.name to:currentFile
                                --format getUserProp body "Particle" to:currentFile
                                format "\t\t<position>\n" to:currentFile
                                    format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                    format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                    format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile   
                                format "\t\t</position>\n" to:currentFile
                                format "\t\t\t<width value =\"%\" />\n" body.emitterwidth  to:currentFile
                                format "\t\t\t<height value =\"%\" />\n" body.emitterheight  to:currentFile
                                 
                                format "\t</particle>" to:currentFile
                                 
                                )
                                 
                                else if(shape == targetSpot) then
                                (
                                rgb = body.rgb
                                multiplier = body.multiplier
                                decay = body.decayRadius
                                 
                                 
                                 
                                format "\t\t<spotlight name=\"%\">\n" body.name to:currentFile
                                format "\t\t<enabled>%</enabled>\n" body.enabled  to:currentFile
                                format "\t\t<fallof>%</fallof>\n" body.falloff  to:currentFile
                                format "\t\t<castShadows>%</castShadows>\n" body.castShadows  to:currentFile
                                format "\t\t<position>\n" to:currentFile
                                format "\t\t\t<x> % </x>\n" body.position[1]  to:currentFile
                                format "\t\t\t<y> % </y>\n" -body.position[3]  to:currentFile
                                format "\t\t\t<z> % </z>\n" body.position[2]  to:currentFile                               
                                format "\t\t</position>\n" to:currentFile
                                 
                                 
                                format "\t\t<color>\n" to:currentFile
                                format "\t\t\t<x> % </x>\n" rgb.red  to:currentFile
                                format "\t\t\t<y> % </y>\n" rgb.green  to:currentFile
                                format "\t\t\t<z> % </z>\n" rgb.blue  to:currentFile                               
                                format "\t\t</color>\n" to:currentFile
                                 
                                 
                                format "\t\t\t<multiplier amount=\"%\" />\n" multiplier to:currentFile
                                format "\t\t\t<decay value =\"%\" />\n" decay to:currentFile               
                                format "\t</spotlight>\n" to:currentFile           
                                 
                                 
                                 
                                )
                                else
                                (
 
 
                                format "i:% body: % \n\n " l body
                                format "\t<body " to:currentFile
 
                                -- Bone and CLass and Name --
                         
                                 
                                format "\t name=\"%\" >\n" body.name to:currentFile
 
                                format "\t\t<collision type=\"%\"/>\n" shape to:currentFile
 
                                if(classOf body.material ==  Standardmaterial) do
                                (
                                format "\t\t<material>\n" to:currentFile
                                 
                                                                 
                                format "\t\t\t<SpecularIntensity>\n" to:currentFile
                                format "\t\t\t%\n" body.material.Glossiness  to:currentFile
                                format "\t\t\t</SpecularIntensity>\n" to:currentFile
                                 
                                format "\t\t\t<SpecularPower>\n" to:currentFile
                                format "\t\t\t%\n" body.material.specularLevel  to:currentFile
                                format "\t\t\t</SpecularPower>\n" to:currentFile
                                 
                                 
                                 
                                if(body.material.diffusemap != undefined) do
                                (
                                a = getFileName body.material.diffusemap.filename
                                format "\t\t\t<diffuse name =\"%\" />\n" a  to:currentFile
                                )
                                if(body.material.bumpmap != undefined) do
                                (
                                a =getFileName body.material.bumpmap.filename
                                format "\t\t\t<bump name =\"%\" />\n" a to:currentFile
                                )
                                if(body.material.specularlevelmap != undefined) do
                                (
                                a = getFileName body.material.specularlevelmap.filename
                                format "\t\t\t<specular name =\"%\" />\n" a to:currentFile
                                )
                                if(body.material.selfillummap != undefined) do
                                (
                                a = getFileName body.material.selfillummap.filename
                                format "\t\t\t<glow name =\"%\" />\n" a to:currentFile                                                 
                                )
                                format "\t\t</material>\n" to:currentFile
                             
                                )
                                 
                        
 
                                format "\t</body> \n"to:currentFile
                                )
                        )
 
                        format "</SCENE>\n" to:currentFile
                        close currentFile
                )
        )
)-- create the rollout window and add the rollout
 
if MoCapFloater != undefined do
(
        closerolloutfloater MoCapFloater
)
 
MoCapFloater = newRolloutFloater "PloobsLevel Exporter" 500 200 100 100
 
addRollout Main MoCapFloater


then add a dummy to the base off all the objects you wish to export (please DO NOT use names with numbers on the end, e.g testDummy0 == BAD
testDummyYay = good.. if you make an instance of your object, 3DS will name it  testDummyYay 001, testDummyYay 002,  etc.. my code removes the numbers at the end, that's why

then add this to your code:


using System;
using System.Collections.Generic;
using System.Xml;
 
namespace DoTs
{
    public class loadXMLDummies
    {
        public static void removeNumsEnd(List<xyzDummy> dummyList)
        {
            string tmpStr;
            int size;
            int newSize;
            int i;
            int ii = 0;
 
            bool charFound = false;
            foreach (xyzDummy itt in dummyList)
            {
                tmpStr = itt.ToString();
                size = tmpStr.Length;
                newSize = size;
 
                charFound = false;
                while (!charFound)
                {
                    for (i = size - 1; i >= 0; i--)
                    {
                        charFound = false;
                        if (!int.TryParse(tmpStr[i].ToString(), out ii)) // if not an int
                        {
                            charFound = true;
                            break;
                        }
                        else
                        {
                            newSize--;
                        }
                    }
                }
 
                tmpStr = tmpStr.Substring(0, newSize);
                itt.setName(tmpStr);
            }
        }
 
        // throws System.Xml.XmlException
        public static List<xyzDummy> load(string fileLoc)
        {
            List<xyzDummy> retList = new List<xyzDummy>();
            //MessageBox.Show(fileLoc);
 
            double x = 0, y = 0, z = 0;
            string name;
            string edit;
            bool breakIt = false;
            bool endRead = false;
 
            using (XmlReader reader = XmlReader.Create(fileLoc))
            {
                endRead = !reader.Read();
                while (!endRead)
                {
                    // Only detect start elements.
                    if (reader.IsStartElement())
                    {
                        // Get element name and switch on it.
                        switch (reader.Name)
                        {
                            case "dummy":
                                // Detect this element.
                                name = reader["name"];
 
                                while (!breakIt && !endRead)
                                {
                                    endRead = !reader.Read();
                                    // Only detect start elements.
                                    if (!endRead)
                                    {
                                        if (reader.IsStartElement())
                                        {
                                            // Get element name and switch on it.
 
                                            switch (reader.Name)
                                            {
 
                                                case "dummy":
                                                    breakIt = true;
                                                    break;
                                                case "x":
                                                    endRead = !reader.Read();
                                                    edit = reader.Value.Trim();
                                                    x = Convert.ToDouble(edit);
                                                    break;
                                                case "y":
 
                                                    endRead = !reader.Read();
                                                    edit = reader.Value.Trim();
                                                    y = Convert.ToDouble(edit);
                                                    break;
                                                case "z":
                                                    endRead = !reader.Read();
                                                    edit = reader.Value.Trim();
                                                    z = Convert.ToDouble(edit);
                                                    break;
                                                default:
                                                    break;
                                            }
 
                                        }
                                    }
                                }
 
                                breakIt = false;
 
                                retList.Add(new xyzDummy(name, x, y, z));
                                break;
                            default:
                                endRead = !reader.Read();
                                break;
                        }
                    }
                }
            }
            return (retList);
        }
    }
 
    public class xyzDummy
    {
        private String m_name;
        private double m_x;
        private double m_y;
        private double m_z;
 
        public double getX()
        {
            return (m_x);
        }
 
        public double getY()
        {
            return (m_y);
        }
 
        public double getZ()
        {
            return (m_z);
        }
 
        public xyzDummy(string name, double x, double y, double z)
        {
            m_name = name;
            m_x = x;
            m_y = y;
            m_z = z;
        }
 
        public void setName(string name)
        {
            m_name = name;
        }
 
        public override string ToString()
        {
            // Generates the text shown in the combo box
            return m_name;
        }
    }
}

this is an implimentation:


try
{
    List<xyzDummy> data = loadXMLDummies.load(FileName);
    loadXMLDummies.removeNumsEnd(data);
}
catch (System.Xml.XmlException xmle)
{
    MessageBox.Show("ERROR READING: " + FileName);
}


this will give you List<xyzDummy> data,

then just make a switch statement and itterate through. using data.getName() as the statement to switch, then inside the switch add a case

for every object that you wish to extract, then call it's constructor passing x,y,z useing getX(), getY(), getZ().. unfortunately I can't find out how to extract the  vector with facing.. but yeah, it was a patching project, so can't give everything, a demo project which will extract all dummies from an .xml is provided here:
http://www.2shared.com/file/7pqW95oF/WindowsFormsApplication1.html
it contains alota useless data in the extractor, that just because I never have maxscript codded and don't really feel like learning. Maybe somone can make maxscript only extract dummies, or grab spec from file!.. I didn't bother.


 
New Post
5/15/2012 9:16 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 567
Re: How Would I make a maze (XML i would assume) 
Thanks for sharing the code!
 
New Post
5/16/2012 3:33 PM
 
falconmick
No Ranking

Joined: 5/12/2012
Posts: 17
Re: How Would I make a maze (XML i would assume) 

you have to use this code to translate from 3DS scale system to Digital Rune:

(inside where you place your object, this is it's location)

this is because 3DS is 1/100th the scale and y/z are inverted

Pose = new Pose(new Vector3F((float)dummy.getX() * 100, (float)dummy.getY()*-100 , (float)dummy.getZ() * -100)),  // Start position

 
 Page 1 of 1
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineHow Would I make a maze (XML i would assume)How Would I make a maze (XML i would assume)


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