> there's already C# code in the open source metaverse
project to faithfully render prim.blender format xml files in to
something like you'd see in SL
 
Thank-you for the reference John.
 
> we just need some building tools added on
 
OSMP contains a set of SL-like building tools.  Screenshots http://sourceforge.net/project/screenshots.php?group_id=112657
 
OSMP C# can be downloaded from http://sourceforge.net/project/showfiles.php?group_id=112657&package_id=198139 
 
There is a proof of concept prim blender exporter/importer attached to this mail (are attachments allowed?).  It imports core parameters, such as position and scale.
 
On 9/19/06, John Hurliman <[EMAIL PROTECTED]> wrote:
Regarding my comment on the blog, I was trying to stay technically
correct and not say it's impossible, but since there is a question of
the feasibility I'm going to go ahead and say it's "impossible". Even if
you were able to restrict all of the SketchUp tools down to the bare
basics, 1) you wouldn't be able to use most of the functionality of
prims because the way the Second Life engine handles cuts, hollows,
twists, etc. is very unique to it's own engine and would need to be
mimicked in whatever target platform you're looking at. And 2) SketchUp
would still use it's own format for storing things which is a completely
different line of thinking from how SL looks at objects. My guess is
that the best building tools will be a standalone program written from
the ground up, there's already C# code in the open source metaverse
project to faithfully render prim.blender format xml files in to
something like you'd see in SL, we just need some building tools added
on. Again much easier said than done but that would be worlds easier
than trying to support SketchUp, to put things in perspective.


C.J. Adams-Collier wrote:
> Speaking of the prims exporter, could the contents of the following
> elements be lowercased?  I can treat them as boolean if they're "true"
> and "false" rather than "TRUE" and "FALSE".
>
> <states>
> <physics params="">FALSE</physics>
> <temporary params="">FALSE</temporary>
> <phantom params="">FALSE</phantom>
> </states>
>
> If not, it can be worked around.  It would just be easier if it were a
> bool rather than a string :)
>
> Cheers,
>
> C.J.
>
>

I could fix it on our end, but the current version of prim.blender
writes them uppercase and other possible utilities might follow suit, so
you'd have to plan for the worst case scenario anyways.

John

_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev
http://www.libsecondlife.org/

// Copyright Hugh Perkins 2006
// [EMAIL PROTECTED] http://manageddreams.com
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License version 2 as published by 
the
// Free Software Foundation;
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
//  more details.
//
// You should have received a copy of the GNU General Public License along
// with this program in the file licence.txt; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
// 1307 USA
// You can find the licence also on the web at:
// http://www.opensource.org/licenses/gpl-license.php
//

using System;
using System.Collections;
using System.Xml;
using System.Xml.Serialization; 
using System.Windows.Forms;
using System.IO;

namespace OSMP
{
    public class ImportExportPrimBlender : IWorldPersist
    {
        static ImportExportPrimBlender instance = new ImportExportPrimBlender();
        public static ImportExportPrimBlender GetInstance()
        {
            return instance;
        }
        
        public ImportExportPrimBlender()
        {
            //MenuController.GetInstance().RegisterMainMenu(new string[]{ 
"&File","&Save World..." }, new MainMenuCallback( SaveWorld ) );
            MenuController.GetInstance().RegisterMainMenu(new string[]{ 
"&File","&Load Prim Blender file..." }, new MainMenuCallback( LoadWorld ) );
            
            
//ContextMenuController.GetInstance().RegisterPersistentContextMenu(new 
string[]{ "World","&Save to File..." }, new ContextMenuHandler( ContextMenuSave 
) );
            
ContextMenuController.GetInstance().RegisterPersistentContextMenu(new string[]{ 
"World","&Load Prim Blender file..." }, new ContextMenuHandler( ContextMenuLoad 
) );
        }
        
        public void ContextMenuSave( object source, ContextMenuArgs e )
        {
            SaveWorld();
        }
        
        public void SaveWorld()
        {
            SaveFileDialog savefiledialog = new SaveFileDialog();
        
            savefiledialog.InitialDirectory = "DefaultWorld" ;
            savefiledialog.Filter = "Prim Blender Files(*.PRIMS)|*.PRIMS|All 
files (*.*)|*.*" ;
            savefiledialog.FilterIndex = 1;
            savefiledialog.RestoreDirectory = true ;
        
            if(savefiledialog.ShowDialog() == DialogResult.OK)
            {
                string filename = savefiledialog.FileName;
                Console.WriteLine ( filename );
                Store( filename );
            }
            DialogHelper.GetInstance().ShowInfoMessage( "World save completed", 
"World save completed" );
        }
        
        public void ContextMenuLoad( object source, ContextMenuArgs e )
        {
            LoadWorld();
        }
        
        public void LoadWorld()
        {
            OpenFileDialog openfiledialog = new OpenFileDialog();
        
            openfiledialog.InitialDirectory = "DefaultWorld" ;
            openfiledialog.Filter = "Prim Blender Files(*.PRIMS)|*.PRIMS|All 
files (*.*)|*.*" ;
            openfiledialog.FilterIndex = 1;
            openfiledialog.RestoreDirectory = true ;
        
            if(openfiledialog.ShowDialog() == DialogResult.OK)
            {
                string filename = openfiledialog.FileName;
                Console.WriteLine ( filename );
                Restore( filename );
            }
            DialogHelper.GetInstance().ShowInfoMessage( "World load completed", 
"World load completed" );
        }
        
        public void Store( string filename )
        {
            WorldModel worldmodel = WorldModel.GetInstance();
            
            ArrayList types = new ArrayList();
            foreach( Entity entity in worldmodel.entities )
            {
                if( !types.Contains( entity.GetType() ) )
                {
                    types.Add( entity.GetType() );
                }
            }
            
            XmlSerializer serializer = new XmlSerializer( 
worldmodel.entities.GetType(), (Type[])types.ToArray( typeof( Type ) ) );
            StreamWriter streamwriter = new StreamWriter( filename );
            serializer.Serialize( streamwriter, worldmodel.entities );
        }
        
        // need to add a publisher/subscriber to this ;-)
        public void Restore( string filename )
        {
            WorldModel worldmodel = WorldModel.GetInstance();
            
            //// note to self: should make these types a publisher/subscriber 
thing
            //XmlSerializer serializer = new XmlSerializer( 
worldmodel.entities.GetType(), new Type[]{
             //   typeof( Avatar ),
              //  typeof( FractalSplineCylinder ), 
              //  //typeof( FractalSplineRing ), 
              //  typeof( FractalSplineBox )
               // } );            
            //FileStream filestream = new FileStream( filename, FileMode.Open );
            //worldmodel.entities = (EntityArrayList)serializer.Deserialize( 
filestream );                
/*                
            <type val="0" />
<position x="5.25000047684" y="7.75" z="8.75" />
<rotation x="0.707107126713" y="-0.707106411457" z="-1.1520197063e-007" 
s="6.65917468723e-007" />
<size x="4.75" y="10.0" z="0.10000000149" />
<cut x="0.0" y="1.0" />
<dimple x="0.0" y="1.0" />
<advancedcut x="0.0" y="1.0" />
<hollow val="0" />
<twist x="0" y="0" />
<topsize x="1.0" y="1.0" />
<holesize x="1.0" y="0.5" />
<topshear x="0.0" y="0.0" />
<taper x="0.0" y="0.0" />
<revolutions val="1.0" />
<radiusoffset val="0.0" />
<skew val="0.0" />
<material val="3" />
<hollowshape val="0" />
*/

            worldmodel.entities.Clear();
            XmlDocument primsdom = XmlHelper.OpenDom( filename );
            foreach( XmlElement primitiveelement in 
primsdom.DocumentElement.SelectNodes( "primitive" ) )
            {
                FractalSplineBox newbox = new FractalSplineBox();
                XmlElement propertieselement = 
primitiveelement.SelectSingleNode("properties" ) as XmlElement;
                newbox.pos = new Vector3( 
primitiveelement.SelectSingleNode("properties/position" ) as XmlElement );
                newbox.rot = new Rot( 
primitiveelement.SelectSingleNode("properties/rotation" ) as XmlElement );
                newbox.scale = new Vector3( 
primitiveelement.SelectSingleNode("properties/size" ) as XmlElement );
                newbox.Hollow = Convert.ToInt32( ( 
propertieselement.SelectSingleNode( "hollow" ) as XmlElement 
).GetAttribute("val" ).ToString() );
                // newbox.Twist = Convert.ToInt32( 
propertieselement.SelectSingleNode( "twist" ) as XmlElement ).GetAttribute("x" 
).ToString() );                
                newbox.TopSizeX = Convert.ToDouble( ( 
propertieselement.SelectSingleNode( "topsize" ) as XmlElement 
).GetAttribute("x" ).ToString() );
                newbox.TopSizeY = Convert.ToDouble( ( 
propertieselement.SelectSingleNode( "topsize" ) as XmlElement 
).GetAttribute("y" ).ToString() );                
                newbox.CutStart = (int)( Convert.ToDouble( ( 
propertieselement.SelectSingleNode( "cut" ) as XmlElement ).GetAttribute("x" 
).ToString() ) * 200 ); 
                newbox.CutEnd = (int)( Convert.ToDouble( ( 
propertieselement.SelectSingleNode( "cut" ) as XmlElement ).GetAttribute("y" 
).ToString() ) * 200 );    
                worldmodel.entities.Add( newbox );
            }
        }
    }
}
_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev
http://www.libsecondlife.org/

Reply via email to