unigine geopivot 經緯度 空間座標 三維平鋪座標

unigine中的geopivot 作用是進行 經緯度與空間座標系之間的換算 以及 經緯度到三維平鋪座標之間的換算

(先理解區分下 經緯度 三維空間座標 三維平鋪座標 這三個的概念:首先在unigine中如果沒有geopivot節點,那麼就只有一個三維空間座標的概念。如果加入geopivot節點並且將其他節點放置到這個geopivot節點下,(如果其他的物體比較大,比如使用一個globalwater,在很遠的地方看會發現,將globalwater節點從非geopivot子節點變成geopivot子節點globalwater會變彎曲。原理是變換成子節點的時候在globalwater的vertexshader中傳入了一個矩陣和一個GEO相關的宏。讓頂點位置有所變換。)那麼那些節點就會有三個座標。一個是未成爲geopivot子節點的時的空間座標,這個座標我稱作三維平鋪座標,對應api中的flat(可以理解爲這個是一個虛擬的座標,只是在某些特殊情況下會用到這個座標,比如從地形上獲取對應點所在的地形塊數);一個是經緯度座標,對應api中的geodetic;一個是當前真實三維空間座標,對應api中的Ellipsolid。)

 

將一個節點放到geopivot下,其座標會被修改,即從flat變換到geodetic 座標和反過來的轉換。其對應的函數如下。

virtual Math::dmat4 mapMeshFlatToEllipsoid(Ptr<Mesh> &mesh, const Math::dmat4 &flat_transform) = 0;
    virtual Math::mat4 mapMeshFlatToEllipsoid(Ptr<Mesh> &mesh, const Math::mat4 &flat_transform) = 0;
    virtual Math::dmat4 mapMeshEllipsoidToFlat(Ptr<Mesh> &mesh, const Math::dmat4 &ellipsoid_transform) = 0;
    virtual Math::mat4 mapMeshEllipsoidToFlat(Ptr<Mesh> &mesh, const Math::mat4 &ellipsoid_transform) = 0;
    virtual Math::dvec3 mapFlatToGeodetic(const Math::dvec3 &flat_point) = 0;
    virtual Math::dvec3 mapFlatToGeodetic(const Math::vec3 &flat_point) = 0;
    virtual void mapFlatsToGeodetic(const double * src_x, const double * src_y, int size, double * ret_lat, double * ret_lon) const = 0;
    virtual Math::dvec3 mapGeodeticToFlat(const Math::dvec3 &geodetic_coords) = 0;
    virtual void mapGeodeticsToFlat(const double * lat, const double * lon, int size, double * ret_x, double * ret_y) const = 0;
    virtual void mapFlatToEllipsoid(const Math::dvec3 &flat_point, Math::dvec3 &ret_ellipsoid_point, Math::dvec3 &ret_ellipsoid_normal) = 0;
    virtual void mapFlatToEllipsoid(const Math::vec3 &flat_point, Math::vec3 &ret_ellipsoid_point, Math::vec3 &ret_ellipsoid_normal) = 0;
    virtual void mapEllipsoidToFlat(const Math::dvec3 &ellipsoid_point, Math::dvec3 &ret_flat_point, Math::dvec3 &ret_ellipsoid_normal) = 0;
    virtual void mapEllipsoidToFlat(const Math::vec3 &ellipsoid_point, Math::vec3 &ret_flat_point, Math::vec3 &ret_ellipsoid_normal) = 0;
    virtual Math::dmat4 mapFlatToEllipsoid(const Math::dmat4 &flat_transform) = 0;
    virtual Math::mat4 mapFlatToEllipsoid(const Math::mat4 &flat_transform) = 0;
    virtual Math::dmat4 mapEllipsoidToFlat(const Math::dmat4 &ellipsoid_transform) = 0;
    virtual Math::mat4 mapEllipsoidToFlat(const Math::mat4 &ellipsoid_transform) = 0;

 

另外一種是。當節點在geopivot下時,節點其實是有兩個左邊一個是新的空間座標(經geopivot糾正後的座標),一個是geodetic座標。(其實還有一個是flat座標(geopivot糾正之前的空間座標))
通過如下函數來進行操作:
virtual Math::dvec3 toGeodetic(const Math::dmat4 &world_transform) = 0;
    virtual Math::dvec3 toGeodetic(const Math::mat4 &world_transform) = 0;
    virtual Math::dmat4 toWorld(const Math::dvec3 &geodetic_coords) = 0;
    virtual Math::dmat4 toWorldPreserveRotation(const Math::dmat4 &world_transform, const Math::dvec3 &geodetic_coords) = 0;
    virtual Math::mat4 toWorldPreserveRotation(const Math::mat4 &world_transform, const Math::dvec3 &geodetic_coords) = 0;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章