<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Converting 3D Points to Screen Space X&amp;Y]]></title><description><![CDATA[<p dir="auto"><em>On 28/07/2018 at 16:27, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hello,<br />
I'm trying to get the X&amp;Y pixel coordinates of my polygon plane's vertices (as well as their depth). The output dimensions are 4096x2160 pixels (attached). These are the plane's 3D vectors followed by the pixel coordinates I'm looking to get:</p>
<pre><code># Top Left Corner: (-200,200,0) -&gt; 1493,505
# Top Right Corner: (200,200,0) -&gt; 2458,471
# Bottom Left Corner: (-200,-200,0) -&gt; 1524,1712
# Bottom Right Corner: (200,-200,0) -&gt; 2438,1509
</code></pre>
<p dir="auto">How can I do this in Python? I've tried to use BaseDraw's WC, WC_V, WS, CS methods, but I'm not sure what to do with their results as they are not in pixels.</p>
<pre><code>WC: Vector(-174.873, 181.224, 1288.966) # Top Left Corner
WC then CS: Vector(472.901, 423.506, 1288.966) # Top Left Corner
WS: Vector(472.901, 423.506, 1288.966) # Top Left Corner
WC_V: Vector(-163.448, 174.118, -151.55) # Top Left Corner
CS: Vector(-25959351, -25959394, 0),Vector(25960649, -25959394, 0),Vector(25960649, 25960606, 0),Vector(-25959351, 25960606, 0) # All four vertices
</code></pre>
<p dir="auto">Thank you.</p>
<p dir="auto"><img src="https://image.ibb.co/jwifm8/Vector_Export.jpg" alt="" class=" img-fluid img-markdown" /></p>
]]></description><link>http://developers.maxon.net/forum/topic/10887/14334_converting-3d-points-to-screen-space-xy</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 15:02:51 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10887.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Sep 2018 10:51:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:52:04 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 07/08/2018 at 03:05, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Blastframe, thanks for following up.</p>
<p dir="auto">With regard to your last post, I need to apologize cause I provided a misleading information being myself confused by the documentation. Actually the BaseView::TestPointZ() verify if a given point is within the camera near/far clipping range and not if the point is occluded by any other object.</p>
<p dir="auto">In your case instead, you should think about a more complex design where each of your point is tested against any other geometry found in the scene by using a <code>GeRayCollider()</code>[URL-REMOVED] and then evaluate the result according to the intersection distance.</p>
<p dir="auto">Unfortunately there's no other turn-key solution to achieve your desired functionality.</p>
<p dir="auto">Best,  Riccardo</p>
<hr />
<p dir="auto">[URL-REMOVED] <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/maxon">@<bdi>maxon</bdi></a>: This section contained a non-resolving link which has been removed.</p>
]]></description><link>http://developers.maxon.net/forum/post/55341</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55341</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:52:04 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:52:01 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 06/08/2018 at 12:09, <strong>xxxxxxxx</strong> wrote:</em></p>
<blockquote>
<p dir="auto"><strong>Originally posted by xxxxxxxx</strong></p>
<p dir="auto">Hi Blastframe, thanks for following up.</p>
<p dir="auto">With regard to your last question, consider that the point being passed to the <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/index.html?highlight=testpointz#BaseView.TestPointZ" target="_blank" rel="noopener noreferrer nofollow ugc">BaseView::TestPointZ()</a>needs to be expressed in camera space and not in world space. Then I warmly suggest to use <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/index.html?highlight=wc#BaseView.WC" target="_blank" rel="noopener noreferrer nofollow ugc">BaseView::WC()</a> before passing your point to the TestPointZ function.</p>
<p dir="auto">Best, Riccardo</p>
</blockquote>
<p dir="auto">Hi Riccardo,<br />
Thank you for all of your help with my issue. Per your advice, I tried converting to camera space, but the results for all points were still true, even if they were blocked by self geometry or another object.</p>
<pre><code>        pointToCS = renderBD.WC(point)
        print renderBD.TestPointZ(pointToCS)
</code></pre>
<p dir="auto">Maybe this is not what TestPointZ is checking? I am wanting to skip vertices that are not visible. Thank you.</p>
]]></description><link>http://developers.maxon.net/forum/post/55340</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55340</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:52:01 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:58 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 06/08/2018 at 00:23, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Blastframe, thanks for following up.</p>
<p dir="auto">With regard to your last question, consider that the point being passed to the <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/index.html?highlight=testpointz#BaseView.TestPointZ" target="_blank" rel="noopener noreferrer nofollow ugc">BaseView::TestPointZ() </a>needs to be expressed in camera space and not in world space. Then I warmly suggest to use <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseView/index.html?highlight=wc#BaseView.WC" target="_blank" rel="noopener noreferrer nofollow ugc">BaseView::WC()</a> before passing your point to the TestPointZ function.</p>
<p dir="auto">Best, Riccardo</p>
]]></description><link>http://developers.maxon.net/forum/post/55339</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55339</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:58 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:55 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/08/2018 at 07:57, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">My apologies, I do have one follow-up question. I see the line with # notify about points outside the render frame</p>
<p dir="auto">How could I tell if the point is being obscured by other geometry? Would this be</p>
<pre><code>renderBD.TestPointZ(point)
</code></pre>
<p dir="auto">?</p>
<p dir="auto">When I use this with the plane highlighted in green, it returns False for two of the points which are visible.</p>
<pre><code>point: [ Vector(0, 200, -200) ] / [ (576.2718396467545, 166.23981331428323) ]
Visible: False
  
point: [ Vector(0, -200, -200) ] / [ (589.7969294792699, 878.0441715337967) ]
Visible: False
  
point: [ Vector(0, 200, 200) ] / [ (1066.6762020149142, 205.85938605460527) ]
Visible: True
  
point: [ Vector(0, -200, 200) ] / [ (1063.7210058999553, 771.3600524945704) ]
Visible: True
</code></pre>
<p dir="auto"><img src="https://image.ibb.co/ns4yiz/Planes.png" alt="" class=" img-fluid img-markdown" /></p>
]]></description><link>http://developers.maxon.net/forum/post/55338</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55338</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:52 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/08/2018 at 07:33, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">WOW! You did it, Riccardo! Thank you very much <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--smile" style="height:23px;width:auto;vertical-align:middle" title=":smile:" alt="😄" /> I'm very impressed and grateful.</p>
]]></description><link>http://developers.maxon.net/forum/post/55337</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55337</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:52 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:50 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 03/08/2018 at 06:23, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Blastframe thanks for following up.</p>
<p dir="auto">I've prepared the following script hoping it works nicely for you.</p>
<pre><code>def main() :  
  # check for doc being valid  
  if not doc:  
      return  
    
  # retrieve the BaseDraw of the view set to "Use as Render View"  
  renderBD = doc.GetRenderBaseDraw()  
  if not renderBD:  
      return  
    
  # retrieve the safe-frame information  
  renderSafeFrame = renderBD.GetSafeFrame()  
  renderSafeFrameRes = (renderSafeFrame['cr'] - renderSafeFrame['cl'], renderSafeFrame['cb'] - renderSafeFrame['ct'])  
    
    
  # retrieve active RenderData  
  rData = doc.GetActiveRenderData()  
  if not rData:  
      return  
    
  # get render data  
  rDataBC = rData.GetDataInstance()  
  if not rDataBC:  
      return   
    
  # store frame resolution  
  frameRes = (rDataBC.GetInt32(c4d.RDATA_XRES), rDataBC.GetInt32(c4d.RDATA_YRES))  
  
    
  # check there's a valid active object  
  if not op or not op.IsInstanceOf(c4d.Opolygon) :  
      return      
    
  # get the points or return instance it's not valid  
  points =  op.GetAllPoints()  
  if not points:  
      return  
    
  # loop through points  
  for point in points:  
      # transform point from World to Screen  
      pointToScreen = renderBD.WS(point)  
      # notify about points outside the render frame  
      if pointToScreen.x &gt; renderSafeFrame['cr'] or pointToScreen.x &lt; renderSafeFrame['cl']:  
          print " -- x-coordinate out of frame area --- "  
      if pointToScreen.y &gt; renderSafeFrame['cb'] or pointToScreen.y &lt; renderSafeFrame['ct']:  
          print " -- y-coordinate out of frame area --- "  
      # compensate the x/y offset              
      pointsR_XY = (pointToScreen.x - renderSafeFrame['cl'], pointToScreen.y -renderSafeFrame['ct'])          
      # scale with regard of the final frame size  
      pointsR_XY_2 = (pointsR_XY[0] * frameRes[0] / renderSafeFrameRes[0], pointsR_XY[1] * frameRes[1] / renderSafeFrameRes[1])  
      # just print  
      print "point: [", point ,"] / [", pointsR_XY_2, "]"  

</code></pre>
<p dir="auto">Let me know if something is unclear or wrong.<br />
Cheers, Riccardo</p>
<p dir="auto"></p>
]]></description><link>http://developers.maxon.net/forum/post/55336</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55336</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:50 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:47 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 02/08/2018 at 08:41, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Riccardo,<br />
Thank you again for the reply. To answer your questions:</p>
<ol>
<li>the context is Rendering.</li>
<li>The output dimensions are the size of the rendered image</li>
</ol>
<p dir="auto">I used the code you provided with GetRenderBaseDraw(). It still is giving me numbers that do not equate to the X &amp; Y coordinates in pixels. For example, if the rendered image is 1920x1080 and I have a point at 0,200,-200, the pixel coordinates in the image are 657 x 144. The script's output is:</p>
<pre><code>point: [ Vector(0, 200, -200) ] / [ Vector(443.885, 338.496, 880.435) ]
</code></pre>
<p dir="auto">If I use the Camera to screen conversion method, I get closer, but the Y is a crazy value:</p>
<pre><code>    for point in points:
        print "point: [",point,"] / [", activeBD.CS(point, True),"]"
</code></pre>
<p dir="auto"><strong>Output:</strong></p>
<pre><code>point: [ Vector(0, 200, -200) ] / [ Vector(649, -25959394, -500000000) ]
</code></pre>
<p dir="auto">Can you help me get the values that I'm seeking? Thanks again!</p>
]]></description><link>http://developers.maxon.net/forum/post/55335</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55335</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:47 GMT</pubDate></item><item><title><![CDATA[Reply to Converting 3D Points to Screen Space X&amp;Y on Sat, 01 Sep 2018 10:51:44 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 30/07/2018 at 08:32, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi blastframe, welcome to our community and thanks for writing here.</p>
<p dir="auto">With regard to your question, there are a couple of point missing:</p>
<ol>
<li>what's the context? Rendering or Viewport?</li>
<li>The output dimensions you're reporting is the size of the rendered image or is it the size of the viewport?</li>
</ol>
<p dir="auto">As a rule of thumb, in case you're evaluating the viewport in a rendering context it's recommended to use <a href="http://BaseDocument::GetRenderBaseDraw%28%29">BaseDocument::GetRenderBaseDraw()</a> whilst if in viewport feel free to use <a href="https://developers.maxon.net/docs/cpp/2023_2/class_base_document.html#adcc7bde927035ef5c994bd597844d5f6" target="_blank" rel="noopener noreferrer nofollow ugc">BaseDocument::GetActiveBaseDraw()</a>.</p>
<p dir="auto">Aside fro this also note that the origin of the screen space is the top/left corner - where the "Perspective" label is - and ends on the bottom/right  - where the "Grid spacing" label is.</p>
<p dir="auto">A brief test in viewport provides the correct results with this code</p>
<pre><code>def main() :  
  if not doc or not op:  
      return  
    
  activeBD = doc.GetActiveBaseDraw()  
  if not activeBD:  
      return  
    
  points =  op.GetAllPoints()  
  if not points:  
      return  
    
  for point in points:  
      print "point: [",point,"] / [", activeBD.WS(point),"]"  
    
if __name__=='__main__':  
  main()  

</code></pre>
<p dir="auto">Hoping it helps, give best.</p>
]]></description><link>http://developers.maxon.net/forum/post/55334</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55334</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:51:44 GMT</pubDate></item></channel></rss>