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.


Topics - dl.zerocool

Pages: [1]
1
Support / Collision between 2 models.
« on: May 30, 2010, 04:32:12 pm »
Hi,

I'm using :
Code: [Select]
cId = checkForCollision(dir, step);where step =2f and dir is a direction SimpleVector from a projectile (he moves along this dir)

My problem is :

I've a projectile :  That I want to move except if there's a collision and in this case I want to do something else.
So basicaly I use checkForCollision each time before moving.
Code: [Select]
if(cId==NO_OJBECT)then I move
else
do something else.

My projectiles are configured like this when I create a project :
Code: [Select]
       addCollisionListener(this);
setCollisionMode(COLLISION_CHECK_SELF);
setCollisionOptimization(COLLISION_DETECTION_OPTIMIZED);

Now the objects I want to collide with have this settings
Code: [Select]
addCollisionListener(this);
setCollisionMode(COLLISION_CHECK_OTHERS);
setCollisionOptimization(COLLISION_DETECTION_OPTIMIZED);

The problem is that even I'm seeing that the 2 objects are colliding cID still equal to NO_OBJECT
so no collision detected.


Am I doing something wrong ?



2
Support / Moving an Object3D to another smoothly.
« on: May 26, 2010, 07:55:02 pm »
Hello.

I would like to know if someone know how to move an Object3D to another smoothly,
without using too much resources ?

Thank you in advance.

3
Support / [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: May 11, 2010, 08:06:35 pm »
All the code provide here is free to use and I'm not responsible for what you use it for.

I received a question that I found very interesting to share with everybody.

There is very few information about this subject on android and how to setup a correct working layout.

So in this topic, I'll answer the simple question : How to use Android Camera and JPCT-AE as a render that overlays the camera.
(Augmented reality concept)


== ALL THE SOURCES PROVIDED IN CODE QUOTES ARE NOT COMPLETE ! ==
You have to code your own engines around it to get it fully functional.

First we need to set up an XML layout.
Our minimum requirement is a glSurfaceView that's where we will draw 3D(JPCT engine),
and a SurfaceView to draw the camera preview.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<android.opengl.GLSurfaceView android:id="@+id/glsurfaceview"
android:layout_width="fill_parent" android:layout_height="fill_parent" />

<SurfaceView android:id="@+id/surface_camera"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_centerInParent="true" android:keepScreenOn="true" />
</FrameLayout>


This is to Initialize the window and the glSurfaceView.
Code: [Select]
       // It talks from itself, please refer to android developer documentation.
getWindow().setFormat(PixelFormat.TRANSLUCENT);

        // Fullscreen is not necessary... it's up to you.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.THE_XML_LAYOUT_CREATED_BEFORE);
        // attach our glSurfaceView to the one in the XML file.
glSurfaceView = (GLSurfaceView) findViewById(R.id.glsurfaceview);


Now let's create the camera and the engine.
This is an example of my own code, so perhaps it won't fill exactly your needs,
but you can be inspired by this one.


The following code is pretty easy to understand,
I create a new camera and I give a render to my glSurfaceView
and of course set the Translucent window  (8888) pixel format and depth buffer to it.
(Without that your glSurfaceView will not support alpha channel and you will not see the camera layer.)

So basically :
1) Create the camera view.
2) Set up the glSurfaceView.
3) Set a Render to glSurfaceView.
4) Set the correct pixelformat to the glSurfaceView holder.

Code: [Select]
try{
cameraView = new CameraView(this.getApplicationContext(),
(SurfaceView) findViewById(R.id.surface_camera), imageCaptureCallback);
}
catch(Exception e){
   e.printStackTrace();
}
// Translucent window 8888 pixel format and depth buffer
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

        // GLEngine is a class I design to interact with JPCT and with all the basic function needed,
        // create a world, render it, OnDrawFrame event etc.
        glEngine = new GLEngine(getResources());
glSurfaceView.setRenderer(glEngine);

game = new Game(glEngine, (ImageView) findViewById(R.id.animation_screen), getResources(), this
.getBaseContext());

// Use a surface format with an Alpha channel:
glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

// Start game
game.start();

Here is my CameraView class :
Code: [Select]
package com.dlcideas.ARescue.Camera;

import java.io.IOException;

import com.threed.jpct.Logger;

import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class CameraView extends SurfaceView implements SurfaceHolder.Callback {
    /**
     * Create the cameraView and
     *
     * @param context
     * @param surfaceView
     */
    public CameraView(Context context, SurfaceView surfaceView,
   ImageCaptureCallback imageCaptureCallback) {
super(context);

// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
previewHolder = surfaceView.getHolder();
previewHolder.addCallback(this);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//previewHolder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);


// Hold the reference of the caputreCallback (null yet, will be changed
// on SurfaceChanged).
this.imageCaptureCallback = imageCaptureCallback;
    }

    /**
     * Initialize the hardware camera. holder The holder
     */
    public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try {
   camera.setPreviewDisplay(holder);
} catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
}
    }

    /**
     *
     */
    public void surfaceDestroyed(SurfaceHolder holder) {
this.onStop();
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int width,
   int height) {
if (previewRunning)
   camera.stopPreview();

Camera.Parameters p = camera.getParameters();
p.setPreviewSize(width, height);
// camera.setParameters(p);

try {
   camera.setPreviewDisplay(holder);
} catch (IOException e) {
   e.printStackTrace();
}
previewRunning = true;
Logger.log("camera callback huhihihihih", Logger.MESSAGE);
camera.startPreview();
imageCaptureCallback = new ImageCaptureCallback(camera, width, height);
//camera.startPreview();


    }

    public void onStop() {
// Surface will be destroyed when we return, so stop the preview.
// Because the CameraDevice object is not a shared resource, it's very
// important to release it when the activity is paused.
imageCaptureCallback.stopImageProcessing();
camera.setPreviewCallback(null);
camera.stopPreview();
previewRunning = false;
camera.release();
    }

    public void onResume() {
camera = Camera.open();
camera.setPreviewCallback(imageCaptureCallback);
previewRunning = true;
    }

    private Camera camera;
    private SurfaceHolder previewHolder;
    private boolean previewRunning;
    private ImageCaptureCallback imageCaptureCallback;

}

4
Support / Activity switching
« on: April 30, 2010, 12:08:09 am »
Hi,

Well I'm confronting a problem but I'm unsure from where it comes.
I pass few hours checking around my code and found nothing yet.

So I wanted to know if you are encountering the same problem as me.

If you run engine, add objects etc.. then push the HOME button,
then with multi task selection return back to game are you models and textures still there ?

When I do this, I loose all my models and textures.

Thank you in advance for help, if don't come from JPCT I'll work harder to find what's wrong on my side.

Best regards.

5
Support / 3D World, models and animation format.
« on: March 31, 2010, 07:40:08 pm »
Hello,

I have few questions so I started a new topic, perhaps it will help someone else too.

So here are my questions:
Are at the moment all the JPCT features implemented in JPCT-AE (of course features that can run on android) like models, animation, textures etc. support?
What are the recommended/supported format to load a world ? (like in quake3 maps are based on bsp format, but not characters).
" " to load non animated objects ?
" " to load animated objects ?
Are keyframes already implemented or does we have to use things like Bones " http://www.aptalkarga.com/bones/#overview "
What is the correct way to add textures to a model, what are the main advices or tips that we have to follow (texture names?) etc.?
Does JPCT-AE allow 2D drawing, like textures, text etc. ? (To do a personal menu for example).
Does JPCT-AE already include a 3D model selection based on 2D (x,y) point ?

I think I asked them all.
Thanks in advance.

Best regards.

Pages: [1]