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.


Messages - Thunderfox

Pages: [1]
1
German corner / Re: Schwarz / Weiß rendern
« on: August 11, 2011, 12:38:47 am »
Alles klar, dann werde ich eine halbtransparente Grafik über die Welt legen, die den Bildschirm einfach abdunkelt oder farblich verändert. Ist zwar kein schwarz/weiß, aber ich denke, der wirkende Effekt sollte ähnlich sein.

Beim Pixelarray werde ich wohl konstant so viele Faces wie das Display Pixel hat *2 berechnen müssen, was zu einem sehr starken Performanceeinbruch führen dürfte. Hab im zweiten Beitrag nicht bedacht, dass OpenGL ja keine Pixel sondern dreiecke rendert.

Danke für die schnellen und hilfreichen Antworten hier im Forum :)

2
German corner / Re: Schwarz / Weiß rendern
« on: August 09, 2011, 04:51:27 pm »
Ja stimmt, hab ich ganz vergessen zu erwähnen. ;)

Ich sollte auch mal wieder im JPCT-AE Unterforum schreiben, so sind schließlich auch mehrere in der Lage, diese Nachrichten zu verstehen, wenn sie ähnliche Probleme haben, auch wenn mein Englisch nicht das beste ist. ^^

3
German corner / Re: Schwarz / Weiß rendern
« on: August 08, 2011, 02:01:30 pm »
Es sollte schon Echtzeit sein, aber welche Möglichkeiten gäbe es denn, auch wenn sie länger zum Rendern braucht? Meine erste Überlegung war, die einzelnen Pixel des Framebuffers zu manipulieren, jedoch habe ich keine Ahnung wie ich das anstellen könnte.

4
German corner / Schwarz / Weiß rendern
« on: August 08, 2011, 12:38:12 pm »
Hallo,

Ganz kurz und knapp: Gibt es eine simple Möglichkeit, den Framebuffer für wenige Sekunden nur schwarz weiß darzustellen oder gewisse Farben zu entnehmen? Die Texturen sind farbig und sollen auch farbig bleiben, da es dafür zu umfangreich wäre, alle Texturen zusätzlich schwarz weiß zu laden.

Wenn nicht, nicht schlimm, aber könnte ja sein ;)

5
German corner / Re: Ein Objekt beliebig oft rendern / Spriteanimation
« on: July 21, 2011, 09:53:39 pm »
Die Rechtecke (jeweils zwei Dreiecke) der Animation habe ich auch in nur einem Floatbuffer definiert und über diese Rechtecke (Dreiecke) dann die Textur. Wenn man diesen Floatbuffer als ein Objekt bezeichnen kann, war dieses also auch nur eins.
Anstatt die Textur zu verschieben habe ich also immer nur ein paar Vertices aus dem Floatbuffer gezeichnet und das funktionierte problemlos auf mein Samsung Galaxy S3 I5800 und war trotz allem performant, da ja schließlich immer nur 2 Dreiecke des Objekts gezeichnet wurden und nur zwei Floatbuffer (für Vertices und Texturekoordinaten) existierte.

Die Engine finde ich sonst aber vor allem im Bereich der Objekt-Animationen und der Performance besser.

Ich werde mal mehrere Möglichkeiten, unter anderem die vorgeschlagenen Möglichkeiten, durchprobieren und dann einmach kurz ergänzen, wie ich das Problem für mich gelöst habe ;)

6
German corner / Ein Objekt beliebig oft rendern / Spriteanimation
« on: July 21, 2011, 09:15:25 pm »
Hallo,

mein Anliegen hier einmal auf Deutsch, da ich dies auf Englisch nur schwer erklären könnte:

Für das Android Game, an welches ich arbeite, benötige ich verschiedene Effekte, die allerdings nur auf einer 2D-Ebene im Game gezeigt werden sollen, bsp. Feuerkugeln, Lichter etc..
Pro Effekt wollte ich dafür eine halbtransparente PNG benutzen, die um die 16-64 verschiedene Bildsequenzen enthält. Beispielsweise eine 512x512 PNG, die 64 Animationsabschnitte in der Größe von 64x64 Pixel enthält und diese auf ein Viereck in einer Schleife abspielt.
Das erste Problem hieran ist, dass diese Animationen nach wenigen Sekunden wieder verschwinden sollen und viele parallel ablaufen können müssen. Es wäre hier also etwas unschön, für jede Animation ein neues Objekt zu erstellen bzw. es zu kopieren und dann nach wenigen Sekunden wieder zu löschen. Kann man ein Objekt in der Form, wie man es bei OpenGL kann, mehrfach rendern oder gibt es eine Möglichkeit, in der onDrawFrame vielleicht selbst mit OpenGL kommunizieren zu können und das Ergebnis in den Framebuffer schreiben zu können (ähnlich wie die blit-Funktionen bei GLFont)(ohne Probleme mit dem Z-Buffer zu bekommen)? Das zweite Problem: Wie kann ich auf diesen Vierecken eine Animation aus dieser PNG abspielen?

Als ich die Render-Klasse noch auf OpenGL-Basis programmiert habe, habe ich hierfür ein Objekt erstellt, welches aus so vielen Rechtecken (also jeweils 2 Dreiecke) bestand, wie die Animation lang ist. Alle Rechtecke lagen hier übereinander, auf jedem Rechteck wurde ein anderer Teil der Textur gemappt und je nach Fortschritt der Animation habe ich über die glDrawArrays(GL10.GL_TRIANGLES, offset, vertices); nur ein bestimmtes Rechteck gezeichnet, indem ich "offset" und "vertices" des aktuellen Animationsbildes bestimmte.
Außerdem konnte ich das Objekt bei der gleichen Anzahl an Animationen mit einer anderen Textur ohne Probleme ein zweites mal rendern, ohne gleich ein neues Objekt erstellen zu müssen.

Gibt es in dieser Engine eventuell eine ähnliche Funktion, die dies macht, welche ich noch nicht entdeckt habe?

Viele Grüße,

Thunderfox.

7
Support / Re: Loading Screen
« on: July 21, 2011, 12:16:12 pm »
Then I think it is the best, when I also load the objects while the onDrawFrame function is running (which I called renderloop above) and not while initialize the GLSurface.

Thanks for the Textclass :)

8
Support / Loading Screen
« on: July 20, 2011, 04:13:54 pm »
Hi,
I want to create a loading screen for the time while the GLSurfaceView, objects and textures are loading. But when I try to load a ProgressDialog in Android, you can see it not until the GLSurfaceView is ready and the renderloop is started. Also a overlay with Android Widgets can't displayed until GLSurfaceView is loaded.
Before I found this engine, I loaded objects in the renderloop, one object per frame and every frame I scaled a colored rectangle, the progressbar, in x-direction. At all, this solution is not really clear.
So, is there another easy solution to show a ProgressBar while loading the GLSurfaceView?

By the way: Is there a easy function to draw 2D text?

9
Support / Re: Strange error while key animation
« on: July 20, 2011, 11:20:20 am »
Thank You, works perfect :)

10
Support / Strange error while key animation
« on: July 20, 2011, 01:19:24 am »
Hello :)
Today I found this engine for Android. It seems to be really usefull and I want to use it for a little game.

But while I testing the key animation function, I got strange results:
There are two 3ds files, which I load in an animation object. When I use the Object3D.animate(index, seq); function on the object, the object is animate only from first object to second. I cannot go back by reducing index from 1 to 0 over the time.
Later I note that the animation is played also when I used a static value for index. If index is 0.0001f, the animation is very slow and when it's higher, the animation is also faster.

I used this code but I don't think that there is an error:
Code: [Select]
package com.threed.jpct.example;

import java.io.IOException;
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.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;

import com.threed.jpct.Animation;
import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
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.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.util.BitmapHelper;
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(50, 50, 100);

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

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

private Object3D cube = null;
private int fps = 0;

private Light sun = 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();
}

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;
return true;
}

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

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();
private boolean stop = false;
private float ind;
private int an = 2;

public MyRenderer() {
}

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) {

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

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

// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.icon)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);



try {
cube = loadModel(getAssets().open( "magiera.3ds" ), 10);

        Animation anim = new Animation(3);
        anim.setInterpolationMethod(Animation.LINEAR);
        anim.setCaching(false);
       
        anim.createSubSequence("idle");
        anim.addKeyFrame(cube.getMesh());

        anim.createSubSequence("walk");
        anim.addKeyFrame(cube.getMesh());
        anim.addKeyFrame(loadModel(getAssets().open( "magierb.3ds" ), 10).getMesh());

        cube.setAnimationSequence(anim);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

cube.calcTextureWrapSpherical();
cube.setTexture("texture");
cube.strip();
cube.build();

world.addObject(cube);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cube.getTransformedCenter());

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

if (master == null) {
Logger.log("Saving master Activity!");
master = HelloWorld.this;
}
}
}

    private Object3D loadModel(InputStream objStream, float scale) {
        Loader.setVertexOptimization(false);
        Object3D[] model = Loader.load3DS(objStream, 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.calcBoundingBox();
            o3d.calcNormals();
        }
        return o3d;
    }

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {

try {
if (!stop) {
doAnim();
if (touchTurn != 0) {
cube.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
cube.rotateX(touchTurnUp);
touchTurnUp = 0;
}
 
fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
} else {
if (fb != null) {
fb.dispose();
fb = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}

    public void doAnim() {
    ind += 0.01f;
    if(ind > 1){
    ind--;
    }
   
        cube.animate(0.003f,2);

   
    }
}
}

Could be an error in the Object.animate(index,seq); function?

Pages: [1]