Forums > Jitter

java, gridshape and textures

May 25, 2008 | 9:16 am

hi.
I’m trying to apply a single texture(a picture file) to each one of these planes created in jit.gl.gridshape. I’m having trouble figuring it out. from the jitter tutorials i can’t quite understand how to get the qtmovie into the jit.gl.texture object.
A suggestion into the right direction would be greatly appreciated.
best
adam

here’s my code so far.

var planes = 20; //number of particles

//jit.window creation
var mywindow = new JitterObject("jit.window","wallpaper");
mywindow.depthbuffer = 0;
mywindow.idlemouse = 0;

//matrix
var mymatrix = new JitterMatrix(4,"char",320,240);
//qtmovie
var myqtmovie = new JitterObject("jit.qt.movie", 320, 240);

//jit.gl.render creation
var myrender = new JitterObject("jit.gl.render","wallpaper");
//use a 2d projection
myrender.ortho = 2;
myrender.erase_color = [0,0,0,1];

//attempt 1 at addig a texture
var mytexture = new JitterObject("jit.gl.texture","wallpapaper");
mytexture.texture = "mymatrix";
mytexture.name = "flowers";

// create an array of [jit.gl.gridshape] objects randomly arrayed across the window
var myplane = new Array(planes);

//for statment to create the planes
for(var i=0;i

myplane[i] = new JitterObject("jit.gl.gridshape","wallpaper");
myplane[i].shape = "plane";
myplane[i].lighting_enable = 1;
myplane[i].smooth_shading = 1;
myplane[i].scale = [0.05,0.05,0.05];
myplane[i].color = [0.5,0.3,0.7,0.5];
myplane[i].position = [Math.random()*2.-1,Math.random()*2.-1];
myplane[i].blend_enable = 1;
myplane[i].texture = "picture";
}

//copied in
function read(filename) // read a movie
{
if(arguments.length==0) {
// no movie specified, so open a dialog
myqtmovie.read();
}
else { // read the movie specified
myqtmovie.read(filename);
}
// initialize feedback matrix to all maximum values
mymatrix.setall(255, 255, 255, 255);
}

// drive the renderer
function bang()
{

myqtmovie.matrixcalc(mymatrix, mymatrix);
//myqtmovie.matrixcalc(mytexture);

// rendering block…
myrender.erase(); // erase the drawing context
myrender.drawclients(); // draw the client objects
myrender.swap(); // swap in the new drawing
}


May 26, 2008 | 3:46 pm

Although i do know Java, I know next to nothing about Jitter and Java, but from glancing at your code this line is using a special kind of paper for its drawing context:

var mytexture = new JitterObject("jit.gl.texture","wallpapaper");

Dunno for certain, but could be it, right?


May 27, 2008 | 9:15 am

On Sun, May 25, 2008 at 10:16 AM, adam synnott wrote:

>
>
> //attempt 1 at addig a texture
> var mytexture = new JitterObject("jit.gl.texture","wallpapaper");
> mytexture.texture = "mymatrix";
> mytexture.name = "flowers";

Texture doesn’t have an attribute "texture", since that would mean you’re
texturing a texture :) To get your matrix data into the texture use
mytexture.matrixcalc() or something. I see you were attempting that before,
but you have to call in on the texture, with the video matrix as the
argument. I’m not sure if you can call it with jit.qt.movie as an argument
directly.

You matrix name is set to "flowers" ….

> myplane[i].texture = "picture";
>

while your plane is textured with "picture".

And of course, like Bas pointed out, the context name of your texture has a
typo.

Cheers,
Thijs


Viewing 3 posts - 1 through 3 (of 3 total)