Heres an example.
The example creates 2 objects, positions and colours them and positions, rotates and colours the backdrop of the camera.
Heres the code:
Rem Project: Dark Basic Pro Project
Rem Created: Thursday, February 24, 2011
Rem ***** Main Source File *****
//Initialise object count
ObjectCount=0
//Load the XML
XMLID=KD LoadXML("Example.xml")
//Find the first child named "world"
if KD GetXMLFirstChildNode(XMLID,"world")
//Now we have jumped into the world node, lets try and find all the objects in the scene
FoundObject=KD GetXMLFirstChildNode(XMLID,"object")
while FoundObject
//Get object type
Type$=KD GetXMLNodeAttribute(XMLID,"type")
//Make the object
select Type$
case "box"
//Get the size of the object
if KD GetXMLFirstChildNode(XMLID,"size")
//Make the object
inc ObjectCount
make object box ObjectCount,val(KD GetXMLNodeAttribute(XMLID,"x")),val(KD GetXMLNodeAttribute(XMLID,"y")),val(KD GetXMLNodeAttribute(XMLID,"z"))
//Jump back to object node
KD GetXMLParentNode XMLID
//Position the object
if KD GetXMLFirstChildNode(XMLID,"position")
position object ObjectCount,val(KD GetXMLNodeAttribute(XMLID,"x")),val(KD GetXMLNodeAttribute(XMLID,"y")),val(KD GetXMLNodeAttribute(XMLID,"z"))
endif
//Jump back to object node
KD GetXMLParentNode XMLID
//Colour the object
if KD GetXMLFirstChildNode(XMLID,"colour")
color object ObjectCount,rgb(val(KD GetXMLNodeAttribute(XMLID,"r")),val(KD GetXMLNodeAttribute(XMLID,"g")),val(KD GetXMLNodeAttribute(XMLID,"b")))
endif
endif
endcase
case "sphere"
//Get the size of the object
if KD GetXMLFirstChildNode(XMLID,"size")
//Make the object
inc ObjectCount
make object sphere ObjectCount,val(KD GetXMLNodeAttribute(XMLID,"radius"))
//Jump back to object node
KD GetXMLParentNode XMLID
//Position the object
if KD GetXMLFirstChildNode(XMLID,"position")
position object ObjectCount,val(KD GetXMLNodeAttribute(XMLID,"x")),val(KD GetXMLNodeAttribute(XMLID,"y")),val(KD GetXMLNodeAttribute(XMLID,"z"))
endif
//Jump back to object node
KD GetXMLParentNode XMLID
//Colour the object
if KD GetXMLFirstChildNode(XMLID,"colour")
color object ObjectCount,rgb(val(KD GetXMLNodeAttribute(XMLID,"r")),val(KD GetXMLNodeAttribute(XMLID,"g")),val(KD GetXMLNodeAttribute(XMLID,"b")))
endif
endif
endcase
endselect
//Find next object
KD GetXMLParentNode XMLID
FoundObject=KD GetXMLNextSiblingNode(XMLID,"object")
endwhile
//Jump back to world
KD GetXMLParentNode XMLID
//Now we have jumped back to the world node, lets try and find all the cameras in the scene
FoundCamera=KD GetXMLFirstChildNode(XMLID,"camera")
while FoundCamera
//Make the camera
inc CameraCount
make camera CameraCount
set current camera CameraCount
//Position the camera
if KD GetXMLFirstChildNode(XMLID,"position")
position camera CameraCount,val(KD GetXMLNodeAttribute(XMLID,"x")),val(KD GetXMLNodeAttribute(XMLID,"y")),val(KD GetXMLNodeAttribute(XMLID,"z"))
endif
//Jump back to camera node
KD GetXMLParentNode XMLID
//Rotate the camera
if KD GetXMLFirstChildNode(XMLID,"rotation")
rotate camera CameraCount,val(KD GetXMLNodeAttribute(XMLID,"x")),val(KD GetXMLNodeAttribute(XMLID,"y")),val(KD GetXMLNodeAttribute(XMLID,"z"))
endif
//Jump back to camera node
KD GetXMLParentNode XMLID
//Colour the cameras backdrop
if KD GetXMLFirstChildNode(XMLID,"backdrop-colour")
color backdrop CameraCount,rgb(val(KD GetXMLNodeAttribute(XMLID,"r")),val(KD GetXMLNodeAttribute(XMLID,"g")),val(KD GetXMLNodeAttribute(XMLID,"b")))
endif
//Find next camera
KD GetXMLParentNode XMLID
FoundCamera=KD GetXMLNextSiblingNode(XMLID,"camera")
endwhile
//Jump back to world
KD GetXMLParentNode XMLID
else
print "Invalid world file"
wait key
end
endif
wait key
Heres the xml. (save as Example.xml and put it in the same directory as the compiled example).
<world>
<object type="box">
<size x="100" y="100" z="100"/>
<position x="-75" y="0" z="0"/>
<colour r="0" g="255" b="0"/>
</object>
<object type="sphere">
<size radius="100"/>
<position x="75" y="0" z="0"/>
<colour r="0" g="0" b="255"/>
</object>
<camera>
<position x="-200" y="200" z="-200"/>
<rotation x="45" y="45" z="0"/>
<backdrop-colour r="0" g="0" b="0"/>
</camera>
</world>
Your signature has been erased by a mod please reduce it to no larger than 600 x 120.