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 - MSL

#1
Support / Re: Augmented Reality for Desktop
February 09, 2015, 02:04:42 PM
Hi,
Thanks again. One of the best part of JPCT (apart from the Engine itself  :) ) is the Reply to the Forum posts. Truly amazing.

I can get the camera image or feed that won't be a much problem.

I think this is silly but can you give any heads up regarding "render or copy it into the GL window"?. Can you point to any example?

Update:

Were you referring to this?
Background Images
http://www.jpct.net/forum2/index.php?topic=110.0

Thanks in advance
MSL
#2
Support / Augmented Reality for Desktop
February 07, 2015, 08:30:18 AM
Hi,

Can anyone point me to best AR solution(preferably free) which can be used with JPCT? (for desktop)

or Can anyone point me how can I replace the JPCT canvas with Live camera feed so that when I render 3D objects the objects will be rendered inside Camera feed?

Thanks in advance
MSL
#3
Support / Dynamic Light placing and control
January 17, 2014, 09:19:04 AM
Hi,
My augmented reality app is supposed to load different architectural models. One of the feature in my wish list is to place lights and user should be able to control the lights(on touch toggle on and off).
The tricky part is different models will have lights in different places. Now, how can I add lights in a particular place at the run time and bind them to onTouch events.

For simplicity, lets say I have 2 model; bed room and living room. When I load bed room model bed lamp and other lights should be placed at respective places. Similarly, when I load living room it should place lights in respective area.
#4
Support / Re: Jpct-AE Vuforia integration Portrait mode
November 28, 2013, 10:49:42 AM
HI..
yes.. I did receive it .. Thanks
I will update the article tonight if possible or tomorrow.
#5
Support / getting Object Size and Units
November 26, 2013, 02:55:56 PM
Hi,

When I integrated with Vuforia, the CUBE was usually lying behind the marker. Hence, it had a odd rotating feeling when we moved camera around it. This was solved by translating CUBE by its SIZE in the z-axis. If I need to display any model, now I have to do the same adjustment i.e translate the model by its SIZE in the z-axis. (Since my model will lay on the marker I think I need height of the model to use in translation)
How can I achieve this?
What method I need to use which will get me the SIZE(or height) of the model?

Above questions resulted me in getting few basic questions. They may be trivial or may be answered. I checked few posts here on this topic I was unable to get satisfactory answers. Here are the questions:

1- What does model units mean when we load them in jpct(i.e any relation between units used while creating the model in a 3D software and jpct)?
2- What are the steps that need to be taken care before loading models in jpct which will ensure "proper" sizing(and probably orientation) during rendering? (in 3D software and in jpct)
3- Is there any way of getting the size (in some units) of the model at run time (apart from getScale)?
4- What is the basis for scaling?
5- One question regarding the object position after scaling which I didnt know how to ask, so I have attached an image. If you refer the image, if the "Dist" need to be constant then on every scaling operation, I have to calculate the distance and translate the object with that distance. Is there any easy of doing this?

If anyone can answer taking consideration of model with only 1 object and model with multiple objects will be great.
For modelling I use 3DS Max.

Thanks


[attachment deleted by admin]
#6
Support / Re: Jpct-AE Vuforia integration Portrait mode
November 26, 2013, 01:53:14 PM
ya sure... we can add it to wiki so that it will cover Portrait mode changes also. However, I have the solution using the 2nd method (i.e when we obtain the camera position, direction) not for 1st method(i.e., rotating the pose matrix). So I am not sure if some one is using 1st method then how can portrait mode be handled.
#7
Support / Re: Jpct-AE Vuforia integration Portrait mode
November 23, 2013, 01:35:37 PM
Hi all,

Finally I was able to solve this issue... I got the answer in this post in Vuforia forum
https://developer.vuforia.com/forum/android/integrating-jpct-ae-vuforia

I am posting the code here so that anyone facing the same issue can use this:

JNI code:

-------------------------------------------------------------------------------------------------------------------------------
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *env, jobject obj)
{
// Get the class out of Activity
jclass activityClass = env->GetObjectClass(obj);

// Get the method from above class
jmethodID cameraPositionMethod = env->GetMethodID(activityClass, "cameraPositionMatrix", "([F)V");

    // Clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();
   
    // Explicitly render the Video Background
    QCAR::Renderer::getInstance().drawVideoBackground();
       
    jfloatArray cameraViewArray = env->NewFloatArray(16);

    // Did we find any trackables this frame?
    for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
        // Get the trackable:
        const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
        const QCAR::Trackable& trackable = result->getTrackable();
        QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());

        QCAR::Matrix44F inverseMV = SampleMath::Matrix44FInverse(modelViewMatrix);
        QCAR::Matrix44F invTranspMV = SampleMath::Matrix44FTranspose(inverseMV);

            env->SetFloatArrayRegion (cameraViewArray, 0, 16, invTranspMV.data);
            env->CallVoidMethod (obj, cameraPositionMethod, cameraViewArray);
}
-------------------------------------------------------------------------------------------------------------------------------

Java Code:
public void cameraPositionMatrix(float matrix[])
    {
    mCameraViewMat = matrix;
   
    if(mCameraViewMat!=null){
   
            Configuration config = mActivity.getResources().getConfiguration();

            switch (config.orientation)
            {
            case Configuration.ORIENTATION_PORTRAIT:
        mCam_Pos_x = mCameraViewMat[12];
        mCam_Pos_y = mCameraViewMat[13];
        mCam_Pos_z = mCameraViewMat[14];
       
        mCam_Dir_x = mCameraViewMat[8];
        mCam_Dir_y = mCameraViewMat[9];
        mCam_Dir_z = mCameraViewMat[10];
       
        mCam_Up_x = -mCameraViewMat[0];
        mCam_Up_y = -mCameraViewMat[1];
        mCam_Up_z = -mCameraViewMat[2];

                break;

            case Configuration.ORIENTATION_LANDSCAPE:
    mCam_Pos_x = mCameraViewMat[12];
    mCam_Pos_y = mCameraViewMat[13];
    mCam_Pos_z = mCameraViewMat[14];
   
    mCam_Dir_x = mCameraViewMat[8];
    mCam_Dir_y = mCameraViewMat[9];
    mCam_Dir_z = mCameraViewMat[10];
   
    mCam_Up_x = -mCameraViewMat[4];
    mCam_Up_y = -mCameraViewMat[5];
    mCam_Up_z = -mCameraViewMat[6];

                break;
            case Configuration.ORIENTATION_UNDEFINED:
            default:
                break;
            }

    mCameraDirection.set(mCam_Dir_x, mCam_Dir_y, mCam_Dir_z);
    mCameraUp.set(mCam_Up_x, mCam_Up_y, mCam_Up_z);
    }
    }

    public void updateCamera()
    {
    if(mCameraViewMat!=null){
mCam.setPosition(mCam_Pos_x, mCam_Pos_y, mCam_Pos_z);
mCam.setOrientation(mCameraDirection, mCameraUp);
    }
    mCam.setFOV(mFov);
    mCam.setYFOV(mFovY);
    }

    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();
        mWorld.renderScene(mfb);
        mWorld.draw(mfb);
        mfb.display();
    }
-------------------------------------------------------------------------------------------------------------------------------


May be in the coming week I will try to make a Android project and will put it in gitHub.
Thanks everyone :)
#8
Support / Re: Jpct-AE Vuforia integration Portrait mode
November 22, 2013, 08:45:28 AM
Hi.. Thanks for your reply.. Yes..I did try rotating the modelViewMatrix by 90 along Z-axis.
if (isActivityInPortraitMode){
        SampleUtils::rotatePoseMatrix (90.0f, 0, 0, 1.0f, &modelViewMatrix.data[0]);
        }
        SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0, 0,
                       &modelViewMatrix.data[0]);
Theoritically, this should work but it seems, this solution is not working. I am unable to determine where its going wrong.

This is code from Rajawali3D integration with Vuforia.. This is working properly in both Landscape and portrait mode:
      if (isActivityInPortraitMode)
         Utils::rotatePoseMatrix(90.0f, 0, 1.0f, 0,
               &modelViewMatrix.data[0]);
      Utils::rotatePoseMatrix(-90.0f, 1.0f, 0, 0, &modelViewMatrix.data[0]);
There is different logic in Rajawali. I have attached cpp and java file of Rajawali in case you want more info:
Too sad 2 people on Vuforia forum asked me to move to Rajawali bcz of this problem :( .. but I want to use jpct. Once this problem is resolved I will make a complete project on Integration for everyone use

[attachment deleted by admin]
#9
Support / Jpct-AE Vuforia integration Portrait mode
November 21, 2013, 09:39:41 AM
HI..
I was able to integrate jpct and vuforia following the wiki article. Everything works fine in landscape mode. However, in portrait mode the model is not positioned properly(model not sticking to marker) also model moves when the camera is moved.
if camera moves UP, model moves RIGHT
if camera moves DOWN, model moves LEFT
if camera moves LEFT, model moves UP
if camera moves RIGHT, model moves DOWN

In many posts people talk about this problem but no one has provided proper solution for this or may be I am missing something.
Can anyone help me by pointing out the changes that is required to be done to the wiki article on Integration so that portrait mode can be handled?
#10
Support / Re: Can't deserialize object Error
November 15, 2013, 03:13:22 PM
Thanks again.. I will check that..

In mean time I got an old version of jpct (1.23) which i used to create a serialized file and it is working like a charm... thanks for your pointer ..  :)

I have one more query. I have evaluated Rajawali 3D engine also. Compared to it the loading time is blazing fast. (4 sec vs 30 sec). However, I noticed one thing. The file size of serialized object is very high. I will give a comparison below:
File Type: obj
File Size: 8.48 MB

Serialized file Size:
JPCT - 12.12 MB
JPCT (Zip) - 2.2 MB

Rajawali - 2.45 MB
Rajawali (Zip) - 1.8 MB

There is not much difference in the Zipped files(0.4 MB) but the difference in serialized formats is very high(~10 MB). Also I was of the assumption that Serialization will reduce the file size (compared to obj). Can you give me some pointers or details on the serialization?

In my case the models will be streamed from server. Typically the models will be of ~10 to 15 MB (obj). I am very much worried about the streaming time because of file size. Can you give any suggestion as to which will be the best way to handle such cases?

p.s: One more interesting thing I noticed was on reopening of the app(after closing the app), Rajawali again takes ~20 sec, but JPCT renders immediately  :o ... It would be very helpful if you an put some light on how JPCT is achieving this....

Thanking you once again ...
#11
Support / Re: Can't deserialize object Error
November 15, 2013, 01:05:47 PM
Thanks for your quick response.
I have downloaded both Desktop and Mobile version from the download page... http://www.jpct.net/download.html
I have even tried with the Beta version of JPCT-AE available here
http://jpct.de/download/beta/jpct_ae.jar

Regarding manually Zipping the file loading, I had tried that also. In that case also I got Unsupported version 6.

Can you guide me where can I download the right version if not from above links?
#12
Support / Can't deserialize object Error
November 15, 2013, 11:42:32 AM
Hi,

I am trying to load a serialized file but I am getting Can't deserialize object error.

Code used to load serialized object:
----------------------------------------------------------------------------------------------------------------------------
ZipInputStream zis = new ZipInputStream(mContext.getResources().openRawResource(R.raw.teapot));
try {
   zis.getNextEntry();
} catch (IOException e) {throw new RuntimeException(e);}
cube = Loader.loadSerializedObject(zis);
-----------------------------------------------------------------------------------------------------------------------------
Error:
11-15 15:56:08.478: E/Trace(11279): error opening trace file: No such file or directory (2)
11-15 15:56:08.828: E/AndroidRuntime(11279): FATAL EXCEPTION: GLThread 6828
11-15 15:56:08.828: E/AndroidRuntime(11279): java.lang.RuntimeException: [ 1384511168803 ] - ERROR: Can't deserialize object: length=256; regionStart=-1; regionLength=257
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.Logger.log(Logger.java:189)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:244)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.Loader.loadSerializedObject(Loader.java:93)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:204)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266)

-----------------------------------------------------------------------------------------------------------------------------

If I use following code to load:
cube = Loader.loadSerializedObject(mContext.getResources().openRawResource(R.raw.teapot));

Error:
11-15 15:53:34.603: E/Trace(11063): error opening trace file: No such file or directory (2)
11-15 15:53:34.945: E/AndroidRuntime(11063): FATAL EXCEPTION: GLThread 6816
11-15 15:53:34.945: E/AndroidRuntime(11063): java.lang.RuntimeException: [ 1384511014916 ] - ERROR: Can't deserialize object: [ 1384511014915 ] - ERROR: Unsupported version: 6
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.Logger.log(Logger.java:189)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:244)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.Loader.loadSerializedObject(Loader.java:93)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:204)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266)

----------------------------------------------------------------------------------------------------------------------------

Code used to serialize an object in Desktop JPCT (object is basic Teapot):
----------------------------------------------------------------------------------------------------------------------------
        box = loadModel("models/"+thingName+".obj","models/"+thingName+".mtl", 100);
        try {
            new DeSerializer().serialize(box, new FileOutputStream("models/teapot.ser"), true);
         } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }

   private Object3D loadModel(String filename, String filemtl, float scale) throws IOException {
         InputStream streamModel = getResources().getAssets().open(filename);
         InputStream streamMtl = getResources().getAssets().open(filemtl);

           Object3D[] model = Loader.loadOBJ(streamModel, stearmMtl, scale);
           Object3D o3d = new Object3D(0);
           Object3D temp = null;
           for (int i = 0; i < model.length; i++) {
               temp = model;
               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;
    }
--------------------------------------------------------------------------------------------------------------------

Any help would be appreciated.