Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - aZen

Pages: 1 ... 4 5 [6] 7
76
Support / Flat Shading + Culling = Black
« on: May 16, 2013, 12:57:06 pm »
When I use

Code: [Select]
object3D.setAdditionalColor(SOME_COLOR);
object3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);
object3D.setTransparency(0);
object3D.setCulling(false);

in software mode, everything is rendered transparent, but just black. Is this something that could be fixed without too much effort?

Thank you,
aZen

Edit: Edited the title to reflect the problem better.

77
Bones / Re: Animation Editor
« on: May 15, 2013, 06:45:16 pm »
Things are looking pretty solid!

Only one question so far: When I enable setShadingMode(Object3D.SHADING_FAKED_FLAT), the texture is not drawn (the triangles are just black). Is that by design?

Edit: Nvm, that's related to jpct. See here: http://www.jpct.net/forum2/index.php/topic,3394.0.html

78
Bones / Re: Animation Editor
« on: May 15, 2013, 01:39:40 pm »
Wohoo, I finally got it to work. The problem was that I didn't (don't?) understand how the SkinData constructor is used. Apparently you have to use all four weighted joints (even if the weight on the others is zero).

Will come back with a more structured example (and possible one or the other question)!

Thanks :)

79
Bones / Re: Animation Editor
« on: May 15, 2013, 10:42:48 am »
Hey, I'm back :)

So here is what I've got so far (just trying to get a really simple testcase working). Unfortunately I'm not sure how to animate it now (it always crashes when I try to call animate). Could you please have a look at it?

Thank you very much!
aZen

Code: [Select]
package vitco;

import com.threed.jpct.*;
import raft.jpct.bones.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * The main class.
 */
public class Main extends WindowAdapter implements MouseMotionListener {

    static FrameBuffer buffer;
    static World world;
    Object3D box;
    JFrame frame;

    Animated3D animated3D;

    public Main() {
        // set up frame
        frame = new JFrame("Hello Animation!");
        frame.setSize(800, 600);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        // set up world
        world = new World();
        world.setAmbientLight(0, 0, 0);
        world.addLight( new SimpleVector( 500,-500,500),new Color(20,20,20) );
        Config.fadeoutLight = false;

        // ==========================

        // 1) create mesh data
        MeshData meshData = new MeshData(
                        // coordinates of the vertices
                        new float[] {10, 0, 0, 0, 10, 0, 0, 0, 10},
                        // uv texture coordinates of the vertices
                        new float[] {0, 0, 1, 0, 0, 1},
                        // assigned indices to identify the vertices
                        new int[] {0, 1, 2});

        // 2) create a Skeleton which consists of Joint's
        Matrix matrix = new Matrix();
        matrix.rotateX((float) (Math.PI/2));
        matrix = matrix.invert();
        Skeleton skeleton = new Skeleton(
                new Joint[]{
                        // Note: # is joint index (not vertex index!)
                        // matrix, id, parent joint, name
                        new Joint(matrix, 0, Joint.NO_PARENT, null),
                        new Joint(matrix, 1, Joint.NO_PARENT, null),
                        new Joint(matrix, 2, Joint.NO_PARENT, null),
                }
        );

        // 3) create a SkeletonPose
        SkeletonPose skeletonPos = new SkeletonPose(skeleton);

        // 4) create a SkinData to define how skeleton joints effect mesh
        SkinData skin = new SkinData(
                new float[][] {
                        // vertex index -> weight
                        new float[]{0.5f,0.5f},
                        new float[]{1f},
                        new float[]{1f}
                },
                new short[][]{
                        // vertex index -> joint index
                        new short[]{0,1},
                        new short[]{1},
                        new short[]{2}
                });

        // 5) create an Animated3D with MeshData, SkinData and SkeletonPose
        animated3D = new Animated3D(meshData, skin, skeletonPos);

        // 6) create JointChannel's for Joint's to define movements and rotations of Joint during animation
        // joint index, times, translation, rotation, scales
        JointChannel jointChannel = new JointChannel(0,
                new float[]{1, 1},
                new SimpleVector[]{new SimpleVector(1,0,0), new SimpleVector(0,1,0)},
                new Quaternion[]{Quaternion.IDENTITY, Quaternion.IDENTITY},
                new SimpleVector[]{new SimpleVector(1, 1, 1), new SimpleVector(1, 1, 1)}
        );

        // 7) create a SkinClip out of that JointChannel's. that's a single animation
        SkinClip skinClip = new SkinClip(skeleton, jointChannel);

        // 8) create a SkinClipSequence out of one or more SkinClip's and assign that to Animated3D or AnimatedGroup
        SkinClipSequence skinClipSequence = new SkinClipSequence(skinClip);
        animated3D.setSkinClipSequence(skinClipSequence);

        animated3D.setAdditionalColor(Color.RED);
        animated3D.setEnvmapped(Object3D.ENVMAP_ENABLED);
        animated3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);
        animated3D.setCulling(false);
        animated3D.rotateY(3f);
        animated3D.build();

        world.addObject(animated3D);

        // ==========================

        // set up camera
        world.getCamera().setPosition(50, -50, -5);
        world.getCamera().lookAt(SimpleVector.ORIGIN);

        // set up frame buffer
        buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);

        // set up event handler
        frame.addMouseMotionListener(this);
        frame.addWindowListener(this);
    }

    @Override
    public void windowClosing(WindowEvent e) {
        // clean up when closing
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        frame.dispose();
        System.exit(0);
    }

    @Override
    public void mouseDragged(MouseEvent e) {}

    private int value = 0;

    @Override
    public void mouseMoved(MouseEvent e) {
        // animate and redraw
        buffer.clear(Color.LIGHT_GRAY);
        world.renderScene(buffer);
        world.draw(buffer);
        buffer.update();
        buffer.display(frame.getGraphics());
    }

    // constructor
    public static void main (String[] args) {
        new Main();
    }


}

80
Bones / Re: My Skeleton Helper
« on: May 11, 2013, 12:04:35 pm »
Omg, I love you so much. You have no idea how much work this will save me!

81
Support / Re: Multithreading Freezes Program
« on: May 07, 2013, 01:40:14 pm »
I think I really fixed the issue finally. It turned out there was some twisted thread calling going on that ended up synchronize blocking. Multithreading messes with your head, that's for sure :o All is working great so far and it's so fast!

Sorry for the trouble. I'm very grateful for all your help!

82
Support / Re: Multithreading Freezes Program
« on: May 06, 2013, 01:07:31 am »
Sorry, I didn't mean to be speculative. It's just that I restructured and separated all parts of my code that "touch" the jpct and the symptoms are still the same.

Without a clean testcase I can't really say anything for sure though. Will do it when I find some chunk of free time! Thanks for the help.

83
Support / Re: Multithreading Freezes Program
« on: May 03, 2013, 10:54:56 pm »
Nvm, it still happens. I restructured the entire application (to be sure nothing "fishy" is going on). The exact same thing still happens (just that now the freeze doesn't happen right at the start).

What kind of code are you pushing to the AWT from the rendering threads?

Note: Input is now entirely decoupled from the rendering/data processing thread.

Edit: From what I can see this caused by your code. It probably has to do with the fact that I'm rapidly updating objects in the world. Do I need to synchronize these updates?

If I find the time I'll write a test case.

84
Support / Re: Multithreading Freezes Program
« on: May 03, 2013, 03:34:31 pm »
Thank you for the help! I finally managed to fix the problem by decoupling swing "repaint" and the repaint logic (and using a lot of synchronization)..

85
Support / Re: Multithreading Freezes Program
« on: May 02, 2013, 04:25:02 pm »
That sounds like it's gonna take a while to find the problem.

Attached the thread dump(s). Not sure how useful they're gonna be.

Let me briefly explain how the application is laid out:
- There are four rendering container (JPanel) and each of them contains a FrameBuffer
- Interaction on one container (mouse) can change the content of the other container and trigger a repaint. The input events are caught by the JPanel
- Repainting is done from four worker threads by calling JPanel.repaint() (synchronizing the calls, or calling directly doesn't help with the freeze)
- The FrameBuffer are recreated when the the container are re-sized (since resize(x,y) doesn't work with the software renderer).
- when the container needs to be repainted the JPanel.repaint() method is called (from a worker thread) which then calls an overridden JPanel.paintComponent(Graphics g1) method. This then draws the FrameBuffer(s) and some overlay on the graphics argument.

Note: Sometimes the application initializes correctly and doesn't freeze for a bit. Mouse interaction then causes a freeze very quickly.

You said that the input might be a problem. Is it correct to capture it in the JPanels (they live in the main thread)? I'm out of ideas how to tackle this. Any idea what I should try to find the issue? Currently I'm using VisualVM, but still getting used to it.
Things would be a lot easier if I could reproduce the problem in my production environment, but unfortunately there it's running great (I can see big improvements through the multi-threading actually).

Thank you for your help.

Edit: Could this have something to do with the graphic card (that is available when it freezes)? Is MODE_OPENGL used when there is no graphic card or is there a fallback to MODE_LEGACY in that case?

[attachment deleted by admin]

86
Support / Multithreading Freezes Program
« on: May 01, 2013, 08:35:43 pm »
Hello EgonOlsen,

I'm having a strange problem: When I set useMultipleThreads = true I can run the application fine on my virtual machine (win 7, 32 bit). However when I start it on a non virtual os (win 7, 64 bit) the application simply freezes (tested on two different computers).

With useMultipleThreads = false there is no problem at all. Could this be a problem with 64 bit os? I'm using the latest jpct built (http://jpct.de/download/beta/jpct.jar).

Thanks you,
aZen

87
Support / Re: Visible Objects
« on: February 08, 2013, 11:55:46 pm »
http://www.jpct.net/doc/com/threed/jpct/Object3D.html#wasVisible%28%29

Oh, so it doesn't return true for empty, visible dummy objects (e.g. no triangles added)? At least that's what my testing shows. It's fine for now. Enough optimization :)

88
Support / Re: Visible Objects
« on: February 08, 2013, 11:00:09 pm »
Downloaded the new jar file and yes, wasVisible() worked!

Can I also query for all objects that are in the view of the camera? Even those that did not get rendered? At the moment I'm converting all object centers into 2D and checking those.

Btw super fast reply, thank you!

89
Support / Visible Objects
« on: February 08, 2013, 07:09:44 pm »
Is there an efficient way to get all visible objects (or all objects rendered in last frame)? I tried using world.getVisibilityList(), but did not understand how to access the VisList object.

Thanks for your help!
aZen

90
Bones / Re: Animation Editor
« on: November 11, 2012, 08:53:16 pm »
That was a fast response, thank you!

As to why I'm doing this: The 3D editor is actually built for "ease of use", to create a specific art style. Once the company decides to release it to the public, I will post a link here and you will understand much better.

I really appreciate that you are investing this time to help me and will try to keep the stupid questions to a minimum! This should be fun after all.

And yes, I know that skeleton animation is a complex subject, but I have a strong math background and I love challenges. Also my head-to-wall threshold is quite high :)

Pages: 1 ... 4 5 [6] 7