Main Menu
Menu

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.

Show posts Menu

Messages - coersum

#1
Support / Re: Moving an object3D around
October 22, 2012, 12:22:03 AM
thank you so much!! I think I actually tried that but I was having so much trouble going through the doc (not the doc's fault), that I might have had something else added to that which made it not work. Got the Chase-Camera to work finding info on this thread in case someone is looking for it: http://www.jpct.net/forum2/index.php/topic,2588.msg19139.html#msg19139

#2
Support / Re: Moving an object3D around
October 21, 2012, 08:49:19 PM
Could you help me on how to do that by chance ?  just can't get anything to work. Been trying to find examples of 3d objects being moved around, with physics etc, I just can't find much sadly.
#3
Support / Moving an object3D around
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
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)
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):
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.
#4
Support / way for a HUD
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:
mGLView = new GLSurfaceView(getApplication());
with

setContentView(R.layout.activity_main); //or whatever the layout you want to use
mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);


remove
setContentView(mGLView);

now in your layout copy/paste:
<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.