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

#1
hello everyone,Administrator
I loaded a black cube model now, but I can't see my load model
can you tell me how to load a balck model?

#2
Support / Re: Just want to ask for help
August 26, 2016, 10:37:43 AM
Thank you ,  This was a great help to me!!!   
In addition to the API documentation , and which have a good learning materials???
#3
Support / Re: Just want to ask for help
August 26, 2016, 04:48:02 AM
Thank you very much !  and I have look at MouseFollowDemo  and then make an Android demo ,But I failed :'( .Maybe I use wrong.Maybe I used the wrong, because I'm not very familiar with the coordinate system for JPCT.
My goal is where I click, the ball will appear in where    This goal is very simple, but I am very confused now . so i want to you can help me . thank you :)
and this is my

package org.yanzi.camera.preview;

import android.content.Context;
import android.opengl.GLSurfaceView;

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

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


public class DeskRenderer implements GLSurfaceView.Renderer {


    private Context mContext;
    private FrameBuffer fb = null;
    private Object3D ball = null;
    private World world = null;
    private Light light = null;
    private Camera camera = null;
    public float horizontal;
    public float vertical;
    public float x = 0;
    public float y = 0;


    public DeskRenderer(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        world = new World();
        ball = Primitives.getSphere(5.0f);
        ball.strip();
        ball.build();
        world.addObject(ball);
        // light
        world.setAmbientLight(255, 255, 255);
        light = new Light(world);
        light.setIntensity(255, 255, 255);
        ball.getCenter();
        // camera
        camera = world.getCamera();
        camera.moveCamera(Camera.CAMERA_MOVEOUT, 100);
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        if (fb != null) {
            fb = null;
        }
        fb = new FrameBuffer(gl, width, height);
    }
    @Override
    public void onDrawFrame(GL10 gl) {
        fb.clear();
        world.renderScene(fb);
        world.draw(fb);
        SimpleVector ray = Interact2D.reproject2D3DWS(world.getCamera(), fb, (int) x, (int) y);
        if (ray != null) {
            ray.add(camera.getPosition());
            ray.normalize();
            float f = world.calcMinDistance(camera.getPosition(), ray, 1000);
            if (f != Object3D.COLLISION_NONE) {
                SimpleVector offset = new SimpleVector(ray);
                ray.scalarMul(f);
                ray = ray.calcSub(offset);
                ball.getTranslationMatrix().setIdentity();
                ball.translate(ray);
                ball.translate(world.getCamera().getPosition());

            }
        }
    }
}


When click on the screen, another class will  set value to x and y
#4
Support / Re: Just want to ask for help
August 25, 2016, 10:14:39 AM
thank for your reply ,and I have use reproject2D3DWS-method like this  (just for test fb is (1080*1920))
SimpleVector simpleVector1 = Interact2D.reproject2D3DWS(camera, fb, 1000, 1000,1f);

SimpleVector simpleVector2 = Interact2D.project3D2D(camera, fb, simpleVector1);

and this is debug result:
simpleVector2 = {SimpleVector@3889} "(544.55444,960.39606,0.00990099)"
simpleVector1 = {SimpleVector@3884} "(0.5324074,0.0462963,1.0)"
why simpleVector2 not (1000,1000,1) 

the second question

For example, I loaded a cuboid model, I need to get a cuboid vertex coordinates, what should I do?


I am a Chinese, English ability is not very good.I believe you should know what I mean :)



#5
Support / Just want to ask for help
August 24, 2016, 08:44:42 AM
Hello  everyone :
      I want to ask you some questions,specific as follows:

The first:
how to converts the coordinates of the screen to the inside of the camera 3 d coordinate?  because I need to be a model accurately on a certain position of the screen.
I have use
```
ball.translate(Interact2D.reproject2D3D(camera,fb,1000,1000,1));
```
But the ball is in the center of the screen is, fb is 1920 * 1080

The second:
How to get somewhere on the obj model coordinates, because I want to this point as the center of rotation of the model, rather than the center of gravity of the models