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

Pages: [1] 2
Support / Re: Vuforia + jPCT-ae issue: 'Live' polyline update
« on: February 17, 2015, 07:28:15 am »
For this simulation yes, this is what I'm doing.

If thats the case, how should I go about doing it? The coordinates needs to be streaming in continuously to allow the Polyline to update continuously without looking laggy.

Support / Vuforia + jPCT-ae issue: 'Live' polyline update
« on: February 15, 2015, 10:54:03 am »
I am working on the vuforia + jpct-ae app which I am attempting to simulate a 'live' feed of spatial data into jpct to draw a polyline. A polyline requires a start and end point. For this simulation, I created a .txt file containing the start points x,y and z, and used bufferedreader to feed the code into the polyline class. I fixed end point at (0,0,0) for this simulation.

The end result I am hoping to acheive is that the line is constantly being 'updated' as the AR application is running. Ultimately, I wish to feed those spatial data obtained via Kinect live (not sure if its possible just yet, hence simulating using a .txt file first).

My codes are as such, in the initApplicationAR() method in class, I added a Button to call for the NeedleUpdate() method which I define in ImageTargetsRenderer class.
Code: [Select]
private void initApplicationAR()
        Button swap =(Button) findViewById(;
swap.setOnClickListener(new OnClickListener(){

public void onClick(View v) {

And at the ImageTargetsRenderer:
Code: [Select]
public ImageTargetsRenderer(ImageTargets activity) {
                SimpleVector needleStart = new SimpleVector (30.2, 30.4, -1);
SimpleVector needleEnd = new SimpleVector (0,0,0);
SimpleVector[] needlePoints= new SimpleVector[]{needleStart,needleEnd};
needle= new Polyline(needlePoints, RGBColor.BLACK);

cam = world.getCamera();

SimpleVector sv = new SimpleVector();
sv.y += 100;
sv.z += 100;



        public static void NeedleUpdate(){
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard, "point1.txt");

// Read text from file
StringBuilder text = new StringBuilder();
int numberOfRows = 0;
String line = null;

ArrayList<String> points = new ArrayList<String>();
ArrayList<Float> point1X = new ArrayList<Float>();
ArrayList<Float> point1Y = new ArrayList<Float>();
ArrayList<Float> point1Z = new ArrayList<Float>();
ArrayList<Integer> commaPos = new ArrayList<Integer>();

try {
//Read the Txt file containing the points.
//Stringbuilder reads everything as one whole 'paragraph'
BufferedReader br = new BufferedReader(new FileReader(file));

while ((line = br.readLine()) != null) {
//Replace spaces with commas
for (int c = 0; c < text.length(); c++) {
if (text.charAt(c) == ' ') {
text.replace(c, c + 1, ",");
//Store the individual lines of text into an array called points
text.delete(0, text.length());


} catch (IOException e) {

//Stores the position of the commas into a separate array called commaPos
for (int i = 0; i < points.size(); i++) {
for (int j = 0; j < points.get(i).length(); j++) {
if (points.get(i).charAt(j) == ',') {

for (int pointsRow = 0; pointsRow < points.size(); pointsRow++) {

int firstpos = pointsRow * 2;
String xpoint = points.get(pointsRow).substring(0,

int secondpos = (pointsRow * 2) + 1;

String ypoint = points.get(pointsRow)

String zpoint=points.get(pointsRow)

float xfloat= Float.parseFloat(xpoint);

float yfloat= Float.parseFloat(ypoint);

float zfloat= Float.parseFloat(zpoint);

SimpleVector point1 = new SimpleVector (point1X.get(pointsRow),point1Y.get(pointsRow)*-1,point1Z.get(pointsRow)*-1);// multiply -1 cuz flipped axis
SimpleVector point2 = new SimpleVector(0, 0, 0);

needle.update(new SimpleVector[]{point1,point2});


The result did perform the 'updating' of the needle. However, everytime it updates the camera layout freezes (see video here ). This does not appear 'live'. I suspect that I might have written the NeedleUpdate() method at the wrong place such that the ImageTargetsRenderer class renders the initial 3D models, then renders again when the button is pressed. That is to say the needle is drawn only when button is pressed which obviously does not continuously 'updates' the needle.

What I wanna acheive is that the needle is always being updated continuously without the screen being frozen. Any advise?

Support / Letters/Characters/Alphabets in World
« on: January 28, 2015, 03:20:13 pm »
I was wondering if there is a method to draw alphabets in world? I am trying to replicate  the XYZ axis on the bottom left hand corner in the attached image, where the characters X Y Z are drawn.

Support / Re: jPCT + Vuforia Issue: 3D Model's Rotation
« on: January 25, 2015, 06:12:12 am »
Hi Egon, thanks so much it works. I skipped the dummy object though, and simply setRotationPivot(Lshapedmodel.getTransformedCenter()) after calling plane.addParent(Lshapedmodel). It works just as well!  ;D

Support / Re: Automating translation of 3D model
« on: January 23, 2015, 10:33:46 am »
ah ha, that works! Thanks!

Support / Re: jPCT + Vuforia Issue: 3D Model's Rotation
« on: January 23, 2015, 10:10:09 am »
I uploaded a video on youtube and here's the link:

In the video you will see two parts, the first part is what I want. You'll see 2 planes and a L-shaped gray model. When I rotate the model around to observe the model at different angle, you'll realise that the 2 planes rotate along with the model, as if the rotation is about the model's center.

In the second part of the video is what I have right now on my tablet. You'll see 3planes and as I rotate the model, you'll realise that the plane does not rotate as how the 2planes rotate in the first part of the video. They appear to rotate about its own center.

I hope I'm clearer now.

Support / Automating translation of 3D model
« on: January 21, 2015, 01:20:58 pm »
Hey there, me again. I am trying to 'automate' a translation of a 3D model that I input into jPCT. But because the center of this model is not at the world's origin, I do an inverse translation of this 3D model so that I can view it at the origin in world space. However, I realise that float somehow does not go into the negative region (but googling around seems to suggest that float can be negative). This is what I intend to do:

Code: [Select]
cube=Object3D.mergeAll(Loader.loadOBJ(inputmodelFile, null, 1));
float xT=-cube.getCenter().x;
float yT=-cube.getCenter().y;
float zT=-cube.getCenter().z;

Log.w("cube center", String.valueOf(xT)+ " "+ String.valueOf(yT)+ " " + String.valueOf(zT));

However, this does not perform the translation at all because the Log meesage tells me -0.0 -0.0 -0.0 . In fact, cube.getCenter has some solid numbers, for my models the center is actually (10,50,-100). I tried other methods to get the figures into the negative region, ie multiply -1f, using -=, but none seems to work. Could anyone help explain where have I gone wrong?

Support / Re: jPCT + Vuforia Issue: 3D Model's Rotation
« on: January 21, 2015, 12:57:02 pm »
Hi Egon, thanks so much for replying. This rotation pivot is shifting my planes around. When I simply call getPlane, all my planes are drawn at the world origin correctly (see attached Capture2.jpg). However, when I do setRotationPivot, my planes somehow got shifted elsewhere.

Code: [Select]
float angle = (float) Math.PI/2;
xplane=Primitives.getPlane(10, 3);
yplane=Primitives.getPlane(10, 3);
zplane=Primitives.getPlane(10, 3);


xplane.setRotationPivot(new SimpleVector(0,-50,0)); //This line moves my plane, see attached Capture1.jpg

I understand that setRotationPivot should be called after build() as I did above, but I do not understand why does setRotationPivot move my plane. I did not call any translation prior to setRotationPivot  :(

Support / Re: Rendering planes
« on: January 21, 2015, 12:18:53 pm »
Hi Egon, can I ask if there is a way to change the texture or set colors on cullings? I just realised that the setCulling(false) shades the back face of the plane that I'm drawing but it sets a default color to black. Anyway to change its color?

Support / jPCT + Vuforia Issue: 3D Model's Rotation
« on: January 18, 2015, 11:13:00 am »
Hi ppl, I'm experimenting on the the jPCT+Vuforia sample app and am facing some issues about the rotation of the 3D model. I changed out the cube and placed my own OBJ model.

I called translation to translate the 3D model at some translation vector, and when I rotate the image target, the 3D model rotates as well. However, the rotation of the 3D model is about its own center, not the image target's center. I tried using setRotationPivot about the origin in the world coordinate system (setRotationPivot(new SimpleVector(0,0,0)) but the rotation is still about the center of the 3D model.

Is anyone able to help me with this? The rotation/movement of the 3D model should be relative to the imagetarget, not the its own center.

Support / Re: Drawing XYZ axis/plane and section view
« on: January 05, 2015, 06:13:59 am »
Oh, I tried another approach and it works. I cloned the model, and I setShadersOpaque on one model, and setShadersSolid on the other, and add both into world. Looks not bad :)

Support / Re: Drawing XYZ axis/plane and section view
« on: January 05, 2015, 05:59:09 am »
Hi Egon, your code work wonders, thanks so much.

I am exploring one more feature, that is to set transparency on the 'cutted away' section. My approach is to alter the alpha value in the vertexShader.src by using setUniform("shader", 5f), but it doesn't seem to set any opaque-ness at all. My reason for doing this instead of simply using setTransparency is because I wanna show the full 3D model, ie the 'remaining-cutted' section be shown will full solid renders while the 'cutted-away' section be shown with some opaqueness. This way I think its possible for me to setShaders twice (i'm not sure if its possible yet), one shader to define the solid shading for remaining cutted section, while the second shader to define the opaque shading for the cut away section.

Any suggestion?

Support / Re: Intersection of 3 Planes in world space
« on: January 05, 2015, 05:19:54 am »
You mean getTransformedNormal() and getTransformedVertex()? Both of these methods require polyID argument, how can I obtain such ID?

Support / Intersection of 3 Planes in world space
« on: January 04, 2015, 03:28:38 pm »
Hi there, any idea how can I obtain the intersection of 3 planes in world space assuming these 3 planes intersect at a single point.

Mathematically its pretty straight forward if I have the equations of these 3 planes, but I think its rather difficult to obtain that information if my planes are placed inside using Primitives.getPlane. Alternatively I can compute using normal vectors (cross product) but still I do require 'some points' on the planes to do it purely mathematically. Anyone knows of a more direct approach to it?

Support / Re: Drawing XYZ axis/plane and section view
« on: January 04, 2015, 02:47:02 pm »
Hi Egon, thanks so much for replying. Seems like I have quite abit of catching up to do. Some queries and pls pardon me if some of these question sounds stupid:

1) To use the vertex shader and fragment shader, I notice that both of these src files are in a zipped file at lib/ in the jpct-ae folder when I downloaded the package. So do I unzip and modify the shader and fragment shader?
2) And once I do that, I can place those two src code into my project and simply call loadTextFile like u did in the onSurfaceChanged method?
3) I am a little unsure how to use the setUniform method. What I understand from the docs and your sample activity above is defining the start and end point on the X axis to include in the shading and this is set at -4 and 4 as float values. These values will be passed into the fragment shader.src for computation, am I right to say that?

Pages: [1] 2