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

Pages: [1]
1
Support / Moving an object3D around
« on: October 19, 2012, 06:25:48 pm »
Hi,

I know this has been talked about before and I read quite a bit about in forum but nothing seems to work.
What I have is:

1. I load my serialized objects (ground and quickly made robot, just a meshes with textures) and everything works fine
Code: [Select]
mesh_plaza = Loader.loadSerializedObject(res.openRawResource(R.raw.plaza4s));
mesh_plaza.setScale(30);
mesh_plaza.setTexture("text_plaza");
mesh_plaza.translate(0, -20, 0);
world.addObject(mesh_plaza);
mesh_plaza.strip();

mesh_robot = Loader.loadSerializedObject(res.openRawResource(R.raw.robots));
mesh_robot.setScale(20);
mesh_robot.setTexture("text_robot");
mesh_robot.translate(0, -35, 0);
mesh_robot.setName("airob");
mesh_robot.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
world.addObject(mesh_robot);
mesh_robot.strip();

2. In onTouchEvent I set moveSpeed and touchTurn variables (i use a dpad I made for it, so moveSpeed is between -2 and +2, 0 being center of my directional-pad)

3. In the onDrawFrame for turning: (that works GREAT, the robot turns on the it's Y axis)
Code: [Select]
if (touchTurn != 0) {
//world.getCamera().rotateY(touchTurn);
mesh_robot.rotateY(touchTurn);
}
4. Still in onDrawFrame, for moving I tried quite a few things and found in forum that using the object's getZAxis would give me its current directionto which then I just add to z (or x depending on how it was modeled):
Code: [Select]
if (moveSpeed != 0) {
SimpleVector robot_turn = mesh_robot.getZAxis();
mesh_robot.translate(robot_turn.x, robot_turn.y, robot_turn.z+moveSpeed);
}
But this gives some very weird results. First, without turning, the robot will go back and forth (his front is initially positioned on the Z axis) but once I start turning all hell breaks loose.
he will often just move sidewise-forward not only in one direction.

Any help or hint would be awesome.
Thank you
PS: next I am going to try to get the camera to follow, get the robot to not go through walls, add gravity so the robot can jump etc...so much to learn.

2
Support / way for a HUD
« on: October 13, 2012, 06:25:22 am »
Hi,

I found this online and figured I'd share it, I just started programing using JPCT-AE and having limited knowledge in java, I experiment a lot.
I wanted to add a HUD of some sort but didn't understand how to "blit" as I read here and there so I searched and found this, please let me know if this will bug or slow down the device:

in HelloWorld demo:

replace:
Code: [Select]
mGLView = new GLSurfaceView(getApplication());with
Code: [Select]
setContentView(R.layout.activity_main); //or whatever the layout you want to use
mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);

remove
Code: [Select]
setContentView(mGLView);
now in your layout copy/paste:
Code: [Select]
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/graphics_frameLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <android.opengl.GLSurfaceView
        android:id="@+id/graphics_glsurfaceview1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </android.opengl.GLSurfaceView>
    <LinearLayout
        android:layout_height="fill_parent"
        android:id="@+id/inventory"
        android:gravity="center"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:visibility="gone">
    </LinearLayout>

    <LinearLayout
        android:id="@+id/HUD"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|bottom"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon" />

    </LinearLayout>
</FrameLayout>

After that play around with placements.

Source where I found it and what it does (2 overlays, 1 for inventory and 1 for hud).
http://stackoverflow.com/questions/8128896/mixing-android-views-and-glsurfaceview


Doing this will keep you from having to blit or making your own opengl, however I don't know enough to know if it will have any undesirable consequences, please let me know.

Pages: [1]