Does anyone know if/how you can check for faces which are visible through a defined camera? If possible this should ignore those faces which are occluded by others (and those backculled). Cheers in advance for any help on this.
use se
Think you might have misunderstood my question (correct me if I'm wrong). What I want to do is to animate a camera and get a script to report back on what faces are visible to it at a certain frame.
you can do full selection each frame. And do a new selectionconstrain based on camera.
What do you need this for? (I meanif you turn backface culling (eg set the object one sided maya ayutomaticaly hides the faces facuing away!?) Its not realy possible to know wich ones are occluded tough (thats what teh zbuffer is for you know)!
Cheers sounds pretty much what I'm looking for. Sorry to be so dense but could you give me a fuller description of how this is achieved? An example of what you mean would be extremely helpful.
What do you need it for! The purpose is to give usefull answers not kludges that work at best very slowly.
If you only give me a step on the way i cant REALY help you. I can solve the step and then your even deeper in a mess, if you arent carefull.
What I need it for is to allow me to optimise a scene and go someway to remove faces which are unneccessary. (please don't reply saying I should have built the scene right in the first place as this isn't relevant). How can you giving me advice on wether something is possible in maya get me in a mess? (no offence but that sounds slightly patronising) I don't care wether it is slow as I can then automate the optimisation which will save me a great deal of time.
Well the problem is generaly if i give bad advice i want to know if the bad advice can be worthwhile. Se if someone need to ask then theres 2 cases to consider 1 how to get from the asked point A to B but theres an option that the bad turn was made allready earlier in wich case id RATHER give the advice form start to end rather than giving a small step on the way.
NOW, you dont need mel for bacface culling. All you need is to make sure your normals are conformed (ie the normals all point in the same direction, otherwise this will get MESSY, even the selection does have the same porblem). Then fire up the atribute speradsheet, select all objcts go to the render tab and check double sided to be off (you can select many items at a time thisway easily), and blam maya makes backface culling.
And thats the best you can do, if you dont have raytracing on then maya will not load things outside of the view. If you have raytracing be sure to only include those objects that realy need to be part of raytracing in the rayrytrace engene, turn the rest off.
Its no use to automate something via script thats allready automated by the rendereingene! its only going to be slower so in the end it takes longer.
The only time youd gain anything form this is if your scene is largely static and you have LOT of extra geo that shouldnt be there in the firstplace.
did you even try using the selectin constraint thing (because if you did youd allready done it the ugly way around)!
Then if you realy need to optimize rendertimes its a matter for the renderforum. Mostly itt involves turning all file textures to bots (wich actualu uses most of the mem anyway).
So the wquestion distills to this do you need this for maya or mr rendering or SOMETHING different!
I don't need it for rendertime improvement. It's to reduce the polygon count in the scene based on a camera that I can predict. This will then be exported to a game engine. All the talk of normals is completely irrelevant. Yes I do need to script it otherwise it will be a question of manually removing polygons.
I don't need it for rendertime improvement. It's to reduce the polygon count in the scene based on a camera that I can predict. This will then be exported to a game engine. Conforming the normals is certainly not what I need as this will remove the ability to check wether they are facing toward or away from the camera. Yes I do need to script it otherwise it will be a question of manually removing polygons.
As I stated in my last post it is to reduce the number of polygons in a scene based on visibility to a known camera. I therefore need to run a camera through the scene and find which faces are visible to it. Those that are never visibile will then be deleted.
Ok in that case! next time whan someone asks you what ist for you answer wghat ist for. Youd be supprised how many times the step people ask for is the one they shouldnt have been contemplating on at all!
backfacing is easily implemented but occlusion inst. Infact occlusion is a bit hard to implement.
look at polySelectConstraint command like i said in my first post (sorry i asumed that since you were asking on a mel forum you knew that if maya had a ui for something it also had the capability of telling you what the commands in that ui are!). Then select everything run that select again etc etc.
Could you explain how this is of any relevance to my question? I know about selection constraints which is fine If I am going to manually select faces in a viewport. That is not what I want to do. Hence this post being in the mel forum. Again I apologise for being dense but if there is any relevance to your reply could you please tell me how as I can see no connection between your answer and my post. I don't see how I could have phrased the post any more clearly but I apologise if I haven't give enough information.
It allows you to filter all the faces that are visible to certain camera point with acertain fov! God damit is it too hard to ask you to read the mel reference.
You dont need to manualy select the faces you know. You can select all faces with mel toggle selection contraint on and blam you have them selected. Jeez. hope the plug works for you tough!
Ok now ive realy awakened and can make a proper answer for you. So the underling problem is that you dont know how to operate maya so here goes.
Working with mel
Wery often a newbie sits and wonders how more eperienced users know what command to use. Well the answer is we dont! But underlying mechanisms in maya states teht 95% of everything that can be done in maya UI can be done in mel too.
How do you know? Well you ask maya. Maya has 3 primary tools for knowing waht to do. Namely the scriptEditor, the Hypergraph and the command referece in help (along with node reference for working with ndes)
Working with script editor. Now whenever you do something maya echoes what command was used to do that in the script editor, however it doesnet echo everything unless you set echo all command soption on in the script menu. But usualy by the time you check it maya echoes too much. Youll juts have to read it all, usualy the actual command that does executing is apparent.
Exampe we want to select everything, deselect all and righclick on maya viiewport and select all now if you didnt have echo all on you wouldnt know what may adid if you did have it on maya ould tell you that the command is either select -allDagObjects; or SelectAll;, infact both do what you want but the other is just a prcedure for the first.
Now changing this selection to faces you go to Edit Polygons -> Selection -> convert selection to faces. and maya will not so helpfully tell you that the command is either ConvertSelectionToFaces; or PolySelectConvert 1; As allways the firts is a wrapper but it works.
time to test our code that now reads
SelectAll;
ConvertSelectionToFaces;, select the text unselect all objects and while the script editor is active hit enter form numpad. Now maya selects all faces. Fine then for the selection constraint open teh selection constraint window and apply a constraint on the selection you lnotice that it gives a command polySelectConstraint -m 2; when you enter it to current and next mode. And that all you need to do. After feeding the cordinates too. so querry on.
So tu cut it short the final code is:
SelectAll;
ConvertSelectionToFaces;
SelectAll;
ConvertSelectionToFaces;
polySelectConstraint -va camera focal view -vp cameraposX cameraposY cameraposZ $fv[2]-m 2;
Now all you need is to querry the apropriate walues and enter in. Tip use $selection =
Thank you very much Mr Campbell
At last someone who has restored my faith in this forum. Thought I was going to spend the rest of my life in an endless loop pointing out that I was obviously far too dense to deign to try and do something productive with Maya.
Cheers again.
no problems. selectionConstraints would do the trick too (as joojaa has laboured for ya), but this is ready to go.
joojaa is awesome, she knows her stuff uber well, and will spend the time to offer great answers.... she can just get a little snappy sometimes, a little frustrated about various things. cant ya joojaa? ![]()
He!
But thanx for the vote of confidence.
Sometimes frustrated isnt enough to even begin explain things yes! Its just sometimes it feels like your in a sortoff atime limbo. Whare you repeat yourself. BUt truuth is that even if i occasionaly consider stopping frequenting this forum I still do learn new stuff everyday. Even lessons in humility.