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

Topics - ggp

#1
Support / LensFlare hidding behind object
February 26, 2014, 12:44:28 PM
The LensFlare hidding behind object
worked before, not now
why?

used jpct-ae 1.28


                        LensF=new LensFlare(sun.getPosition(), "burst", "halo1", "halo2", "halo3");
LensF.setHiding(true);
LensF.setMaximumDistance(-1f); // i have also tried that in case of distance pb ...
LensF.setTransparency(2);
LensF.setGlobalScale(1.0f);
#2
Support / layout View.INVISIBLE
February 19, 2014, 04:10:32 PM
No hide joystick and label layout when show gui :-\

and View v2 = this.findViewById(R.id.mylayout);
no work


private void updateGameState() {
if (selected != -1) {
//loadSelectedLevel();
}
//showSelection();
                        //View v2 = this.findViewById(R.id.mylayout);
View v2 = (LinearLayout) findViewById(R.id.mylayout);

if (startTouch) {

showSelection();

startTouch = false;

v2.setVisibility(View.VISIBLE);

}else{
v2.setVisibility(View.INVISIBLE);


}
       ...


This is my xml

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

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

    <LinearLayout
        android:id="@+id/mylayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:visibility="visible" >

        <LinearLayout
            android:id="@+id/mylayout2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" >

            <com.android.joystick.JoystickView
                android:id="@+id/joystickView"
                android:layout_width="100dip"
                android:layout_height="100dip"
                android:layout_gravity="bottom"
                android:layout_marginTop="20dip"
                android:color="#88000000" />

            <TableLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dip" >

                <TableRow>

                    <TextView
                        android:layout_width="50dip"
                        android:layout_height="wrap_content"
                        android:layout_gravity="bottom"
                        android:text="X" />

                    <TextView
                        android:id="@+id/TextViewX"
                        android:layout_width="100dip"
                        android:layout_height="wrap_content" />
                </TableRow>

                <TableRow>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Y" />

                    <TextView
                        android:id="@+id/TextViewY"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </TableRow>
            </TableLayout>
        </LinearLayout>
    </LinearLayout>

</FrameLayout>

#3
Support / solved stop soundpool
February 14, 2014, 01:06:50 PM
I know isn't jpc-ae but it is helpful  :D

Add functions at class SoundManager


public synchronized int playID(int id) {
if (res == null || GameConfig.soundMul == 0) {
return 0;
}
times[id] = Ticker.getTime();
return soundPool.play(ids[id], 0.75f * GameConfig.soundMul, 0.75f * GameConfig.soundMul, 0, 0, 1);
}

public synchronized void stopID(int id) {
if (res == null || GameConfig.soundMul == 0) {
return;
}
soundPool.stop(id);

}





private int mStreamId;

//for play
mStreamId=SoundManager.getInstance().playID(SoundManager.COLLECTED);

//for stop
SoundManager.getInstance().stopID(mStreamId);


#4
Support / the source code projects links
February 12, 2014, 07:17:25 PM
the source code projects links?

ej:Alien Runner and other proyects

   
#5
show this error in jpct-ae last version


02-12 13:34:15.693: E/dalvikvm(370): No free temp registers
02-12 13:34:15.693: E/dalvikvm(370): Jit: aborting trace compilation, reverting to interpreter
02-12 13:34:15.703: E/dalvikvm(370): No free temp registers
02-12 13:34:15.703: E/dalvikvm(370): Jit: aborting trace compilation, reverting to interpreter


and no hide ramp with puss down sphere with function selectAnyObjectAt


here the full code

package com.threed.jpct.example;

import java.io.InputStream;
import java.lang.reflect.Field;

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

import android.app.Activity;
import android.content.res.Resources;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;

import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Interact2D;
import com.threed.jpct.Light;
import com.threed.jpct.Loader;
import com.threed.jpct.Logger;
import com.threed.jpct.Matrix;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.RGBColor;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.World;
import com.threed.jpct.util.MemoryHelper;

/**
* A simple demo. This shows more how to use jPCT-AE than it shows how to write
* a proper application for Android. It includes basic activity management to
* handle pause and resume...
*
* @author EgonOlsen
*
*/
public class HelloWorld extends Activity {

    // Used to handle pause and resume...
    private static HelloWorld master = null;

    private GLSurfaceView mGLView;
    private MyRenderer renderer = null;
    private FrameBuffer fb = null;
    private World world = null;
    private RGBColor back = new RGBColor(255, 0, 0);

    private float touchTurn = 0;
    private float touchTurnUp = 0;

    private float xpos = -1;
    private float ypos = -1;


    //private int fps = 0;

    private Light sun = null;

    //------------------------
    private Texture font = null;
   
    private float move = 0;
   
    private static final long serialVersionUID = 1L;

    private static final float DAMPING = 0.1f;

    private static final float SPEED = 1f;

    private static final float MAXSPEED = 1f;
   
    private Object3D plane = null;

    private Object3D ramp = null;

    private Object3D cube = null;

    private Object3D cube2 = null;

    private Object3D sphere = null;

    private float dxx;

    private SimpleVector moveRes = new SimpleVector(0, 0, 0);

    private SimpleVector ellipsoid = new SimpleVector(2, 2, 2);
   
    private Camera cam = null;
   
    private Object3D selectedObject = null;
   
    protected void onCreate(Bundle savedInstanceState) {

        Logger.log("onCreate");

        if (master != null) {
            copy(master);
        }

        super.onCreate(savedInstanceState);
        mGLView = new GLSurfaceView(getApplication());

        mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
            public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
                // Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
                // back to Pixelflinger on some device (read: Samsung I7500)
                int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
                EGLConfig[] configs = new EGLConfig[1];
                int[] result = new int[1];
                egl.eglChooseConfig(display, attributes, configs, 1, result);
                return configs[0];
            }
        });

        renderer = new MyRenderer();
        mGLView.setRenderer(renderer);
        setContentView(mGLView);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    private void copy(Object src) {
        try {
            Logger.log("Copying data from master Activity!");
            Field[] fs = src.getClass().getDeclaredFields();
            for (Field f : fs) {
                f.setAccessible(true);
                f.set(this, f.get(src));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public boolean onTouchEvent(MotionEvent me) {

        if (me.getAction() == MotionEvent.ACTION_DOWN) {
            xpos = me.getX();
            ypos = me.getY();
            return true;
        }

        if (me.getAction() == MotionEvent.ACTION_UP) {
            xpos = -1;
            ypos = -1;
            touchTurn = 0;
            touchTurnUp = 0;
            return true;
        }

        if (me.getAction() == MotionEvent.ACTION_MOVE) {
            float xd = me.getX() - xpos;
            float yd = me.getY() - ypos;

            xpos = me.getX();
            ypos = me.getY();

            touchTurn = xd / -100f;
            touchTurnUp = yd / -100f;
           
            dxx = -xd / -200f;
            cube.rotateY(-dxx);
            return true;
        }

        try {
            Thread.sleep(15);
        } catch (Exception e) {
            // No need for this...
        }

        return super.onTouchEvent(me);
    }
   
    private int selectAnyObjectAt( int mouseX, int mouseY){
        //Camera cam = world.getCamera();
        SimpleVector ray=Interact2D.reproject2D3DWS(cam, fb, mouseX, mouseY).normalize();
        Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), ray, 10000F);
        if (res==null || res[1] == null || res[0] == (Object)Object3D.RAY_MISSES_BOX) {
            //Log.d("SELECTION", "You missed! x="+mouseX+" y="+mouseY);   
            selectedObject = null;
            return -1;
        }
        Object3D obj = (Object3D)res[1];
        Log.d("SELECTION", "x="+mouseX+" y="+mouseY+" id2="+obj.getID()+" name="+obj.getName());
        selectedObject = obj;   
       
       
       
        if(obj.getID()==4){   
            if(ramp.getVisibility()==true){
                ramp.setVisibility(false);
               
               
            }else{
                //SoundManager.getInstance().play(SoundManager.COLLECTED);   
                 ramp.setVisibility(true);
                 
            }
         
        }
       
       
        return obj.getID();
    }

    public boolean onKeyDown(int keyCode, KeyEvent msg) {
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
            move = 1f;
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            move = -1f;
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
            cube.rotateY((float) Math.toRadians(-1));
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            cube.rotateY((float) Math.toRadians(1));
            return true;
        }

       

        return super.onKeyDown(keyCode, msg);
    }
   
    public boolean onKeyUp(int keyCode, KeyEvent msg) {
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
            move = 0;
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            move = 0;
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
           
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
           
            return true;
        }

       

        return super.onKeyUp(keyCode, msg);
    }

   
    protected boolean isFullscreenOpaque() {
        return true;
    }

    class MyRenderer implements GLSurfaceView.Renderer {
        private int fps = 0;
        private int lfps = 0;
       
        private long time = System.currentTimeMillis();
        private boolean stop = false;
        public MyRenderer() {
           
            Config.maxPolysVisible = 500;
             Config.farPlane = 1500;
             Config.glTransparencyMul = 0.1f;
             Config.glTransparencyOffset = 0.1f;
             Config.useVBO=true;
             
             Texture.defaultToMipmapping(false);
             Texture.defaultTo4bpp(true);
        }
        public void stop() {
            stop = true;
        }

        public void onSurfaceChanged(GL10 gl, int w, int h) {
            if (fb != null) {
                fb.dispose();
            }
            fb = new FrameBuffer(gl, w, h);

            if (master == null) {
                Resources res = getResources();
                world = new World();
                world.setAmbientLight(20, 20, 20);

                sun = new Light(world);
                sun.setIntensity(250, 250, 250);
               
                //keyMapper = new KeyMapper(this);
               
                plane = Primitives.getPlane(20, 10);
                plane.rotateX((float) Math.PI / 2f);

                ramp = Primitives.getCube(20);
                ramp.rotateX((float) Math.PI / 2f);

                sphere = Primitives.getSphere(30);
                sphere.translate(-50, 10, 50);

                cube2 = Primitives.getCube(20);
                cube2.translate(60, -20, 60);
               
                cube = loadModel(res.openRawResource(R.raw.flecha), 0.5f);
                //cube = Primitives.getCube(2);
                //cube.rotateY((float) Math.PI / 2f);
                cube.translate(-50, -10, -50);
                cube.setAdditionalColor(RGBColor.GREEN);
                cube.strip();
                cube.build();

                plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
                ramp.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
                sphere.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
                cube2.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
                cube.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
                ramp.setVisibility(false);
               
                world.addObject(plane);
                world.addObject(ramp);
                world.addObject(cube);
                world.addObject(sphere);
                world.addObject(cube2);
               
                Light light = new Light(world);
                light.setPosition(new SimpleVector(0, -80, 0));
                light.setIntensity(140, 120, 120);
                light.setAttenuation(-1);

                world.setAmbientLight(20, 20, 20);
               
                cam = world.getCamera();
                cam.moveCamera(Camera.CAMERA_MOVEOUT, 100);
                cam.moveCamera(Camera.CAMERA_MOVEUP, 100);
                cam.lookAt(ramp.getTransformedCenter());
               
                //long start = System.currentTimeMillis();
                //long fps = 0;

                SimpleVector sv = new SimpleVector();
                sv.set(cube.getTransformedCenter());
                sv.y -= 50;
                sv.z -= 100;
                sun.setPosition(sv);
                MemoryHelper.compact();

                if (master == null) {
                    Logger.log("Saving master Activity!");
                    master = HelloWorld.this;
                }
            }
        }
       
        private Object3D loadModel(InputStream filename, float scale) {
            Loader.setVertexOptimization(false);
           
            Object3D[] model = Loader.load3DS(filename, 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.rotateY((float)(-Math.PI));
                temp.rotateMesh();
                temp.setRotationMatrix(new Matrix());
                o3d = Object3D.mergeObjects(o3d, temp);
       
            }
            o3d.build();
            return o3d;
    }
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        }

        public void onDrawFrame(GL10 gl) {
            try {
               
               
                selectAnyObjectAt((int) xpos, (int) ypos);
               
               
                if (!stop) {
                    //move();
                   
         cam = world.getCamera();
            cam.setPositionToCenter(cube);
            cam.align(cube);
            cam.rotateCameraY(0.0174532925f * 90f);
            cam.rotateCameraX((float) Math.toRadians(30));
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 40);
         
            SimpleVector t = cube.getXAxis();
            t.scalarMul(move);
            moveRes.add(t);
           
            // avoid high speeds
            if (moveRes.length() > MAXSPEED) {
                moveRes.makeEqualLength(new SimpleVector(0, 0, MAXSPEED));
            }

            cube.translate(0, -0.02f, 0);

            moveRes = cube.checkForCollisionEllipsoid(moveRes, ellipsoid, 8);
            cube.translate(moveRes);

            // finally apply the gravity:
            //SimpleVector t = cube.getZAxis();
            SimpleVector tt = new SimpleVector(0, 1, 0);
            tt = cube.checkForCollisionEllipsoid(tt, ellipsoid, 1);
            cube.translate(tt);

            // damping
            if (moveRes.length() > DAMPING) {
                moveRes.makeEqualLength(new SimpleVector(0, 0, DAMPING));
            } else {
                moveRes = new SimpleVector(0, 0, 0);
            }
             
           
           
            fb.clear(back);
            world.renderScene(fb);
            world.draw(fb);
            blitNumber(lfps, 5, 5);
           
            fb.display();
           
           
            if (System.currentTimeMillis() - time >= 1000) {
                Logger.log(fps + "fps");
                lfps = fps;
                fps = 0;
                time = System.currentTimeMillis();
            }
            fps++;
                } else {
                    if (fb != null) {
                        fb.dispose();
                        fb = null;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                Logger.log("Drawing thread terminated!", Logger.MESSAGE);
            }
        }
       
        private void blitNumber(int number, int x, int y) {
            if (font != null) {
                String sNum = Integer.toString(number);

                for (int i = 0; i < sNum.length(); i++) {
                    char cNum = sNum.charAt(i);
                    int iNum = cNum - 48;
                    fb.blit(font, iNum * 5, 0, x, y, 5, 9, FrameBuffer.TRANSPARENT_BLITTING);
                    x += 5;
                }
            }
        }
    }
}




#6
Support / how to implement a start menu
February 12, 2014, 01:12:26 PM
how to implement a start menu
i need examples codes

this is good, but i don know implement
http://www.jpct.net/forum2/index.php/topic,2139.msg15977.html#msg15977
#7
Support / collision example how helloword-ae
February 08, 2014, 06:55:03 PM
Long time ago i not visited this site...

i search a simple example collision proyect android jpct-ae

-sphere down in plane (gravity) for example

-or move sphere and colide with cube for example

I am not able to implement, i read wiki

http://www.jpct.net/wiki/index.php/Collision_detection

I do not understand
#8
Support / Animate Textures
April 15, 2012, 09:57:40 PM
Is posible Animate textures?  ej(Video) or add html code in blitboard?
#10
Support / jpct-ae 64 bit
March 27, 2012, 11:48:19 AM
The proyect  jpct-ae crash after install apk in my new machine 64bit.
The LogCat is

03-27 09:43:08.920: E/AndroidRuntime(437): FATAL EXCEPTION: main
03-27 09:43:08.920: E/AndroidRuntime(437): java.lang.NoClassDefFoundError: com.threed.jpct.RGBColor
03-27 09:43:08.920: E/AndroidRuntime(437):    at com.threed.jpct.example.HelloWorld.<init>(HelloWorld.java:50)
03-27 09:43:08.920: E/AndroidRuntime(437):    at java.lang.Class.newInstanceImpl(Native Method)
03-27 09:43:08.920: E/AndroidRuntime(437):    at java.lang.Class.newInstance(Class.java:1409)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.os.Looper.loop(Looper.java:123)
03-27 09:43:08.920: E/AndroidRuntime(437):    at android.app.ActivityThread.main(ActivityThread.java:3683)
03-27 09:43:08.920: E/AndroidRuntime(437):    at java.lang.reflect.Method.invokeNative(Native Method)
03-27 09:43:08.920: E/AndroidRuntime(437):    at java.lang.reflect.Method.invoke(Method.java:507)
03-27 09:43:08.920: E/AndroidRuntime(437):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-27 09:43:08.920: E/AndroidRuntime(437):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-27 09:43:08.920: E/AndroidRuntime(437):    at dalvik.system.NativeStart.main(Native Method)


#11
How to make an object not transferred to another at any angle?, there is a universal function of collision?
#12
Support / How rotate object around pivot?
February 18, 2012, 09:27:32 PM
How rotate object around pivot?
example:  earth=obj , Sun=pivot.
#13
How to make the light glow of the example "Multiple light sources" AnD3Bench?