Please login or register.

Login with username, password and session length
Pages: [1] 2 3 ... 10
 on: Today at 03:53:50 
Started by Spytrycer - Last post by Spytrycer
Ok, thats great help, I implemented the Code for the Positioning and it works perfectly!

And i dont think i want an Arcball Camera, im sorry, i might have spoken too wierd :)

What i want the Camera to do is to follow around the Player in every Movement.
The Player moves like a FreeCamera and the Camera follows behind.
What i dont want is to just move the Camera in the Function i call the Playermovement, i want the camera to move BASED on the players position and Rotation.

And that works just fine, at least for the Rotation. Just the Translation doesnt want to work.

GIF of Movement Example

As you see in the Gif, its all working, but the Camera class is not moving.
Or to be precise, it is moving but its being reset everytime, which makes this wobbling and glitching kinda thing.

As i mentioned earlier, i tried a translation of just 1,1,1 and it was doing this glitching back and forth the whole time.

I dont know why it is not translating the Cameras position.
I checked the Values i give into the translation, i even checked if that changes the position i get with your method and the Position doesnt seem to change.

For Position.Z for example it just takes the Value of the Differential Change.
The System.out.print for position.z looks like this:
Code: [Select]

Looks pretty much just like
Code: [Select]
dt * player.linearVel.x
Here is my viewMatrix:

Code: [Select]
public void move(double delta)

float dt = (float)delta;

//linearVel.fma(dt, linearAcc);

    //angularVel.fma(dt, angularAcc);
this.angularVel.x = player.angularVel.x;
    this.angularVel.y = -player.angularVel.y;
    this.angularVel.z = player.angularVel.z;

this.Rotation.x += dt*angularVel.x;
    this.Rotation.y += dt*angularVel.y;
    this.Rotation.z += dt*angularVel.z;
    linearVel.x = dt * player.linearVel.x;
    linearVel.y = dt * player.linearVel.y;
    linearVel.z = dt * player.linearVel.z;

    .translateLocal(linearVel.x,linearVel.y, linearVel.z);

    viewMatrix.getTranslation(position); // <- store entity's position


And BTW, is there a way to do
Code: [Select]
With the Entities or cameras Rotation too?

 on: April 23, 2017, 19:42:28 
Started by bcbradle - Last post by bcbradle
Sweet thanks for all your help, vulkan in clojure is going to rock :)

 on: April 23, 2017, 19:37:04 
Started by bcbradle - Last post by spasi
Raw pointers are considered "unsafe" in LWJGL, so methods that accept them are prefixed with 'n'. The method you're looking for is MemoryUtil.nmemFree(long). Example:

Code: [Select]
PointerBuffer pp = ...;
for ( int i = 0; i < pp.remaining(); i++ ) {

I don't know how memory allocations are done on the native side in lwjgl

The MemoryUtil methods directly call the corresponding method of the native memory allocator. The only utility they have is that the memory allocator is configurable; you can try another implementation without changing your program. By default, if the bindings are available, jemalloc will be used as the memory allocator. Otherwise, the default system allocator is used. I would like to try rpmalloc soon, it'd be nice to have a third option if it's competitive. Btw, you also have the option of using one allocator via MemoryUtil and another by using the corresponding bindings directly (via org.lwjgl.system.libc.LibCStdlib and org.lwjgl.system.jemalloc.*).

 on: April 23, 2017, 19:18:23 
Started by bcbradle - Last post by bcbradle
Yes, only the pointer is necessary to free an allocation.

how would you do it then?

I mean i know how to free a PointerBuffer instance foo using foo.free(), but what about all the buffers the PointerBuffer instance foo contains?

foo.get() returns a long (presumably the address of the current buffer stored), but can you use that to free anything? I'm looking inside MemoryUtil but can't find anything that would allow me to free an arbitrary address.

I was thinking of maybe doing foo.getByteBuffer().free(), but there isn't any such method (only getByteBuffer(size)). I would have to know the size of the current buffer in bytes in order to free it this way.

It seems kind of odd though. I don't know how memory allocations are done on the native side in lwjgl, but the c function "free" doesn't require a size, only an address (assuming it was previously allocated with malloc, calloc or realloc). So I feel it would be strange if it weren't possible to free memory with just an address in lwjgl, and that is why I'm asking.

 on: April 23, 2017, 19:02:35 
Started by bcbradle - Last post by spasi
Yes, only the pointer is necessary to free an allocation.

 on: April 23, 2017, 16:08:44 
Started by bcbradle - Last post by bcbradle
Specifically, without knowing their lengths.

Basically I want to be able to free the pointer buffer and all the things pointed to by it given only the pointer buffer instance.

 on: April 23, 2017, 12:22:06 
Started by Spytrycer - Last post by Kai
You can separate the translation of your entity from its rotation and compose both together when building the final model transformation matrix. However, when you still want to move an entity along its own local "forward"/"right"/"up" axes, then you need to compute these vectors in world-space first.
Instead, an easier way is to keep everything like it is now, and compute the origin of the entity in world-space via:
Code: [Select]
Matrix4f model = ...; // <- the model transformation matrix of the entity
Vector3f position = new Vector3f(); // <- position will be stored in here
model.getTranslation(position); // <- store entity's position

It sounds that you want to have an "arcball" camera. Is that right?
If that is the case, then have a look at: https://github.com/JOML-CI/joml-camera/blob/master/src/org/joml/camera/ArcBallCamera.java

The important part of it is the order of transformations in the viewMatrix() method:

You can throw all that ArcRotor/ScalarMover stuff out, as it is merely used to "smoothen" the rotation and translation of the arcball camera over time.

 on: April 23, 2017, 06:20:22 
Started by bcbradle - Last post by spasi
The VkClearColorValue class does not decide anything. Like all struct classes, it's a wrapper over a pointer address + byte size. Because it's a union, the offset of all 3 members is zero and the byte size is 4 x 4 bytes (i.e. 16 bytes total, not 48).

How those bytes are interpreted is specified by Vulkan; it depends on the format of the image or attachment. The getters and setters with different types provide type-safety over the raw bytes. You can use those that match the format of the image or attachment that you need to clear to a specific color. Using value.float32(2, 3f) and value.int32(2, 3) will both write 4 bytes at offset 8 in the struct, but obviously different bytes will be written. There is no difference between int32 and uint32 in Java, but because of the properties of two's complement binary representation, you can use a Java int as a uint32_t.

 on: April 23, 2017, 04:16:18 
Started by Spytrycer - Last post by Spytrycer
Thank you alot!
I understand my problem now way more.

I implemented the Code into mine and changed it a little bit, because i didnt like the Entity to move continuously and faster and faster when accelerated, or i implemented the code wrong at first :).

But i did keep the integration of differentials with delta that solves the Rotation problem i had, thanks alot for that!

Im now struggeling with the Coordinates of an Entity.
I want an Entity to have specified coordinates in the World, that i can refer to and change in order to chase it with the Camera(which right now doesnt work) and to set to a specific value if nessesary.

Here is my implementation, maybe you can help me getting to a solution and look over my Code to see if i implemented correctly:

(And Yes, i know casting a Double into a Float is horribly inaccurate and can be terrible, i intend to go over these castings later on, now i want to get this to work)

Code: [Select]
public void move(double delta)
float dt = (float)delta;

//linearVel.fma(dt, linearAcc);

    //angularVel.fma(dt, angularAcc);

    this.position.x += dt*linearVel.x;
    this.position.y += dt*linearVel.y;
    this.position.z += dt*linearVel.z;

    transformationMatrix.translate( dt*linearVel.x, dt*linearVel.y, dt*linearVel.z);

Thats the changed Move Method. Im now not calculation in it, instead im just changing the transformationMatrix which i have made part of the Entity Class in general, terrible solution, but right now i want to get it to work.

Code: [Select]
public void move(double delta)

float dt = (float)delta;

    //linearVel.fma(dt, linearAcc);

    //angularVel.fma(dt, angularAcc);

    this.angularVel.x = player.angularVel.x;
    this.angularVel.y = -player.angularVel.y;
    this.angularVel.z = player.angularVel.z;

    this.pitch += dt*angularVel.x;
    this.yaw += dt*angularVel.y;
    this.roll += dt*angularVel.z;

    linearVel.x = player.linearVel.x;
    linearVel.y = player.linearVel.y;
    linearVel.z = player.linearVel.z;
    position.x += dt*linearVel.x;
    position.y += dt*linearVel.y;
    position.z += dt*linearVel.z;

    .translateLocal(-dt*linearVel.x, -dt*linearVel.y, -dt*linearVel.z);

The Camera is the Problem.
I want it to tag along the Player, i try that by giving it the players linearVelocity.
The Camera does take this and with my code the Position changes to, but the Cameras position doesnt, or at least not really. It is kind of vibrating in place.
I tried to set the translation to:
Code: [Select]
.translateLocal(1,1,1);and it turns out that it DOES move it that way, but it seems to be returned to its original position everytime.

I also spawned in a referenceEntity that im not moving and that proves this theory. The Camera is trying to move but it seems like it Cant for some reason.
What am i doing wrong??

 on: April 23, 2017, 03:18:22 
Started by bcbradle - Last post by bcbradle
The vulkan specification states that VkClearColorValue is a union type between float, int, and unsigned int arrays.

Java doesn't have a union type so it can't expose that in the api. The lwjgl VkClearColorValue class offers getters and setters for each of float, int and unsigned int arrays.

How does this class decide which field to use (which field is used natively) if they have all been set?

Pages: [1] 2 3 ... 10