Sign in to follow this  
Patzolino

I have troubles intersecting two spheres

Recommended Posts

Hello everybody ! My problem is next - i have two Mesh.Sphere and i want to unite them, cause now the one is above the other. I guess i have to intersect them, so the both spheres will look like one object, but the only method (Mesh.Intersect) i found returns bool and nothing really happens. If its not inconvinient for you, i will be very happy if you post some code with the answer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Patzolino
Hello everybody !
My problem is next - i have two Mesh.Sphere and i want to unite them, cause now the one is above the other. I guess i have to intersect them, so the both spheres will look like one object, but the only method (Mesh.Intersect) i found returns bool and nothing really happens. If its not inconvinient for you, i will be very happy if you post some code with the answer.


Mesh.Intersect probably return rue if the two mesh are intersecting each other. Creating an union (and not an intersection) of two mesh is harder. The simplest solution is to create a mesh that contains the two other meshes, but it should be better to avoid storing parts that are not visible. The correct solution is to ue CSG (constructive solid geometry) to do the job - and that's the hard thing... Here is a PDF presentation about this subject.

HTH,

Share this post


Link to post
Share on other sites
Thank you very much for the information. I took a look at the pdf file, and unfortunately it wont be very helpful to me since im not so advanced in the DirectX to manage to release the ideas in the pdf in DirectX code. You mentioned that there is a more simply way to do that. Since i dont have many objects in my project, i dont think it will be a big problem to keep the non-seeing sides. Would you help me with releasing this your idea? Thank you very much !!
Best regards, Plamen Dimitrov

Share this post


Link to post
Share on other sites
Quote:
Original post by Patzolino
Thank you very much for the information. I took a look at the pdf file, and unfortunately it wont be very helpful to me since im not so advanced in the DirectX to manage to release the ideas in the pdf in DirectX code. You mentioned that there is a more simply way to do that. Since i dont have many objects in my project, i dont think it will be a big problem to keep the non-seeing sides. Would you help me with releasing this your idea? Thank you very much !!
Best regards, Plamen Dimitrov


I didn't read your answer when I PM'ed you, thus you can (nearly) forget my PM.

To create a simple union of two meshes, you'll have to read the informations of a mesh and add these informations to the other mesh. For example, consider a very simple mesh with a single triangle and - of course - 3 points. You want to 'unite' this mesh with a similar one.

mesh A;
mesh B;
int vcount = B.get_vertice_count();
for each vertex V in A
add V in B
// T(a,b,c) is a triangle that uses vertices a,b,c in the vertice list
for each triangle T(a,b,c) in A
create a triangle T'(a+vcount,b+vcount,c+vcount)
add T' to B

It seems you are csharping, and I don't know much about this language. I hope the pseudo-code above will help you. Of course, the DX SDK may be more complex (the mesh SDK deals with mesh parts and so on) but you get the idea.

Regards,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this