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.

Topics - jiarongkoh

Pages: [1]
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 / 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 / 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 / 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 / Rendering planes
« on: December 31, 2014, 10:33:38 am »
Hi all, I was drawing a plane and realised that the texturing of the plane is only on the front of the plane, not the back. That is to say if I rotate the plane to the back, its transparent. Anyway to texture the plane throughout both front and back?

Support / Drawing XYZ axis/plane and section view
« on: December 31, 2014, 09:09:51 am »
Hi all, I am working on an app that is capable of providing section views of a 3D model. This section view is indicated by a plane located on the XYZ axis of the model and the location is controlled by the user via a touch and scale capability on a XYZ axis. Ideally, what i wanna acheive is smth that looks like the one attached.

Any help in the approach in acheiving the two things is greatly appreciated:
1) an XYZ axis coordinate in the corner of the view
2) acheiving a section view of the 3D model

Pages: [1]