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

Pages: [1] 2
1
Support / Re: jPCT benchmark?
« on: April 03, 2009, 04:28:34 pm »
Impressive!

Simple and fast  8)

2
Support / Re: Object3D, matrices and transformations
« on: April 03, 2009, 03:13:48 pm »
Ok, I will try to seperate the camera into two matrices then.

Again thanks for the replies. Allways great to get advice from experienced nerds :)


Edit: Worked like a charm now. Objects and the camera got 2 matrices now and they are multiplied once per frame. Time to clean my code now :D

3
Support / Re: Object3D, matrices and transformations
« on: April 03, 2009, 03:05:08 pm »
My camera-rotation works before I invert (just have to rotateX(-theta) to rotate the right way). But when I try to invert it (by transposing the upper left 3x3 of the matrix I get some strange results). I (trying at least) to have both the translation and the rotation in one matrix.

In the Matrix-class I got a function which returns a FloatBuffer with the inverted matrix:
Code: [Select]
public FloatBuffer getInvertedBuffer() {
    Matrix temp = new Matrix(this);        // Creates a temporary matrix with this matrix' values.

    temp.invertTranslation();                // This function just negate the values in m3, m7 and m11 (the translation)
    temp.transpose3x3();                    // This function transposes the upper left 3x3 of the matrix

    return temp.getBuffer();
}

I have tested the transpose3x3-functions and it works fine. But doesn't seem like the getInvertedBuffer-functions gives me the right values. Really want this to work since pre-negating all values in all functions of the isn't elegant :P

4
Support / Re: Object3D, matrices and transformations
« on: April 03, 2009, 12:02:05 pm »
Thanks again for all the help.

Now I have a working Camera class and I can rotate all objects around their own axis. Just one quick questing about the Camera-class.

Since the transformation of the Camera is applied inverted to the Scene, should add a Invert-matrix method and use it? Inverting matrices seems like a time (and CPU) stealer. Guess the best way is just to create functions that invert the values beforehand e.g.:
Code: [Select]
public class Camera {
private Matrix transformation;

...

public void rotateX(float theta) {
    transformation.rotateX(-theta);
}


public void translate(Vector3D v) {
    v.mul(-1.0f);
    transformation.translate(v);
}

5
Support / Re: Object3D, matrices and transformations
« on: April 02, 2009, 11:53:40 pm »
I am working on the rotations now. Not quite sure how to implement it though. Tried multiplying the rotation matrix and translation matrix but got some strange results :D

Do jPCT use matrices for camera-movement also? I thought it was just to -translate and -rotate the camera values first and everything was OK, but doesn't seem like it. Haven't started reading about quaternions yet :/

Edit: fixed the rotation of objects now (I use just one Matrix in the Object3D-class which handles both translation and rotation, and objects are translated -x, -y, -z before rotation and translated back afterwards to rotate around its own axis). Just have to get the camera class to work now, and some getXAxis-like function so that translation from the objects rotation is trivial.

6
Support / Re: Object3D, matrices and transformations
« on: April 02, 2009, 10:41:22 pm »
Update: No I think I really got it (the translation bit at least).

The rendering "pipe-line" should look something like this (the [C] etc. just shows what Matrices are on the stack).

Code: [Select]
glLoadTransposeMatrix(CameraMatrix);               [C]
glPushMatrix();                                               [C, C]

....

// Object:

glMultTransposeMatrix(ObjectMatrix);                 [CO, C ]
glPushMatrix();                                               [CO, CO, C]


// Child

glMultTransposeMatrix(ChildMatrix);            [COK, CO, C]
           


I also found the glLoadTransposeMatrix and glMultTransposeMatrix (in OpenGL 1.3) which takes row-ordered matrices as arguments (guess OpenGL's transpose-function is as good as mine :P ).

7
Support / Re: Object3D, matrices and transformations
« on: April 02, 2009, 06:03:39 pm »
Ok, thanks. I'll look into it. Just discovered the glLoadMatrix-function and added a transpose and toGLFloatBuffer-function to my Matrix class :D

So I guess the rendering will look something like this:
Code: [Select]
public void renderScene(Scene scene) {

glPushMatrix();
    // the Camera-transformation will be inverted
    glLoadMatrix(scene.getCamera().toBuffer());
        glPushMatrix();
               // Iterate through objects in the scene
               glLoadMatrix(obj.getTranslation().toBuffer));
               drawObject(obj);

               // If the object has children, iterate through them
               glPushMatrix();
                    glLoadMatrix(child.getTranslation().toBuffer));
                    drawObject(child)
               glPopMatrix();
        glPopMatrix();

glPopMatrix();


}

8
Support / Re: Object3D, matrices and transformations
« on: April 02, 2009, 04:22:05 pm »
OK, but how is the rotationMatrix actually used?

I guess jPCT uses it own type of rendering-pipeline, but I am trying to get it to work with OpenGL only.

My "rendering" class works like this:
render scene -> render object (translates to the objects translationMatrix) -> render polygon-groups -> render polygons.

I want to be able to rotate an object around it own axis and be able to translate in a direction relative to the objects rotation, much like:
Code: [Select]
Vector v = obj.getXAxis();
v.mul(2.0f);
obj.translate(v);

9
Support / Re: Object3D, matrices and transformations
« on: April 02, 2009, 03:53:15 pm »
Now I kind of realized that the location of an object is in the translationMatrix, and translating the object is then the trivial task of translating the translationMatrix. So the position (relative to its origin) would be the m3, m7 and m11 in a row-ordered matrix.

Should every polygon have its own translationMatrix? E.g. if I want to scale the polygon vertices and not just use glScale().

And how should use the rotationMatrix of the object (e.g. with OpenGL glRotatef). 

I know that these questions may seem odd, but this subject it (currently) a few inches over my head, and I haven't found any example code :)


10
Support / Object3D, matrices and transformations
« on: April 02, 2009, 03:20:52 pm »
Hi, I have some questions that maybe are more related to game engine design than jPCt, but anyway :)

I am currently working on a little 3D-engine in Java using LWJGL just for learning purposes, and the last couple of days I have been reading a lot about 3D-mathematics. I have some questions on how jPCT has implemented translation/rotation-matrices.

I got a working Matrix-class to handle basic 4x4-matrix operations and a simple Vector-class. I've built a little polygon-system on top of that, so currently I can load OBJ-files.

My question is how to implement the translation- and rotation-matrices in my "Object3D"-class. I got functions in my Matrix class for transforming the Matrix (translate, rotate XYZ).

Should I store the location in a Vector and have a translationMatrix in the Object-class, and have a Object3D.translate-function something like this:

Code: [Select]
public void translate(Vector3D trans) {
    this.translationMatrix.translate(trans);
    this.location.mul(translationMatrix);
}

I am very green on this subject and I haven't found any good books/resouces for this (found A LOT of books on Matrices and 3D-math but none about how you actually implements them in your program). So I just wondered how you experienced programmers would do it  ;D


11
Support / Server side collision detection
« on: August 23, 2008, 01:45:56 am »
Hi

I know this is kinda off topic, but it is possible to use jPCT to implement server-side collision detection? Or do I have to actually have a window rendering the world to do it? :P

I am a totally n00b when it comes to multiplayer-programming, but it seems like a good idea to let the collision detection be server side because of client perfomance/security.

12
Support / Re: Texture-coordinates from Blender
« on: August 17, 2008, 02:47:44 pm »
Thanks Fireside! :)

Instead of using UV/Image-editor, I just added a texture to the material which didn't work. With TexFace it worked just fine :)

13
Support / Re: Texture-coordinates from Blender
« on: August 16, 2008, 06:23:56 pm »
Thanks, it worked perfectly!

I'll try to get the textures working now. Thanks for all the replies.

14
Support / Re: Texture-coordinates from Blender
« on: August 16, 2008, 05:42:27 pm »
I have just applied a texture to a object in Blender and sat the X-repeat and Y-repeat values. I'll try and play around some more.

The other question:
I want to be able to get a instance of the Entity-class from the Object3D.

Code: [Select]
// In the class definition
public class Entity extends Object3D { ...

// In the game
...
private Entity enemy = new Entity();
...


// In the mouse handling
...
Object3D selected_object = world.getObject(Interact2D.getObjectID(result));

// Now I want to get the Entity-instance (e.g. enemy) from the selected_object

15
Support / Re: Texture-coordinates from Blender
« on: August 16, 2008, 03:00:58 pm »
Strange, it works here :S

I can describe it though: the ground is solid green with a lot of noise. When I move the camera the noise flickers (like a TV without signal :P), but when the camera stands still it takes a few seconds the flickering stops.



Off-topic:
In my test game I have this class diagram:
Object3D
- Entity
-- DynamicEntity
--- Player

I have used Interact2D to select the object, but it is possible to get the Player-instance from Object3D? Sorry for my poor java-knowledge.

Pages: [1] 2