Git Product home page Git Product logo

Comments (16)

MasDennis avatar MasDennis commented on July 20, 2024

Hi,
Could you elaborate on 'not being renderer properly'?
Are the textures stored alongside the models (in the same folder)?
Are the textures power of two textures?
Any errors in LogCat?

from rajawali.

anzarzulfiqar avatar anzarzulfiqar commented on July 20, 2024

Not being rendered properly means, Sometimes there is no texture loaded , and some of the times , it loaded only on half side of model.
Textures for MD2 Models are just bitmaps , so Bitmap images i will get from server and it need not to be stored on sdcard , where as in case of OBJ model , Material file will saved alongside the models , but again for Bitmap it will be same case.

Errors in Logcat is displayed:
Material was not found

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

Ah, so there is a third scenario. When you load images from the server, are you sure they've completely finished loading?

Could you copy & paste the stack trace (with line numbers, etc)?

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

hi here are the errors when i try to load model from sdcard and texture from drawable

05-25 14:53:24.715: W/System.err(3248): java.lang.NullPointerException: name
05-25 14:53:24.715: W/System.err(3248): at android.content.res.AssetManager.getResourceIdentifier(Native Method)
05-25 14:53:24.715: W/System.err(3248): at android.content.res.Resources.getIdentifier(Resources.java:1642)
05-25 14:53:24.715: W/System.err(3248): at rajawali.parser.MD2Parser.getMaterials(MD2Parser.java:122)
05-25 14:53:24.715: W/System.err(3248): at rajawali.parser.MD2Parser.parse(MD2Parser.java:79)
05-25 14:53:24.715: W/System.err(3248): at com.monyetmabuk.rajawali.tutorials.Md2Renderer.initScene(Md2Renderer.java:42)
05-25 14:53:24.715: W/System.err(3248): at rajawali.renderer.RajawaliRenderer.onSurfaceCreated(RajawaliRenderer.java:224)
05-25 14:53:24.715: W/System.err(3248): at com.monyetmabuk.rajawali.tutorials.Md2Renderer.onSurfaceCreated(Md2Renderer.java:58)
05-25 14:53:24.715: W/System.err(3248): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1373)
05-25 14:53:24.715: W/System.err(3248): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)
05-25 14:53:25.140: E/Rajawali(3248): [rajawali.animation.mesh.VertexAnimationObject3D] Material is null. Please add a material before adding a texture.
05-25 14:53:25.175: I/GLThread(3248): exiting tid=13
05-25 14:53:25.175: W/dalvikvm(3248): threadid=9: thread exiting with uncaught exception (group=0x4001e578)
05-25 14:53:25.175: E/AndroidRuntime(3248): FATAL EXCEPTION: GLThread 13
05-25 14:53:25.175: E/AndroidRuntime(3248): java.lang.RuntimeException: Material is null. Please add a material first.
05-25 14:53:25.175: E/AndroidRuntime(3248): at rajawali.BaseObject3D.addTexture(BaseObject3D.java:329)
05-25 14:53:25.175: E/AndroidRuntime(3248): at com.monyetmabuk.rajawali.tutorials.Md2Renderer.initScene(Md2Renderer.java:44)
05-25 14:53:25.175: E/AndroidRuntime(3248): at rajawali.renderer.RajawaliRenderer.onSurfaceCreated(RajawaliRenderer.java:224)
05-25 14:53:25.175: E/AndroidRuntime(3248): at com.monyetmabuk.rajawali.tutorials.Md2Renderer.onSurfaceCreated(Md2Renderer.java:58)
05-25 14:53:25.175: E/AndroidRuntime(3248): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1373)
05-25 14:53:25.175: E/AndroidRuntime(3248): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

Hi, the textures and the model both need to be in the same location. It's either sdcard or resources.

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

thanks for your reply,
even i don't apply any texture situation is seemed to be same..

i have another question that in obj with the help of mtl texture is applied but how implicitly md2 model apply texture?is there any way to rename textures so that md2 apply them?

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

could you send me the .obj file?
the md2 file is baked into the file, can't change that i'm afraid.
You can add a texture afterwards though.

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

plz give your mail id so that i can forward you the file

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

info at rozengain com

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

The parser crashed when there was not material defined in the md2 file. Now it reports a RajLog message but continues without throwing an exception.

So after parsing the file you still have to add a material or it won't render:

MD2Parser parser = new MD2Parser(mContext.getResources(), mTextureManager, R.raw.king);
parser.parse();
VertexAnimationObject3D o = (VertexAnimationObject3D)parser.getParsedAnimationObject();
o.addLight(mLight);
o.setScale(.05f);
DiffuseMaterial material = new DiffuseMaterial(true); // -- true because it is an animated object
material.setUseColor(true); // -- use a color, not a texture
o.setMaterial(material);
o.setColor(0xff00ff00);
o.play();

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

as you mentioned,i tried with these modifications but result is black screen,i am using the same md2 king model.

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

Did you try using different values for setScale(); it might be too small to see depending on the distance of the camera. You might also try removing this line completely :-)

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

sorry for replying late but i tried everything but still no model only black screen.

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

Could you send me your code please?
On Jun 1, 2012 2:40 PM, "MrYogi" <
[email protected]>
wrote:

sorry for replying late but i tried everything but still no model only
black screen.


Reply to this email directly or view it on GitHub:
#35 (comment)

from rajawali.

MrYogi avatar MrYogi commented on July 20, 2024

i am just editing your md2 renedrer class ,here is the code:

package com.monyetmabuk.rajawali.tutorials;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import rajawali.animation.mesh.VertexAnimationObject3D;
import rajawali.lights.DirectionalLight;
import rajawali.materials.DiffuseMaterial;
import rajawali.parser.MD2Parser;
import rajawali.renderer.RajawaliRenderer;
import android.content.Context;
import android.graphics.Color;

public class RajawaliMD2Renderer extends RajawaliRenderer {
private DirectionalLight mLight;
private VertexAnimationObject3D mOgre;

public RajawaliMD2Renderer(Context context) {
    super(context);
    setFrameRate(60);
}

public void playAnimation(String name) {
    if (name.equals("loop all")) {
        mOgre.play();
    } else {
        mOgre.play(name, false);
    }
}

protected void initScene() {
    mLight = new DirectionalLight(0, 0, 1);
    mLight.setPower(2);
    mCamera.setPosition(0, 0, -8);

    MD2Parser parser = new MD2Parser(mContext.getResources(), mTextureManager, R.raw.king);
    parser.parse();
    VertexAnimationObject3D mOgre = (VertexAnimationObject3D)parser.getParsedAnimationObject();
    mOgre.addLight(mLight);
    mOgre.setScale(.015f);
    DiffuseMaterial material = new DiffuseMaterial(true); // -- true because it is an animated object
    material.setUseColor(true); // -- use a color, not a texture
    mOgre.setMaterial(material);
    mOgre.setColor(Color.GREEN);
    addChild(mOgre);
    mOgre.play();
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    ((RajawaliExampleActivity) mContext).showLoader();
    super.onSurfaceCreated(gl, config);
    ((RajawaliExampleActivity) mContext).hideLoader();
}

}

from rajawali.

MasDennis avatar MasDennis commented on July 20, 2024

I removed the line

mOgre.setScale(.015f);

which made it work.

from rajawali.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.