styuR

Member
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

100 Neutral

About styuR

  • Rank
    Newbie
  1. Android Image Loading

    Nope, no reason, I'm pretty inexperienced with this haha.
  2. Android Image Loading

    I'm having issues with the way that I'm loading my images in Android, this is the way I'm doing it just now. [CODE]try{ AssetManager assetManager = context.getAssets(); inputStream = assetManager.open("blackcat.png"); cat = BitmapFactory.decodeStream(inputStream); inputStream.close(); inputStream = assetManager.open("Jellyfish1.png"); jellyfish = BitmapFactory.decodeStream(inputStream); inputStream.close(); inputStream = assetManager.open("/Dog.png"); bigdog = BitmapFactory.decodeStream(inputStream); inputStream.close(); inputStream = assetManager.open("exit.png"); exitTile = BitmapFactory.decodeStream(inputStream); inputStream.close(); inputStream = assetManager.open("kitchen.png"); background = BitmapFactory.decodeStream(inputStream); inputStream.close(); inputStream = assetManager.open("endscreen.png"); gameover = BitmapFactory.decodeStream(inputStream); inputStream.close(); }catch(IOException ex){}[/CODE] Any help would be massively appreciated as I'm pretty stuck for what to do now.
  3. I need a little help with C++, it's probably just something stupid that I'm doing. Basically, I'm trying to find the max/min value of something, call it in another function and use it. That's all fine if I'm doing it for just one thing but if I'm calling it more than once for more than one thing then it messes up. In this case, I'm using it to find the max/min values of the vertices of a model so that I can make a bounding box for collision detection but they just end up being the same, even when I reset the max/min to zero before calling it again. It works fine if I draw a box inside the class that the max/min is found but i can't use that for collision detection since it's a model class that I have and I'm calling the specific models from my main class to get the vertices co-ordinates so that I can check for collision detection. MD2Model.cpp [code] void MD2Model::RenderFrameItp() { *removed code* /* Draw each triangle */ for (i = 0; i < mdl.header.num_tris; ++i) { /* Draw each vertex */ for (j = 0; j < 3; ++j) { pframe1 = &mdl.frames[currentFrame]; pframe2 = &mdl.frames[nextFrame]; pvert1 = &pframe1->verts[mdl.triangles[i].vertex[j]]; pvert2 = &pframe2->verts[mdl.triangles[i].vertex[j]]; /* Compute texture coordinates */ s = (GLfloat)mdl.texcoords[mdl.triangles[i].st[j]].s / mdl.header.skinwidth; t = (GLfloat)mdl.texcoords[mdl.triangles[i].st[j]].t / mdl.header.skinheight; /* Pass texture coordinates to batch */ triangles->MultiTexCoord2f(0,s,t); /* Interpolate normals */ n_curr = anorms_table[pvert1->normalIndex]; n_next = anorms_table[pvert2->normalIndex]; norm[0] = n_curr[0] + interp * (n_next[0] - n_curr[0]); norm[1] = n_curr[1] + interp * (n_next[1] - n_curr[1]); norm[2] = n_curr[2] + interp * (n_next[2] - n_curr[2]); triangles->Normal3fv(norm); /* Interpolate vertices */ // Doing these scaling operations *every* refresh is *very* wasteful // Should do all the scaling calculations once only, when loading the file v_curr[0] = pframe1->scale[0] * pvert1->v[0] + pframe1->translate[0]; v_curr[1] = pframe1->scale[1] * pvert1->v[1] + pframe1->translate[1]; v_curr[2] = pframe1->scale[2] * pvert1->v[2] + pframe1->translate[2]; v_next[0] = pframe2->scale[0] * pvert2->v[0] + pframe2->translate[0]; v_next[1] = pframe2->scale[1] * pvert2->v[1] + pframe2->translate[1]; v_next[2] = pframe2->scale[2] * pvert2->v[2] + pframe2->translate[2]; v[0] = v_curr[0] + interp * (v_next[0] - v_curr[0]); v[1] = v_curr[1] + interp * (v_next[1] - v_curr[1]); v[2] = v_curr[2] + interp * (v_next[2] - v_curr[2]); [b]if(v[0]>vertMaxX) {vertMaxX=v[0];} if(v[0]<vertMinX) {vertMinX=v[0];} if(v[1]>vertMaxY) {vertMaxY=v[1];} if(v[1]<vertMinY) {vertMinY=v[1];} if(v[2]>vertMaxZ) {vertMaxZ=v[2];} if(v[2]<vertMinZ) {vertMinZ=v[2];}[/b] triangles->Vertex3fv(v); } } triangles->End(); triangles->Draw(); } [/code] Returning of vertex co-ordinates [code]float MD2Model::getModelMinX() { return vertMinX; } etc until vertMaxZ [/code] Test function in game.cpp to get co-ordinates [code] std::cout << "Pmin x: " << playerModel.getModelMinX() << std::endl; std::cout << "Pmax x: " << playerModel.getModelMaxX() << std::endl; std::cout << "Pmin y: " << playerModel.getModelMinY() << std::endl; std::cout << "Pmax y: " << playerModel.getModelMaxY() << std::endl; std::cout << "Pmin z: " << playerModel.getModelMinZ() << std::endl; std::cout << "Pmax z: " << playerModel.getModelMaxZ() << std::endl << std::endl; std::cout << "Bmin x: " << buildingModel.getModelMinX() << std::endl; std::cout << "Bmax x: " << buildingModel.getModelMaxX() << std::endl; std::cout << "Bmin y: " << buildingModel.getModelMinY() << std::endl; std::cout << "Bmax y: " << buildingModel.getModelMaxY() << std::endl; std::cout << "Bmin z: " << buildingModel.getModelMinZ() << std::endl; std::cout << "Bmax z: " << buildingModel.getModelMaxZ() << std::endl << std::endl << std::endl;[/code]