Recent Posts

Pages: 1 ... 6 7 [8] 9 10
71
Support / Re: How does JPCT-AE Vertex works on Object3D.addTriangle(...)?
« Last post by EgonOlsen on November 26, 2022, 09:31:27 pm »
Order matters here. jPCT culls away back faces (unless you disable this with setCullling(), but the lighting will be wrong in this case). What is a back face and what isn't is defined by the order of the vertices in a triangle. In this case, reverse the order of the vertices for the faces that aren't visible and they should show up.
72
Support / How does JPCT-AE Vertex works on Object3D.addTriangle(...)?
« Last post by Hellfire on November 25, 2022, 03:45:26 pm »
Hello friends. How does JPCT-AE Vertex works on Object3D.addTriangle(...)?
Code: [Select]
public static Object3D createCube(float scale) {
 Object3D o = new Object3D(12);
 float size = scale / 2;

// FRONT
 o.addTriangle(new SimpleVector(-size, size, size), new SimpleVector(-size, -size, size), new SimpleVector(size, size, size));
 o.addTriangle(new SimpleVector(size, size, size), new SimpleVector(size, -size, size), new SimpleVector(-size, -size, size));

// BACK
 o.addTriangle(new SimpleVector(-size, size, -size), new SimpleVector(-size, -size, -size), new SimpleVector(size, size, -size));
 o.addTriangle(new SimpleVector(size, size, -size), new SimpleVector(size, -size, -size), new SimpleVector(-size, -size, -size));

// LEFT
 o.addTriangle(new SimpleVector(-size, size, size), new SimpleVector(-size, -size, size), new SimpleVector(-size, size, -size));
 o.addTriangle(new SimpleVector(-size, size, -size), new SimpleVector(-size, -size, -size), new SimpleVector(-size, -size, size));
 
// RIGHT
 o.addTriangle(new SimpleVector(size, size, size), new SimpleVector(size, -size, size), new SimpleVector(size, size, -size));
 o.addTriangle(new SimpleVector(size, size, -size), new SimpleVector(size, -size, -size), new SimpleVector(size, -size, size));

// UPPER
 o.addTriangle(new SimpleVector(size, size, size), new SimpleVector(-size, size, size), new SimpleVector(size, size, -size));
 o.addTriangle(new SimpleVector(size, size, -size), new SimpleVector(-size, size, -size), new SimpleVector(-size, size, size));

// LOWER
 o.addTriangle(new SimpleVector(size, -size, size), new SimpleVector(-size, -size, size), new SimpleVector(size, -size, -size));
 o.addTriangle(new SimpleVector(size, -size, -size), new SimpleVector(-size, -size, -size), new SimpleVector(-size, -size, size));
 return o;
}
Result:
73
Support / Re: How to display 2D image to 3D screen
« Last post by AeroShark333 on November 22, 2022, 03:05:15 pm »
Thank you, its working, i didn't have the perfect texture though  ::) ::)
Glad to hear!

For a joystick, I'd recommend a PNG file as texture (where the outside is transparent), otherwise a JPG texture (where the outside is black).
Make sure to use the constructors in Texture that have 'useAlpha' (which you should then set to true): https://www.jpct.net/jpct-ae/doc/com/threed/jpct/Texture.html#Texture-Bitmap-boolean-
74
Support / Re: How to display 2D image to 3D screen
« Last post by Hellfire on November 22, 2022, 12:39:50 pm »
Hello welcome!

Hello friends. How to display 2D Image to the camera?
I'am trying to make a Joystick
I'd recommend the blitting functions of the FrameBuffer:
https://www.jpct.net/jpct-ae/doc/com/threed/jpct/FrameBuffer.html#blit-com.threed.jpct.Texture-float-float-float-float-float-float-float-float-int-boolean-

I hope this helps :)
Thank you, its working, i didn't have the perfect texture though  ::) ::)
75
Support / Re: How to display 2D image to 3D screen
« Last post by AeroShark333 on November 21, 2022, 10:27:21 pm »
Hello welcome!

Hello friends. How to display 2D Image to the camera?
I'am trying to make a Joystick
I'd recommend the blitting functions of the FrameBuffer:
https://www.jpct.net/jpct-ae/doc/com/threed/jpct/FrameBuffer.html#blit-com.threed.jpct.Texture-float-float-float-float-float-float-float-float-int-boolean-

I hope this helps :)
76
Support / How to display 2D image to 3D screen
« Last post by Hellfire on November 21, 2022, 12:13:39 pm »
Hello friends. How to display 2D Image to the camera?
I'am trying to make a Joystick
77
News / Re: Maintainability
« Last post by GMas on November 14, 2022, 12:18:04 pm »
Thanks for your answers. So far nothing very important to bring up. I'm just starting off the bench  ;D and testing the lib.
78
Support / Re: Bug with diffuse lighting
« Last post by AeroShark333 on November 13, 2022, 03:49:43 am »
I tried to modify the test case to something similar as what I had but it seems to be working fine...

I tried to look again at my own situation too but it seems fine now...  ???
I think I just made a mistake myself along the way
Sorry for bringing this up, I guess it was an error on my side after all
I think I forgot to set the intensities for some lights and they showed the wrong color (white by default...)

I'll report back if there was something fishy going on still but I suppose it is not the case; so... case closed for now
79
Support / Re: Bug with diffuse lighting
« Last post by EgonOlsen on November 11, 2022, 11:38:10 am »
I made this test case, but I fail to see an issue with it:



Code: [Select]
package com.threed.jpct.example;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Light;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.RGBColor;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.World;

import java.util.ArrayList;
import java.util.List;

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

public class HelloWorld extends Activity {
    private GLSurfaceView mGLView;
    private MyRenderer renderer = null;
    private FrameBuffer fb = null;
    private World world = null;
    private final List<Light> lights = new ArrayList<>();
    private float[] dir = null;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLView = new GLSurfaceView(getApplication());
        mGLView.setEGLContextClientVersion(2);
        mGLView.setPreserveEGLContextOnPause(true);

        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();
        System.exit(0);
    }


    class MyRenderer implements GLSurfaceView.Renderer {

        public MyRenderer() {
            //
        }

        public void onSurfaceChanged(GL10 gl, int w, int h) {
            world = new World();
            world.setAmbientLight(0, 0, 0);

            SimpleVector[] cols = new SimpleVector[]{
                    SimpleVector.create(64, 128, 64),
                    SimpleVector.create(0, 128, 128),
                    SimpleVector.create(128, 0, 128),
                    SimpleVector.create(128, 128, 0),
                    SimpleVector.create(0, 0, 128),
                    SimpleVector.create(128, 0, 0),
                    SimpleVector.create(0, 128, 0),
                    SimpleVector.create(0, 64, 64)};

            for (int i = 0; i < 8; i++) {
                Object3D obj = Primitives.getSphere(50, 8);
                world.addObject(obj);
                int pos = 30 + (i - 7) * 10;
                obj.translate(10 - 20 * (i % 2), pos, 0);
                obj.build();
            }

            for (int i = 0; i < 8; i++) {
                int pos = 30 + (i - 7) * 30;
                Light light = new Light(world);
                light.setIntensity(cols[i]);
                SimpleVector sv = new SimpleVector();
                sv.y = pos;
                sv.z -= 20 - 40 * (i % 2);
                light.setPosition(sv);
                lights.add(light);
            }

            dir = new float[lights.size()];
            for (int i = 0; i < lights.size(); i++) {
                dir[i] = 1f;
            }

            Camera cam = world.getCamera();
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 45);
            cam.lookAt(SimpleVector.ORIGIN);

            fb = new FrameBuffer(w, h);
        }

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

        public void onDrawFrame(GL10 gl) {
            fb.clear(RGBColor.BLACK);
            world.renderScene(fb);
            world.draw(fb);
            fb.display();

            for (int i = 0; i < lights.size(); i++) {
                Light light = lights.get(i);
                SimpleVector sv = light.getPosition();
                sv.y += dir[i];
                if (sv.y > 150 || sv.y < -150) {
                    dir[i] *= -1f;
                }
                light.setPosition(sv);
            }
        }
    }
}


Do you have a test case that shows this problem?
80
Support / Re: Bug with diffuse lighting
« Last post by AeroShark333 on November 09, 2022, 04:00:05 pm »
Thank you!
Pages: 1 ... 6 7 [8] 9 10