Android Question jPCT-AE Library Problem

stopa

New Member
Licensed User
Longtime User
Hello,
I'm working with my project and I have one problem which I couldn't fix today. I'm sending values of angles from accelerometer via Bluetooth to my mobile device and I would like to rotate my 3D model like I rotate the accelerometer.
Everything was good when I was using OpenGL library, but I chose jPCT-AE, because it supports exporting from CAD models.
Problem with I have it's that my 3D model rotates on and on, continously. I was trying with few ways but I don't have idea.

There's link to library:
http://www.b4x.com/android/forum/threads/jpct-ae-3d-engine-wrapper.29546/#content

At the link you have example 'helloworld', I added one line to this code. This example shows where is my problem:
B4X:
Sub Jpct_SurfaceChanged(Width As Int, Height As Int)

         Cube.RotateX(10) 'MY CODE
   
        ' set our framebuffer. pass a gl context, width and height
        'fb.Initialize1(glsv.glContext.pContext, glsv.Width, glsv.Height)
        FrameBuffer.Initialize1(Jpct.glContext, Width, Height)
       
        ' Initialize the world and lighting it
        World.Initialize
        World.setAmbientLight(20, 20, 20)
       
        ' Primitives -> Mesh
        Cube.Initialize3(Primitives.getCube(10))
        Cube.calcTextureWrapSpherical
       
        ' give or model a look with texture
        ' notice we used the name we gave 
        ' from the TextureManager.
        Cube.Texture = "cubetexture"
       
        ' clean the mesh
        Cube.strip
       
        ' build it for our world
        Cube.build
       
        'add it to the wrld
        World.addObject(Cube)
       
        'now we deal with the camera
        Camera.Initialize
       
        ' we assign the world's camera to our own camera
        Camera= World.Camera
       
        ' movw the camera out 50 unit, and up 25 unit
        Camera.moveCamera(Camera.CAMERA_MOVEOUT, 50)
        Camera.moveCamera(Camera.CAMERA_MOVEUP,25)
       
        ' let the camera look at our cube's center
        Camera.lookAt(Cube.TransformedCenter)
       
        ' we need to get the position of the model 
        ' so we can place the Sun above it 100 unit
        ' away.
        Vectore.Initialize4(Cube.TransformedCenter)
        Vectore.y = -100
        Vectore.z = -100
       
        ' now we Initialize a sun and set it above our model
        ' set the sun's rgb Intensity to 100.
        Sun.Initialize(World)
        Sun.Position = Vectore
        Sun.setIntensity2(100, 100, 100)
       
        ' clean any unused/un-needed memory
        MemHelper.compact
       
        'hide the dialog.
        ProgressDialogHide 
End Sub
 

John.E

Member
Licensed User
Longtime User
Just a thought. Can you not recover the sensor data in the 'Jpct_SurfaceTouch' sub and update the rotation of the cube there? As it stands you are trying to set a value on an uninitialised structure!
 
Upvote 0
Top