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

Pages: 1 2 [3] 4
31
Support / 3DS Texture loading advice...
« on: August 11, 2010, 05:22:19 pm »
I'm wishing to load a textured 3ds model from a remote url.

Jpct does have this neat system, as I understand, that when the 3ds model is loaded it will automatically assign matching textures already in its memory. (that is, if the 3ds refers to a filename "text1.jpg" for the texture, and a texture with that name is in memory, it will add it).
Thats pretty cool.
The problem is, with my app the textures also have to be loaded dynamically, and their names wont be known in advance. So I cant easily preload them all in, then call to load the 3ds.

Ideally, I'd like to be able to point the app at a url, say;
http://www.darkflame.co.uk/building1/building.3ds
And the app looks at the 3ds file, see's what texture-names it has assigned, then looks in the same url directory for them
http://www.darkflame.co.uk/building1/texture1.jpg
http://www.darkflame.co.uk/building1/texture2.jpg

Is this possible?

The only other solution I see for my app is I point it at a file on the server that lists both the 3ds file and all its textures. Then it looks at that list and downloads the textures listed and then the 3ds file.


32
Support / Re: Version updates!
« on: August 11, 2010, 02:49:42 pm »
Whooooaaaa FANTASTIC! YEEESSSS  :)

33
Support / Re: Possibly to download/display a mesh at runtime?
« on: July 14, 2010, 02:21:30 am »
Oh, if thats the case, its much easier then I expected :)
I already gave my app internet permissions. (to stream the locations of some 3d objects to the field of view).

Thanks.

34
Support / Possibly to download/display a mesh at runtime?
« on: July 13, 2010, 05:00:02 pm »
Is it possible to download a mesh (say, OBJ or 3DS) at runtime and use this in a scene?

I assume you'd have to pre-download and then use it as a input-stream for Loader.load3DS, but I have no idea how to do this, or if its even possible.

Sorry if this has been asked before, btw, I tried searching but couldn't see anything.
Thanks,
Thomas

35
pritom057 - is that my code your using? What variables did you feed into RTmp, I, grav and mag?

In the end I solved my problem with the following code;

Code: [Select]
switch (s_ev.sensor.getType()) {
        case Sensor.TYPE_ACCELEROMETER:
System.arraycopy(s_ev.values, 0, mGravs, 0, 3);
break;
        case Sensor.TYPE_MAGNETIC_FIELD:
         System.arraycopy(s_ev.values, 0, mGeoMags, 0, 3);
         break;
        default:
         return;
        }
        
 
        
        if (SensorManager.getRotationMatrix(mRotationM, null, mGravs, mGeoMags)){
//              Rotate to the camera's line of view (Y axis along the camera's axis)
                SensorManager.remapCoordinateSystem(mRotationM, SensorManager.AXIS_X, SensorManager.AXIS_Z, mRemapedRotationM);
                SensorManager.getOrientation(mRemapedRotationM, mOrientation);
                
                SimpleVector cameraVector = new SimpleVector();
                cameraVector.x = mOrientation[1];
                cameraVector.y = mOrientation[2];
                cameraVector.z = mOrientation[0];
                
                myworld.setCameraOrientation(cameraVector);
        }
      

setCameraOrientation() leads too;

Code: [Select]

public void setCameraOrientation(SimpleVector xyzAngles)
{


Camera worldcam = world.getCamera();

worldcam.getBack().setIdentity();

float Z = xyzAngles.z;
float Y = xyzAngles.y;
float X = xyzAngles.x;

worldcam.rotateCameraAxis(new SimpleVector(0,1,0), -Z);
worldcam.rotateCameraAxis(new SimpleVector(1,0,0), X);
worldcam.rotateCameraAxis(new SimpleVector(0,0,1), -Y);

}

I still think the setBack() method should be possible, and quicker too, but this way at least works.


36
Support / Re: Version updates!
« on: June 27, 2010, 04:24:10 pm »
Great work :)

37
Ok, I decided to give this another go, and I'm determined to get it right :)
I'm going to go step by step this time and be as methodical as possible.

I'm currently just bliting a rotation matrix onto the screen.
The source of which is "RT" from;

SensorManager.getRotationMatrix(Rt, I, accels, mags);

Where accels and mags are from the sensors.

Question;

How often should this update? It seems to be far too slow to be any use.
I mean, once every 2-3 seconds it gives a new matrix out, even though its triggered hundreds of times inbetween.

Does anyone successfully use getRotationMatrix from here? What speeds does it update? I'm using a HTC Legend, Android 2.1.

38
Not really, if I can get my system working, Treasure hunts will be possible :)

39
Support / Re: Version updates!
« on: June 02, 2010, 06:47:03 pm »
Nice work :)

40
Its basically;

Code: [Select]

SensorManager.getRotationMatrix(Rt, I, accels, mags);

Matrix tempR = new Matrix();

tempR.setRow(0, Rt[0], Rt[1], Rt[2],0);
tempR.setRow(1, Rt[3], Rt[4], Rt[5],0);
tempR.setRow(2, Rt[6], Rt[7], Rt[8],0);
tempR.setRow(3, 0, 0, 0,1);


tempR.rotateX((float)Math.PI);

arView.setCameraOrentation(tempR);

Is this correct?
Rt[] is supposed to be a 3x3 returned by the get RotationMatrix according to google's documentation. (I defined it as Rt[9]).


Something is still very wrong unfortunately. I haven't inverted it yet, but when laid flat on the table using the above code I get this;

The diagonal angle is odd no? (this is basically a simplified version of the demo scene)


[attachment deleted by admin]

41
I thought that at first but.....

Quote
Each matrix is returned either as a 3x3 or 4x4 row-major matrix depending on the length of the passed array:
If the array length is 16:
   /  M[ 0]   M[ 1]   M[ 2]   M[ 3]  \
   |  M[ 4]   M[ 5]   M[ 6]   M[ 7]  |
   |  M[ 8]   M[ 9]   M[10]   M[11]  |
   \  M[12]   M[13]   M[14]   M[15]  /
This matrix is ready to be used by OpenGL ES's glLoadMatrixf(float[], int).
Note that because OpenGL matrices are column-major matrices you must transpose the matrix before using it. However, since the matrix is a rotation matrix, its transpose is also its inverse, conveniently, it is often the inverse of the rotation that is needed for rendering; it can therefore be used with OpenGL ES directly.
Also note that the returned matrices always have this form:
   /  M[ 0]   M[ 1]   M[ 2]   0  \
   |  M[ 4]   M[ 5]   M[ 6]   0  |
   |  M[ 8]   M[ 9]   M[10]   0  |
   \      0       0       0   1  /
If the array length is 9:
   /  M[ 0]   M[ 1]   M[ 2]  \
   |  M[ 3]   M[ 4]   M[ 5]  |
   \  M[ 6]   M[ 7]   M[ 8]  /

so that's right isn't it?

I guess its the varying co-ordinate system causing the problem?

Also, where's the most efficient place to put the
world.getCamera().setBack(CameraMatrix);
?

Camera rotation is only every second or more at the moment, so I'm trying to work out what part of my code is slowing it down.



42
Theres also this code here which I've tried with a similar lack of success;
http://mysticlakesoftware.blogspot.com/2009/07/sensor-accelerometer-magnetics.html

This code features a filtering function, which is nice, but I still cant match the v
  • output to the Jpct camera.

Also this code seems very slow compared to the above.

43
Anyone know how to use the orientation sensors to set the JPCT camera to corrispond?

Ive been looking at the sourcecode of Mixare;
http://code.google.com/p/mixare/source/checkout
for guidelines.

The problem comes that they are using their own engine, and thus the rotations arnt in the needed format.

Heres what Ive tried;

Code: [Select]
@Override
public void onSensorChanged(SensorEvent evt) {
try
{


if (evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
grav[0] = evt.values[0];
grav[1] = evt.values[1];
grav[2] = evt.values[2];

arView.postInvalidate();
} else if (evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
mag[0] = evt.values[0];
mag[1] = evt.values[1];
mag[2] = evt.values[2];

arView.postInvalidate();
}

SensorManager.getRotationMatrix(RTmp, I, grav, mag);
//SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z, Rt);

Rt=RTmp;

tempR.setRow(0, Rt[0], Rt[1], Rt[2],0);
tempR.setRow(1, Rt[3], Rt[4], Rt[5],0);
tempR.setRow(2, Rt[6], Rt[7], Rt[8],0);
tempR.setRow(3, 0, 0, 0,1);


    Log.i("--", Rt[0] +" "+ Rt[1] +" "+ Rt[2]);
    Log.i("--", Rt[3] +" "+ Rt[4] +" "+ Rt[5]);
    Log.i("--", Rt[6] +" "+ Rt[7] +" "+ Rt[8]);
     
    arView.setCameraOrentation(tempR);


}
        catch (Exception ex)
        {
        Log.e("Sensor", "ProcessingError", ex);
        }
}


The function "setCameraOrentation" just leads to a

world.getCamera().setBack(RotMatrix);

Where RotMatrix is the Matrix passed to it.

What I'm not sure of is how Androids SensorManager.getRotationMatrix()  matrix corresponds to the JCPTs "setBack" matrix :-/

I know one is 3x3 and the other is 4x4...but I think I dealt with that correct, so I'm not sure whats wrong now :?

The jcpt camera moves on rotations, but clearly not correctly. (or any simple angular displacement).


44
Support / Re: How to get a texture from a FrameBuffer?
« on: May 23, 2010, 07:36:05 pm »
I can't verify a)...it works just fine in a test case of mine. Can you post the code snippet that you use to do this? In addition, make sure to call TextureManager.unload(...) for the old texture before replacing it, because otherwise, it will stay in GPU's memory forever. However, this shouldn't prevent the texture from changing.

I fixed the problem, it was a daft error of mine where the code I thought was being triggered wasn't.
Added the unload too, thanks for the advice.

Quote
b) is actually a feature of jPCT as it converts all black parts of a texture to transparent. If you don't want this, either use a color above #0f0f0f for the text or try new Texture(yourBitmap, true); so that the alpha channel isn't calculated based on the pixel data but on the channel that the bitmap contains. You just have to make sure that it doesn't contain one in your example. Another option is to leave everything as it is and call texture.removeAlpha() after creating the texture.

Bingo. That worked a charm.
I used the "true" flag as I will probably want to use my own alpha later.


45
Support / Re: How to get a texture from a FrameBuffer?
« on: May 18, 2010, 12:52:28 pm »
Sorry,The canvas solution works, as in, it appears on the object perfectly after that code is run.

However it has a few problems;

a) if I then trigger the same code again with a different string, the old texture remains on the object.
(this is where I tried "tm.replaceTexture("testText2", testtext);" rather then "addTexture" if the texture already had been put
on it once, but it had no effect).


b) The other problem is the texture comes out with the text being transparent, but on a white background. So you can see the camera view though the text itself;


paint.setColor(Color.BLACK); doesn't seem to help.







[attachment deleted by admin]

Pages: 1 2 [3] 4