Converting 3D Points to Screen Space X&Y

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  2 Weeks Ago
Converting 3D Points to Screen Space X&Y

Hello,I'm trying to get the X&Y pixel coordinates of my polygon plane's vertices. The output dimensions are 4096x2160 pixels (attached). These are the plane's 3D vectors followed by the pixel coordinates I'm looking to get:
# Top Left Corner: (-200,200,0) -> 1493,505
# Top Right Corner: (200,200,0) -> 2458,471
# Bottom Left Corner: (-200,-200,0) -> 1524,1712
# Bottom Right Corner: (200,-200,0) -> 2438,1509

Does anyone know how can I do this in Python? I've tried to us BaseDraw's WC, CS, WS, and WC_V methods, but I'm not sure what to do with their results (which are not in pixels).
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


Thank you.




 
  1 Week Ago
Hey brother, I want to tell you that this effect can be achieved in c4d. I created something similar to c4d's own annotation tag feature, where I let him display the data is the pixel result you want. I am sorry that I have not disclosed the idea of this technology for the time being, because I am still a newcomer. At this stage, I need to reserve some intellectual property for myself. I only recently registered this forum and started uploading my own work on other websites.I hope you can understand me.But what I want to say is that I think there are many ways to do this. I hope my video can give you some inspiration. Once again, I am sorry that I didn't tell you the answer directly.Of course, I don't rule out the possibility that BaseDraw can accomplish this effect. I don't know much about this class. But I think this data could be useful, even if I don't know how to use it effectively.But I am curious if the scope of the view exceeds the rendered area, what effect will it have on the results?I hope my video can give you inspiration.https://vimeo.com/282510869

Last edited by LLAN : 1 Week Ago at 09:24 PM.
 
  1 Week Ago
Originally Posted by LLAN: Hey brother, I want to tell you that this effect can be achieved in c4d. I created something similar to c4d's own annotation tag feature, where I let him display the data is the pixel result you want. I am sorry that I have not disclosed the idea of this technology for the time being, because I am still a newcomer. At this stage, I need to reserve some intellectual property for myself. I only recently registered this forum and started uploading my own work on other websites.I hope you can understand me.But what I want to say is that I think there are many ways to do this. I hope my video can give you some inspiration. Once again, I am sorry that I didn't tell you the answer directly.Of course, I don't rule out the possibility that BaseDraw can accomplish this effect. I don't know much about this class. But I think this data must be useful, even if I don't know how to use it effectively.But I am curious if the scope of the view exceeds the rendered area, what effect will it have on the results?I hope my video can give you inspiration.https://vimeo.com/282510869

Thank you for the response! Best wishes for your inspiring plugin!
 
  1 Week Ago
Originally Posted by blastframe: Thank you for the response! Best wishes for your inspiring plugin!
I wish you a better solution early.I think c4d has reserved a lot of freedom for us so that we can do all sorts of things. There are many ways to solve an effect. If one method doesn't work, change one. This is my recent sentiment. Similarly, I thank you for your reply.
 
  1 Week Ago
Is this what you're asking for?

Put this code in a python tag
import c4d
def main():

 bd = doc.GetActiveBaseDraw()
 win = bd.GetEditorWindow()
 
 obj = doc.GetActiveObject()
 if obj is None or obj.GetType() != c4d.Opolygon: return
 
 points = obj.GetAllPoints()

 #The first point in the object 
 points[0] = bd.WS(points[0]) #<--- The screen coords
 print points[0]


-ScottA
__________________
My Gallery
 
  1 Week Ago
Hey brothers, if you just want to get pixel values conveniently, I think of another way to do this. I would love to share this method for you, which is to use the toComp([0,0]) function in Adobe After Effects. This function perfectly accomplishes your desired goals. You only need to pour the 3D information of the c4d project into Adobe After Effects. A lot of tutorials on this function can be found online. Finally, I hope that your problem can be solved.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:47 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.