Эх сурвалжийг харах

Start to add background2d attributes

Paul 11 жил өмнө
parent
commit
cf8d89afd0

+ 12 - 12
QGearsMain/include/data/QGearsCameraMatrixFile.h

@@ -44,23 +44,23 @@ namespace QGears
 
         static const String RESOURCE_TYPE;
 
-        virtual const Ogre::Matrix3&    getMatrix() const;
-        virtual void                    setMatrix( const Ogre::Matrix3& matrix );
+        const Ogre::Matrix3&    getMatrix() const;
+        void                    setMatrix( const Ogre::Matrix3& matrix );
 
-        virtual const Ogre::Vector3&    getPosition() const;
-        virtual void                    setPosition( const Ogre::Vector3& position );
+        const Ogre::Vector3&    getPosition() const;
+        void                    setPosition( const Ogre::Vector3& position );
 
-        virtual const Pixel&            getOffset() const;
-        virtual void                    setOffset( const Pixel& offset );
+        const Pixel&            getOffset() const;
+        void                    setOffset( const Pixel& offset );
 
-        virtual const size_t&           getCount() const;
-        virtual void                    setCount( const size_t count );
+        const size_t&           getCount() const;
+        void                    setCount( const size_t count );
 
-        virtual const Ogre::Real&       getFocalLength() const;
-        virtual void                    setFocalLength( const Ogre::Real );
+        const Ogre::Real&       getFocalLength() const;
+        void                    setFocalLength( const Ogre::Real );
 
-        virtual Ogre::Quaternion        getOrientation() const;
-        virtual Ogre::Radian            getFov( const Ogre::Real& width ) const;
+        Ogre::Quaternion        getOrientation() const;
+        Ogre::Radian            getFov( Ogre::Real width ) const;
 
     protected:
         virtual void loadImpl( void );

+ 1 - 1
QGearsMain/src/data/QGearsCameraMatrixFile.cpp

@@ -155,7 +155,7 @@ namespace QGears
 
     //---------------------------------------------------------------------
     Ogre::Radian
-    CameraMatrixFile::getFov( const Ogre::Real& width ) const
+    CameraMatrixFile::getFov( Ogre::Real width ) const
     {
         return 2 * Ogre::Math::ATan( width / (2 * m_focal_length ) );
     }

+ 35 - 2
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -183,14 +183,47 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
         auto& layers = bg->getLayers();
         const QGears::CameraMatrixFilePtr& camMatrix = field->getCameraMatrix();
 
+       
+
+        // TODO: Should be the width/height of the actual field image, not the texture atlas
+        int width = bgImage->getWidth();
+        int height = bgImage->getHeight();
+
+        // set camera for depth calculation
+        Ogre::Vector3 position = camMatrix->getPosition();
+        Ogre::Quaternion orientation = camMatrix->getOrientation();
+        Ogre::Degree fov = camMatrix->getFov(90);
+
+
+        // TODO: Needs to be loaded from "doors and gateways" section
+        int min_x = 0;
+        int min_y = 0;
+        int max_x = 0;
+        int max_y = 0;
+        //GetScreenRange(min_x, min_y, max_x, max_y);
+
+        // <background2d image="md1_2.png" position="-4990.38 -29075.1 -3384.11" orientation="0.887914 0.381507 0.101529 0.23619" fov="90" range="0 0 0 0" clip="960 720">
+
+        // <background2d image="maps/ffvii/field/md1_2.png" position="39.027 227.173 26.4208" orientation="0.887914 0.381507 0.101529 0.23619" fov="14.3239" range="-768 -768 768 768" clip="960 720">
+
+        // TODO: These are not fully correct yet, some need to be scaled down etc
+        element->SetAttribute("image", (outDir + "/" + field->getName() + ".png"));
+        element->SetAttribute("position", Ogre::StringConverter::toString(position));
+        element->SetAttribute("orientation", Ogre::StringConverter::toString(orientation));
+        element->SetAttribute("fov", Ogre::StringConverter::toString(fov));
+        element->SetAttribute("range", std::to_string(min_x) + " " + std::to_string(min_y) + " " + std::to_string(max_x) + " " + std::to_string(max_y));
+        element->SetAttribute("clip", std::to_string(320 * 3) + " " + std::to_string(240 * 3));
+   
+
+
         // Write out the *_BG.XML data
-        for (auto& layer : layers)
+        for (const auto& layer : layers)
         {
             // TODO: Should we only output tiles to construct enabled layers?
           //  if (layer.enabled)
             {
                
-                for (QGears::BackgroundFile::SpriteData& sprite : layer.sprites)
+                for (const QGears::BackgroundFile::SpriteData& sprite : layer.sprites)
                 {
                     std::unique_ptr<TiXmlElement> xmlElement(new TiXmlElement("tile"));