Loading a jit.gl.texture programmatically

Apr 23, 2009 at 7:51am

Loading a jit.gl.texture programmatically

I have written a java external that draw some objects in a scene. I want to set a textures for the objects.
I can create a texture object like
texture = new JitterObject(“jit.gl.texture”);
but I don’t know how to load the texture file or how to use that texture on a object
can you help?

#43495
Apr 23, 2009 at 12:59pm

you might want to post in the jitter developer forum rather then the jitter user forum

#156046
Apr 26, 2009 at 5:44am

texture.read(filename) will read a file. object.texture = texture.name will attach a texture to an object. I don’t remember the exact syntax, but this is the gist of it.

wes

#156047
Apr 26, 2009 at 5:33pm

If I am not mistaken that is how you do it if you are programming using javascript.
I wanted to do it using Java external. Any idea how to do that?

#156048
Apr 27, 2009 at 5:51pm

I believe it’s nearly identical.
wes

#156049
Apr 30, 2009 at 6:40pm

I have written simple JavaScript program to load a textures and rotate the plane after looking at several examples in the forum
When I run it the program does work but I can see some white squares flickering all over the window and loaded texture looks different.
Any suggestions?

inlets = 1;
outlets = 1;

//jit window
var mywindow = new JitterObject(“jit.window”,”test”);
mywindow.depthbuffer = 1;
mywindow.doublebuffer = 1;
mywindow.size = [1000,800];
//mywindow.idlemouse = 0;
//mywindow.mode = “texture”
//mywindow.interp = 1;

//render
var myrender = new JitterObject(“jit.gl.render”,”test”);
myrender.ortho = 2;
myrender.camera =[0, -10, 20];
myrender.lookat= [0, 0, 0];
myrender.far_clip = 1000;
myrender.erase_color = [0,0,0,1];

var mywallpaper = new JitterObject(“jit.gl.texture”,”test”);
mywallpaper.name = “wallpaper”;
mywallpaper.read(“skin2.tif”);

var planepaper = new JitterObject(“jit.gl.gridshape”,”test”);
planepaper.shape = “plane”;
planepaper.lighting_enable = 1;
planepaper.smooth_shading = 1;
planepaper.color = [1,1,1,1];
planepaper.position = [0,0];
planepaper.blend_enable = 1;
planepaper.texture = “wallpaper”;

var small_amt = 1.1;
var ang =0;

function bang()
{

ang += small_amt ;
if (ang > 360)
ang -= 360;

planepaper.rotate = [ang, 0, 0, 1];

myrender.erase();
myrender.drawclients();
myrender.swap();

}

#156050
Apr 30, 2009 at 9:05pm

please provide a simple patch that loads your javascript file and illustrates the problem.

#156051
Apr 30, 2009 at 9:22pm

Please find the attached file
Somehow the flickering no longer appearing now. I have no idea how it happened only thing I did was close and restart max/msp program.

However the texture still looks somewhat bluish

#156052
Apr 30, 2009 at 9:23pm

{
“boxes” : [ {
"box" : {
"maxclass" : "newobj",
"text" : "js mytest.js",
"outlettype" : [ "" ],
“fontsize” : 12.0,
“patching_rect” : [ 52.0, 133.0, 68.0, 22.0 ],
“numinlets” : 1,
“fontname” : “Arial”,
“numoutlets” : 1,
“id” : “obj-1″
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “t b erase”,
“outlettype” : [ "bang", "erase" ],
“fontsize” : 10.024474,
“patching_rect” : [ 52.0, 89.0, 56.0, 20.0 ],
“numinlets” : 1,
“fontname” : “Arial”,
“numoutlets” : 2,
“id” : “obj-8″
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “qmetro 40″,
“outlettype” : [ "bang" ],
“fontsize” : 10.024474,
“patching_rect” : [ 52.0, 52.0, 63.0, 20.0 ],
“numinlets” : 2,
“fontname” : “Arial”,
“numoutlets” : 1,
“id” : “obj-34″
}

}
, {
“box” : {
“maxclass” : “toggle”,
“outlettype” : [ "int" ],
“patching_rect” : [ 52.0, 25.0, 20.0, 20.0 ],
“numinlets” : 1,
“numoutlets” : 1,
“id” : “obj-35″
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-34", 0 ],
“destination” : [ "obj-8", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-35", 0 ],
“destination” : [ "obj-34", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-8", 0 ],
“destination” : [ "obj-1", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}

#156053
Apr 30, 2009 at 9:35pm

I have taken a screenshot of the window. The bottom image is the actual image and the top one is how the max engendered it. It is quite bluish …

#156054
Apr 30, 2009 at 9:38pm

your patch works as expected over here. if the color looks off, try lighting_enable 0.

also, please post patches using the Edit – Copy compressed option.

#156055
Apr 30, 2009 at 9:59pm

When I change this line I noticed that only some brightness changes
planepaper.lighting_enable = 0;
didn’t fixed the problem …
when I changed the following line I noticed big changes in the images appearance. Still the problem is there
planepaper.color = [1,1,0,1];
then I set the following line to change the lighting of the renderer still no change
myrender.lighting_enable = 0;
is there any other settings I should try?

#156056
Apr 30, 2009 at 10:26pm

not sure what the problem is, but it looks like the color planes are re-mapped. the image in your screenshot is not the same as the image you posted in your zip file.

can you post the image from the screenshot as well as relevant system specs?

#156057
Apr 30, 2009 at 10:41pm

Yes I took the screen shot with a different image. Following is a screen shot of the image in the zip file.
As you can see it is somewhat blue colored.
I am running
windows vista ultimate
Intel core 2 quad cpu/ 4gb ram
nvidia geforce gtx 260

#156058
Apr 30, 2009 at 11:32pm

maybe try with a jpg or png?

#156059
May 1, 2009 at 4:37am

I tried jpg and it looks the same.
Do you have a sample code that does something like this so I can have look to see what I did wrong?

#156060

You must be logged in to reply to this topic.