<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Pooling marker3D]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1056</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1056&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Pooling marker3D.]]></description>
		<lastBuildDate>Thu, 04 Apr 2019 19:38:16 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4727#p4727</link>
			<description><![CDATA[<p>Your code looks fine and should work (theoretically) for Bottom Mode - Zero.<br />For Bottom Mode - Min Value you need to do:<br /></p><div class="codebox"><pre><code>p.y = (float)pos.Altitude;
p.y += OnlineMapsElevationManagerBase.GetUnscaledElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);
p.y -= OnlineMapsElevationManagerBase.instance.minValue;</code></pre></div><p>Or you can try to do it this way:<br /></p><div class="codebox"><pre><code>public static Vector3 GetWorldPositionWithAltitude(GpsCoordinates pos)
{
    double tlx, tly, brx, bry;
    OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);

    Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPositionWithElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);
    float el = OnlineMapsElevationManagerBase.GetUnscaledElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);

    float yOff = pos.y - el;
    yOff *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
    yOff *= OnlineMaps.instance.transform.localScale.x;
    p.y += yOff;

    return p;
}</code></pre></div><p>P.S. I wrote it without IDE, so there may be typos.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 04 Apr 2019 19:38:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4727#p4727</guid>
		</item>
		<item>
			<title><![CDATA[Re: Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4726#p4726</link>
			<description><![CDATA[<p>So i finally had time to implement it, and it&#039;s working well <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>One problem remains though : the altitude calculation.</p><p>I&#039;m using elevation, and the function <br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
    /// Return the World position of a GpsCoordinates position
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;pos&quot;&gt;GpsCoordinates position to convert&lt;/param&gt;
    public static Vector3 GetWorldPositionWithAltitude(GpsCoordinates pos)
    {
        Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPosition(pos.Longitude, pos.Latitude);

        OnlineMaps.instance.UpdateCorners();
        double tlx, tly, brx, bry;
        OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);

        p.y = (float)pos.Altitude;
        
        p.y += OnlineMapsElevationManagerBase.GetUnscaledElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);
        p.y *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
        p.y *= OnlineMaps.instance.transform.localScale.x;
        return p;
    }</code></pre></div><p>make my object appears below the ground. I need to calculate the relative altitude (if i feed my function with a position with altitude = 0, i want it to appear at the surface of the ground, whenever i&#039;m at the top of a mountain or at the bottom of a hole)</p><p>I tried to look at the markers3D code for the calculation of the relative altitude but failed to find the answer <img src="https://forum.infinity-code.com/img/smilies/hmm.png" width="15" height="15" alt="hmm" /></p>]]></description>
			<author><![CDATA[null@example.com (Thibault)]]></author>
			<pubDate>Thu, 04 Apr 2019 15:54:40 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4726#p4726</guid>
		</item>
		<item>
			<title><![CDATA[Re: Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4710#p4710</link>
			<description><![CDATA[<p>Yes, with proper implementation it will work faster than markers.</p><p>In general, the code looks (I have not tested it) well, except for the last part with scaling.<br />This way works for int zoom, but does not work for float zoom.<br />The right way:<br /><a href="http://forum.infinity-code.com/viewtopic.php?pid=4529#p4529">http://forum.infinity-code.com/viewtopi … 4529#p4529</a></p><p>You forgot to mention disabling / enabling the markers.<br />You can see the implementation of this in OnlineMapsMarker3D.Update.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 27 Mar 2019 23:06:11 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4710#p4710</guid>
		</item>
		<item>
			<title><![CDATA[Re: Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4708#p4708</link>
			<description><![CDATA[<p>Thanks for the response.</p><p>What i really need for those gameobjects are: </p><p>- follow the map when it&#039;s moving (so it stay at the exact gps location &amp; altitude)<br />- keep the same size proportionnally to the map zoom lvl (my gameObject should grow in size when the user zoom on the map)<br />- be disabled when out of the square map view</p><p>I think i could work with that. Is it an overkill to use 3D marker for this behaviour ?</p><p>Now correct me if i&#039;m wrong, but to implement this behaviour myself, i need to :&nbsp; </p><p>1) position my gameobject based on its GPS location. I will use this function :&nbsp; <br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
    /// Return the World position of a GpsCoordinates position
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;pos&quot;&gt;GpsCoordinates position to convert&lt;/param&gt;
    public static Vector3 GetWorldPositionWithAltitude(GpsCoordinates pos)
    {
        Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPosition(pos.Longitude, pos.Latitude);

        OnlineMaps.instance.UpdateCorners();
        double tlx, tly, brx, bry;
        OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);

        p.y = (float)pos.Altitude;
        
        p.y += OnlineMapsElevationManagerBase.GetUnscaledElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);
        p.y *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
        p.y *= OnlineMaps.instance.transform.localScale.x;
        return p;
    }</code></pre></div><p>Then to keep the proper position i would need to subscribe to <br /></p><div class="codebox"><pre><code>OnlineMapsTileSetControl.instance.OnMeshUpdated</code></pre></div><p>and use the function above to reposition my gameobject.</p><p>I also need to subscribe to <br /></p><div class="codebox"><pre><code>OnlineMapsTileSetControl.instance.OnSmoothZoomProcess</code></pre></div><p>to keep a&nbsp; proper scale for my gameobject. I think i should store the original scale of the gameobject for a given zoom lvl and adapt it to the current zoom level. Something like :</p><div class="codebox"><pre><code>/// &lt;summary&gt;
    /// Zoom, when the scale = 1.
    /// &lt;/summary&gt;
    public int defaultZoom = 20;</code></pre></div><p>And then each time OnSmoothZoomProcess is called : <br /></p><div class="codebox"><pre><code>float originalScale = 1 &lt;&lt; defaultZoom;
float currentScale = 1 &lt;&lt; OnlineMaps.instance.zoom;
float scale = currentScale / originalScale;
transform.localScale = new Vector3(scale, scale, scale);</code></pre></div><p>I&#039;m not sure that my pieces of codes are correct. I also don&#039;t now if i&#039;m missing some important stuff</p>]]></description>
			<author><![CDATA[null@example.com (Thibault)]]></author>
			<pubDate>Wed, 27 Mar 2019 16:15:47 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4708#p4708</guid>
		</item>
		<item>
			<title><![CDATA[Re: Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4623#p4623</link>
			<description><![CDATA[<p>Hello.</p><p>If you don&#039;t need marker events, then the best way is to position GameObjects on the map yourself using OnlineMapsTileSetControl.GetWorldPosition.<br />In fact, marker events are easy to implement using MonoBehaviour, so this should not be a problem.</p><p>First, it will work faster, because the markers have a lot of specific logic that is not needed for most projects.<br />Secondly, you no longer need to think about the features and limitations of the markers. You work directly with GameObjects.</p><p>No, the disabled marker doesn&#039;t cost anything for GPU, but still cost a little for CPU.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 12 Mar 2019 21:01:26 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4623#p4623</guid>
		</item>
		<item>
			<title><![CDATA[Pooling marker3D]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4621#p4621</link>
			<description><![CDATA[<p>Hi<br />I want to implement a pooling system for my marker3D gameobject. </p><p>I noticed that it&#039;s possible to create marker3D from existing gameobject (instead of instancing prefab).</p><p>So i&#039;m asking myself if i should :</p><p>- 1) make a pooling system for the gameobjects, and create marker3D (from pooled gameobject) when i need it and remove the marker3D when i put the gameobject back in the pool</p><p>- 2) make a pooling system for marker3D directly. Use OnlineMapsMarker3DManager.instance.Create to populate my pool and disable those marker, then just activate and set position when i need a marker.</p><p>From your experience, what would be best ?</p><p>solution 2) seems to be more in the &quot;pooling&quot; spirit.<br />But does a disabled marker3D &quot;cost&quot; anything in term of GPU ? Is it enought to disable its gameObject or is there a specific way to &quot;shut it down&quot; when it&#039;s not currently in use?</p><p>Thx for help <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Thibault)]]></author>
			<pubDate>Tue, 12 Mar 2019 18:52:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4621#p4621</guid>
		</item>
	</channel>
</rss>
