www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: elhoce on March 06, 2012, 07:58:19 pm

Title: shaders and animations
Post by: elhoce on March 06, 2012, 07:58:19 pm
Hi,

I have a problem with shaders,  my model don't move (bones animation) when I activate a shader

my code

GLSLShader shader = new GLSLShader(Loader.loadTextFile("./vertexshader_body.glsl"),Loader.loadTextFile("./fragmentshader_body.glsl"));
        for (Animated3D o : animatedGroup) {
            o.getName();
            o.setTexture("corps");
            o.setRenderHook(shader);
            o.compile();
            o.build();
            o.discardMeshData();
        }

if I comment o.compile() my model moves but without shader  :-[

Can you please tell me why ?

Thanks
Title: Re: shaders and animations
Post by: EgonOlsen on March 06, 2012, 08:01:20 pm
Replace o.compile() vy o.compile(true); and add a call to Object3D.touch() right after calling the animation method.
Title: Re: shaders and animations
Post by: elhoce on March 06, 2012, 08:43:16 pm
Thanks now it works fine !

I have another question, I have a model composed of several parts,  How can I disable the normal auto computing during the loading model ?
I have already comment the Object.build() call.

Thanks
Title: Re: shaders and animations
Post by: EgonOlsen on March 06, 2012, 08:49:33 pm
Why do you want to do this? Without normals, no lighting will work properly.
Title: Re: shaders and animations
Post by: elhoce on March 06, 2012, 08:59:07 pm
because my file already contains precalculated normal data, and because my model looks bad between the parts in jpct
Title: Re: shaders and animations
Post by: EgonOlsen on March 06, 2012, 09:07:45 pm
jPCT doesn't load normal data from the file. It fully relies on its own calculations. What's the problem "between the parts" (screen shot)?
Title: Re: shaders and animations
Post by: elhoce on March 06, 2012, 09:26:58 pm
(http://img11.hostingpics.net/thumbs/mini_50411526ss.png) (http://www.hostingpics.net/viewer.php?id=50411526ss.png)

the problem is I see the edge of each part, so I think the normals must be calculated on the whole model not in each part (part == one object3D)
Title: Re: shaders and animations
Post by: EgonOlsen on March 06, 2012, 09:48:58 pm
And it's not an option to merge these parts into one Object3D?
Title: Re: shaders and animations
Post by: elhoce on March 06, 2012, 09:53:20 pm
Yes I can, How can I merge them in jpct ?
Title: Re: shaders and animations
Post by: EgonOlsen on March 06, 2012, 10:06:05 pm
By either using this

)]http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#mergeAll(com.threed.jpct.Object3D[]) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#mergeAll(com.threed.jpct.Object3D[)

or this

http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#mergeObjects(com.threed.jpct.Object3D, com.threed.jpct.Object3D) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#mergeObjects(com.threed.jpct.Object3D, com.threed.jpct.Object3D))

Edit: Maybe the first link doesn't work as it should...the bloody forum software can't handle brackets inside others.