PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Sat Nov 18, 2017 7:42 pm

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Source Code
PostPosted: Sat Jul 22, 2006 8:33 pm 
Offline

Joined: Thu Jun 15, 2006 8:14 am
Posts: 19
Location: Washington
Ok, so do you want me to create the plugin from scratch, or do you have the source code for the existing plugin to model it after, or do you have a particular structure you would like me to follow for this plugin?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 22, 2006 11:30 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
The source code for the PlugIn, as it is distributed with the program, is contained inside the PlugIn-SDK. So the easiest starting point would be to use and extend it.

- In CPnPTCObjectsPlugIn::CheckSupportedFormat you can add the new supported file extensions.
- If you want to follow the given project structure, the loading of the file starts in C3DObject::Load, where you have to call the appropriate ogre file loader.
- There is already a file called ogre.cpp, which I use for writing ogre meshes. There I would add the loading methods.
- After loading, you have to convert it into the existing rendering data structures. See the ConvertData function in the obj.cpp file, which performs this task for obj files. Alternatively you might be able to use the rendering data structures provided by ogre.


Top
 Profile  
 
 Post subject: Code Review
PostPosted: Tue Jul 25, 2006 6:19 am 
Offline

Joined: Thu Jun 15, 2006 8:14 am
Posts: 19
Location: Washington
I've been reviewing the code snippets in different areas and am starting to get the drift of how things are going. I'm suprised that I've forgotten so much, working with Java and C# for quite a while. It's easy for me to get mixed up. In fact, I think I'm going to read a couple programming books again, to refresh my memory.


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Thu Jan 01, 2009 8:26 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
I intend to have a go at this.
As far as I can see, I have to modify 3DObject.cpp and PnPTCObjectsPlugin.cpp to allow for the loading of mesh.xml files.
Then I will implement C3DObjectSerializerOGRE::Load.
I will probably base it on the collada loader, because that's xml too. :)

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Sat Jan 03, 2009 11:05 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
Just look at this:

Image

'nuff said. :D

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Sun Jan 04, 2009 1:46 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
whoa, that's great :)


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Sun Jan 04, 2009 6:29 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
Here's a little preview of Ogre scene export:

Code:
<scene formatVersion="1.0.0" author="PnP Terrain Creator">
    <nodes>
        <node>
            <position x="10.337444" y="110.991356" z="1014.281982" />
            <quaternion qx="0.000000" qy="0.000000" qz="0.000000" qw="1.000000" />
            <scale x="1" y="1" z="1" />
            <entity name="ogrehead" meshfile="ogrehead.mesh" />
        </node>
        <node>
            <position x="162.940475" y="92.746559" z="1042.552734" />
            <quaternion qx="0.000000" qy="0.990960" qz="0.000000" qw="-0.134161" />
            <scale x="1" y="1" z="1" />
            <entity name="box" meshfile="box.mesh" />
        </node>
    </nodes>
</scene>


I have to figure out how to export position and rotation properly..
But it's shaping up. :)

I put in support for user defined properties, but I cannot test it. Does it work?

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Sun Jan 04, 2009 10:44 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
Almost there. :)
I need to do some more testing, but it sure is promising. :wink:

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 12:15 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
What coordinate system is PnPTC using?
Left-handed with Z up?
It works, but now I need to know why. :)

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 12:37 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
The rendering engine in TC uses the default DirectX left-handed y-axis-up system. As most models are created right-handed z-up, there is a possibility to rotate and flip the objects within TC so that they are rendered correctly. There is also a possibility to export this flipping/rotation in the mesh files if needed.

However, the coordinates for the positioning of the objects are converted to the more common right-handed z-up system by the PlugIn-SDK. So the horizontal plane is defined by the x and y axis. As ogre is using right-handed z-up too, you should be able to directly use them.


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 1:28 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
That's what I figured, thanks. :)
It had me puzzled for a moment, that the plugin sdk is dealing with right-handed z-up.

However, Ogre is right-handed y-up, but that's not a problem.

But, the default terrain in Ogre is using a different terrain origin.
In Ogre, x/z zero is at upper left corner of the terrain, but in PnPTC it's at lower left.
I got around it by adjusting the z by the size of a terrain patch.

I'll keep you posted. :wink:

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 4:53 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
I just emailed the modifications to the Ogre serializer (Objects plugin) and a new Ogre Scene Export plugin to Ralf. :)

I forgot to write how to use it:

PnPTC now supports loading of Ogre meshes.
Ogre users should drop their binary meshes on the OgreXMLConverter, giving them a mesh.xml file.
So, ogrehead.mesh becomes ogrehead.mesh.xml.

Then, in order to get materials on that mesh in PnPTC, we need to write a small material file, entitled ogrehead.material.

This file should look like this:
Code:
<materials>
<material material="Ogre/Eyes" texture="WeirdEye.png" />
<material material="Ogre/Skin" texture="GreenSkin.jpg" />
<material material="Ogre/Earring" texture="spheremap.png" />
<material material="Ogre/Tusks" texture="dirt01.jpg" />
</materials>


Basically a mapping between the Ogre material names and an actual texture.
As Ogre material scripts can be quite involved, writing a material script parser would be quite a big project in itself.
Hence the need to write that little material xml file.

I think it would be a good idea to rename that extension to .pnpogremat, as .material is already used in Ogre.
I didn't think about that when I wrote the loader.

Right.
Drop the textures, the ogrehead.mesh.xml and the ogrehead.material in the OBJECTS folder, and PnPTC will happily load it for you. :wink:


About the Ogre Scene Exporter Plugin:

It will export the objects placed in the terrain, like this:
Code:
<scene formatVersion="1.0.0" author="PnP Terrain Creator">
    <nodes>
        <node>
            <position x="10.337000" y="110.991287" z="1009.718018" />
            <quaternion qw="1.000000" qx="0.000000" qy="0.000000" qz="0.000000" />
            <scale x="0.100000" y="0.100000" z="0.100000" />
            <entity name="ogrehead" meshfile="ogrehead.mesh" />
            <userData>
                <property type="STRING" name="name" data="thename" />
            </userData>
        </node>
        <node>
            <position x="162.940994" y="92.747040" z="981.447021" />
            <quaternion qw="-0.377235" qx="0.000000" qy="-0.926118" qz="0.000000" />
            <scale x="0.100000" y="0.100000" z="0.100000" />
            <entity name="ogrehead" meshfile="ogrehead.mesh" />
            <userData>
                <property type="STRING" name="name" data="second head" />
            </userData>
        </node>
        <node>
            <position x="57.160999" y="62.982960" z="853.117981" />
            <quaternion qw="0.980982" qx="0.194097" qy="0.000000" qz="0.000000" />
            <scale x="0.100000" y="0.100000" z="0.100000" />
            <entity name="cube" meshfile="cube.mesh" />
            <userData>
                <property type="STRING" name="name" data="my box" />
            </userData>
        </node>
    </nodes>
</scene>


It supports user defined properties, of type string, integer, float and bool. Doesn't handle nested properties, though.
UDPs are really useful for things like game logic, etc.

That's basically it. :wink:

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 5:23 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
@Ralf: I will code an Ogre3D test application and send it to you. Makes it easier to test the Ogre scene exporter. What do you think?

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 7:03 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
Thank you very much for your work. A small test application would indeed be very helpfull.


Top
 Profile  
 
 Post subject: Re: exporter plugin for ogre
PostPosted: Mon Jan 05, 2009 10:48 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
I am uploading the files now. :)

Thanks for your email - I am a happy PnPTC Pro user now! :D

Will email you a link to the files when they're ready. :wink:

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: