Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - mallikpavan

#1
Support / Re: Few textures were applied and few not.
March 24, 2015, 12:42:50 PM
Hi EgonOlsen

       Finally i am able to set the textures to my model by removing below code.

        world.setAmbientLight(20, 20, 20);
        sun.setIntensity(250, 250, 250);

           
             Thank you so much for you support and response.   :) :) :) :) :) :) :) :) :) :)
#2
Support / Re: Few textures were applied and few not.
March 24, 2015, 11:52:36 AM
Hi EgonOlsen

             thanks alot for your patience and quick response. I didn't increase any ambient colors in my code. i am just fallowing the same code which i attached to our previous conversation (i.e March 18, 2015, 08:13:19 pm). If you don't mine would you please share me the source code what you have tried?
#3
Support / Re: Few textures were applied and few not.
March 24, 2015, 07:39:01 AM
Hi EgonOlsen

     I attached the screen shot of my model. in the image, black area should be green color gross but it is showing as black color.
#4
Support / Re: Few textures were applied and few not.
March 22, 2015, 05:40:20 PM
Hi EgonOlsen

        Please find the attached log.zip file.
#5
Support / Re: Few textures were applied and few not.
March 20, 2015, 07:42:21 PM
Hi EgonOlsen

Thanks for the reply. I removed cube.calcTextureWrapSpherical(); But it's not working for me. would you please provide me any sample source code which contains .3ds file displaying with multiple textures?

I tried to display the below .3ds model.

http://www.shareaec.com/v/22436/browse/5/3D-Model/Stone-Front-Home


Only few of the textures are applying to this model few were not like gross & top.

Thanks in advance.
#6
Support / Few textures were applied and few not.
March 18, 2015, 08:13:19 PM
Hi

       I tried to load a .3ds file into android by using our jpct-ae. i read the texture names from the file by using

String[] names_textures=Loader.readTextureNames3DS(mActivity.getResources().openRawResource(R.raw.house));

the above code returned me the list of texture files. i gave the same names while loading texture files but few of the textures only applied to the model object, rest of the textures were not. would you please tell me the reason why? Below is the my code.



package com.qualcomm.QCARSamples.ImageTargets;

import java.io.InputStream;

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

import android.opengl.GLSurfaceView;
import android.util.DisplayMetrics;

import com.qualcomm.QCAR.QCAR;
import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Light;
import com.threed.jpct.Loader;
import com.threed.jpct.Matrix;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.util.BitmapHelper;
import com.threed.jpct.util.MemoryHelper;

/** The renderer class for the ImageTargets sample. */
public class ImageTargetsRenderer implements GLSurfaceView.Renderer {
public boolean mIsActive = false;

/** Reference to main activity **/
public ImageTargets mActivity;

private FrameBuffer fb;

private World world;

private float[] modelViewMat;

private Light sun;

private Object3D cube;
private Camera cam;

private float fov;

private float fovy;

/** Native function for initializing the renderer. */
public native void initRendering();

/** Native function to update the renderer. */
public native void updateRendering(int width, int height);

public ImageTargetsRenderer(ImageTargets activity) {
this.mActivity = activity;

world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

TextureManager.getInstance().addTexture(
"Siding16.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.siding16))));
TextureManager.getInstance().addTexture(
"LTCHER~3.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.ltcher3))));
TextureManager.getInstance().addTexture(
"LTHICK~4.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.lthick4))));
TextureManager.getInstance().addTexture(
"LAKEER~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.lakeer1))));
TextureManager.getInstance().addTexture(
"CHAIRR~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.chairr1))));
TextureManager.getInstance().addTexture(
"FAWNHA~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.fawnha1))));
TextureManager.getInstance().addTexture(
"AFRICA~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.africa1))));
TextureManager.getInstance().addTexture(
"518lmpw.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.c518lmpw))));
TextureManager.getInstance().addTexture(
"612cdw.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.c612cdw))));
TextureManager.getInstance().addTexture(
"MDCHER~3.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.mdcher3))));
TextureManager.getInstance().addTexture(
"STUCCO03.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.stucco03))));
TextureManager.getInstance().addTexture(
"Grass01.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.grass01))));
TextureManager.getInstance().addTexture(
"NAE62C~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.nae62c1))));
TextureManager.getInstance().addTexture(
"WOODFL~3.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.woodfl3))));
TextureManager.getInstance().addTexture(
"SH6ABB~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.sh6abb1))));
TextureManager.getInstance().addTexture(
"Plywood.jpg",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.plywood))));
TextureManager.getInstance().addTexture(
"VENTWH~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.ventwh1))));
TextureManager.getInstance().addTexture(
"MDMAPC~1.JPG",
new Texture(BitmapHelper.convert(mActivity.getResources()
.getDrawable(R.drawable.mdmapc1))));


cube = load3DSModel(
mActivity.getResources().openRawResource(R.raw.house), 0.01f);


cube.calcTextureWrapSpherical();

cube.strip();
cube.build();

world.addObject(cube);

cam = world.getCamera();

SimpleVector sv = new SimpleVector();
sv.set(cube.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;

sun.setPosition(sv);

MemoryHelper.compact();
}

/** Called when the surface is created or recreated. */
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
DebugLog.LOGD("GLRenderer::onSurfaceCreated");

// Call native function to initialize rendering:
initRendering();

// Call Vuforia function to (re)initialize rendering after first use
// or after OpenGL ES context was lost (e.g. after onPause/onResume):
QCAR.onSurfaceCreated();
}

/** Called when the surface changed size. */
public void onSurfaceChanged(GL10 gl, int width, int height) {
DebugLog.LOGD(String.format("GLRenderer::onSurfaceChanged (%d, %d)",
width, height));

if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(width, height);
Config.viewportOffsetAffectsRenderTarget = true;

// Call native function to update rendering when render surface
// parameters have changed:
updateRendering(width, height);

// Call Vuforia function to handle render surface size changes:
QCAR.onSurfaceChanged(width, height);
}

/** The native render function. */
public native void renderFrame();

/** Called to draw the current frame. */
public void onDrawFrame(GL10 gl) {
if (!mIsActive)
return;

// Update render view (projection matrix and viewport) if needed:
mActivity.updateRenderView();

// Call our native function to render content
renderFrame();

updateCamera();

world.renderScene(fb);
world.draw(fb);
fb.display();
}

public void updateModelviewMatrix(float mat[]) {
modelViewMat = mat;
}

public void updateCamera() {
if (modelViewMat != null) {
float[] m = modelViewMat;

final SimpleVector camUp;
if (mActivity.isPortrait()) {
camUp = new SimpleVector(-m[0], -m[1], -m[2]);
} else {
camUp = new SimpleVector(-m[4], -m[5], -m[6]);
}

final SimpleVector camDirection = new SimpleVector(m[8], m[9],
m[10]);
final SimpleVector camPosition = new SimpleVector(m[12], m[13],
m[14]);

cam.setOrientation(camDirection, camUp);
cam.setPosition(camPosition);

cam.setFOV(fov);
cam.setYFOV(fovy);
}
}

public void setVideoSize(int videoWidth, int videoHeight) {

DisplayMetrics displaymetrics = new DisplayMetrics();
mActivity.getWindowManager().getDefaultDisplay()
.getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;

int widestVideo = videoWidth > videoHeight ? videoWidth : videoHeight;
int widestScreen = width > height ? width : height;

float diff = (widestVideo - widestScreen) / 2;

Config.viewportOffsetY = diff / widestScreen;
}

public void setFov(float fov) {
this.fov = fov;
}

public void setFovy(float fovy) {
this.fovy = fovy;
}

private Object3D load3DSModel(InputStream is, float scale) {
Object3D[] model = Loader.load3DS(is, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float) (+.5 * Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
return o3d;
}
}

#7
Thanks a lot for quick reply.

My exact problem is, I downloaded one .3ds model object from net. i found multiple textures in that folder i.e 003.jpg,009.jpg,119.jpg... .

My question is what are the names i need to give while loading textures.

ex:  TextureManager.getInstance().addTexture(
            "003.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c003)),
                        128, 128)));

         is the above is correct or is there any chance to know the given texture names of .3ds file? Please help me. i have been stuck from past 1 week.
#8
Hi

   I tried to load a house.3ds file using JPCT-AE. i have multiple texture files to add. Below is the way how i am attaching the textures.


house= load3DSModel(
            mActivity.getResources().openRawResource(R.raw.cottagen131214),
            0.5f);

      TextureManager.getInstance().addTexture(
            "003.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c003)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "009.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c009)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "119.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.c119)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "221 roof gray.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.c221roofgray)),
                  128, 128)));

      TextureManager.getInstance().addTexture(
            "Doski113.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.doski113)), 128,
                  128)));

      TextureManager.getInstance().addTexture(
            "old3.jpg",
            new Texture(
                  BitmapHelper.rescale(BitmapHelper.convert(mActivity
                        .getResources().getDrawable(R.drawable.old3)),
                        128, 128)));

      TextureManager.getInstance().addTexture(
            "OLDMETAL.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity
                  .getResources().getDrawable(R.drawable.oldmetal)), 128,
                  128)));

      TextureManager.getInstance().addTexture(
            "stone_paving_01.jpg",
            new Texture(BitmapHelper.rescale(BitmapHelper
                  .convert(mActivity.getResources().getDrawable(
                        R.drawable.stone_paving_01)), 128, 128)));

It seems not working. Please help me to apply the multiple textures to my .3ds model. thanks in advance.