Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: PienueDut

26. May 2012, 09:40:46 am
Xith3D CommunityGeneral CategoryGeneral Discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)Cut Meshes?
Pages: [1]
Print
Author Topic: Cut Meshes?  (Read 756 times)
dinaharchery
Just dropped in

Offline Offline

Posts: 7


View Profile Email
« on: 12. December 2008, 01:12:00 pm »

Hello all,

I have a quick question:

Can Xith3D cut/trim a mesh? I have a cylinder that I need to trim with a circular shape - a bounded curve. I was thinking of creating mesh and then cutting it.

Thanks.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 12. December 2008, 02:54:42 pm »

There's no code in Xith, that is in just one line. But the code to do this is quite simple.

First you load your mesh and create a BoundingSphere of the size and position, that you need.

Then you loop through the meshes vertices and check each vertex-coordinate for containment against the BoundingSphere (there're methods available for that). If the vertex passes the test, you put it into a List of vertices (A vertex consists of a coordinate and optionally a normal, color, texture-coordinates and custom attributes. You would have to take this into account).

After that you simply create a new GeometryArray and put the remaining vertices into it.

That's all.

Marvin
Logged
dinaharchery
Just dropped in

Offline Offline

Posts: 7


View Profile Email
« Reply #2 on: 12. December 2008, 09:41:25 pm »

Thank you for the kind reply. I will give Xith3D a try - I am just getting too frustrated with the Java3D environment.

Can you (or anyone else) help me with the following newbie problem:

I have downloaded Xith3D-0.9.7-dev-B1618.zip and am trying out the "Chapter01a.java" code but am getting some strange results. The canvas3D GUI displays but has wierd bitmap images. The code follows:

Code:
import org.xith3d.loop.RenderLoop;
import org.xith3d.render.Canvas3D;
import org.xith3d.render.Canvas3DFactory;
import org.xith3d.base.Xith3DEnvironment;

/**
 * XIN - "Our fisrt Empty Scene" example coding.
 *
 * @author Marvin Froehlich (aka Qudus)
 */
public class Chapter01a {

    public Chapter01a() {
        Xith3DEnvironment env = new Xith3DEnvironment();
        Canvas3D canvas = Canvas3DFactory.createWindowed(800, 600,"My empty scene");
        env.addCanvas(canvas);
        RenderLoop rl = new RenderLoop(env);
        rl.setMaxFPS(120f);
        //rl.setXith3DEnvironment(env);
        // never forget to start the RenderLoop!
        rl.begin();
    }

    public static void main(String[] args) {
        new Chapter01a();
    }
}

The GUI pop-up is attached as a jpeg.

Any Ideas? I am running NetBeans6.5.


Once again, thank you.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 12. December 2008, 11:14:01 pm »

Could you please checkout xith from SVN? I'm pretty sure, that this but doesn't exist in the latest codebase.

Besides I just realized, that my cuttnig-advices above won't work like this. It's actually much more complicated. You would have to cut triangles against the sphere and generate new triangles. The new triangles could be taken from a Sphere primitive. But you would have to smoothly merge the borderline.

I could try to write some code, if you need help. But I'm not sure, if I will have the time in the next days. Just give it a try yourself.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic