Author Topic: some effects  (Read 6435 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
some effects
« on: August 17, 2010, 06:43:25 am »
how would you implement these effects ? i've also written my ideas but maybe there are better ways

* gravity tile which makes things heavier then they are. i planned to use a billboarded transparent plane over the tile with a texture with small downward arrows on it. then change the UV coordinates in time such that arrows move downwards.
* lava (or similar) tile which kills the player. some particles maybe spawn over it but this may be a performace killer if number of lava tiles increase
* teleport or portal tile: billboarded plane with a texture like the shield in robombs. uv coordinates can be changed to provide some motion
* exit tile: with glow effect

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #1 on: August 17, 2010, 07:45:03 am »
Quote
* gravity tile which makes things heavier then they are. i planned to use a billboarded transparent plane over the tile with a texture with small downward arrows on it. then change the UV coordinates in time such that arrows move downwards.
Sounds fine to me. Instead of changing u/v, you could simply change the position of that quad. That should be cheaper on Android. Another option is to use a special texture matrix, but that doesn't work reliable on my phone, so it might fail as well on others...
Quote
* lava (or similar) tile which kills the player. some particles maybe spawn over it but this may be a performace killer if number of lava tiles increase
I don't see a problem as long as the amount of particles is small enough...i.e. a level full of lava tiles might cause some trouble.
Quote
* teleport or portal tile: billboarded plane with a texture like the shield in robombs. uv coordinates can be changed to provide some motion
In Robombs, it's a rotating sphere (at least until some ATI driver bug kicks in and makes it a rotating mess... ;)). Billboards might look good too.
Quote
* exit tile: with glow effect
Yes, just put a "glow quad" on top of it.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #2 on: August 17, 2010, 03:56:55 pm »
mm thanks.

Quote
Quote
* gravity tile which makes things heavier then they are. i planned to use a billboarded transparent plane over the tile with a texture with small downward arrows on it. then change the UV coordinates in time such that arrows move downwards.
Sounds fine to me. Instead of changing u/v, you could simply change the position of that quad. That should be cheaper on Android. Another option is to use a special texture matrix, but that doesn't work reliable on my phone, so it might fail as well on others...
but how can i make the movement continuous if i move the plane. it will move downwards and suddenly jump to upper position.
can u please say more about that texture matrix ?

Quote
In Robombs, it's a rotating sphere (at least until some ATI driver bug kicks in and makes it a rotating mess... ;)).
yes, i've looked into Robombs code. btw, i've also tried your environment mapped diamonds on N1. it looks gray at some distance and when come closer it works. i may send screenshots if you wish

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #3 on: August 17, 2010, 10:04:47 pm »
Quote
but how can i make the movement continuous if i move the plane. it will move downwards and suddenly jump to upper position.
can u please say more about that texture matrix ?
Yes, i won't be continuous that way. Might look ok though. A texture matrix is a transformation matrix for u/v coordinates. You can set one on an Object3D and all u/v-coordinates of that object will be transformed (i.e. translated, scaled, rotated...whatever) by that matrix. The problem is, that this doesn't work reliable at least on my Galaxy. Changing the texture matrix sometimes has no effect, sometimes works fine and sometimes affects other objects. I consider this to be a driver and/or hardware bug.

Quote
yes, i've looked into Robombs code. btw, i've also tried your environment mapped diamonds on N1. it looks gray at some distance and when come closer it works. i may send screenshots if you wish
I know. That's because the texture coordinate for calculation formular isn't correct yet. Problem here is, that i have to device that can handle this correctly because the upper problem applies here too.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #4 on: August 18, 2010, 04:09:35 am »
Quote
i planned to use a billboarded transparent plane over the tile with a texture with small downward arrows on it. then change the UV coordinates in time such that arrows move downwards.

billboarding such a tall plane didnt prove very useful. the plane is placed over tile, so when camera moves around plane rotates accordingly and does not feel like it's over tile. as seen in the screenshot:


setting rotation pivot to bottom center somehow helped but still far from perfect. i guess i need a plane which always remains vertical and faces camera by only rotating about y axis. is there an easy way of this?

i've tried shifting UV coordinates, it works on desktop version but i couldnt make it run on AE. i've also tried calling touch(), any ideas?

seems as the only way of shifting UV coordinates is via PolygonManager.setPolygonTexture(int, TextureInfo). the problem here is, we cannot change previously set fields of TextureInfo, so we need to create a new TextureInfo each time. making TextureInfo mutable or providing a method with primitive types may help.

thanks

Offline brianbaillargeon

  • byte
  • *
  • Posts: 6
    • View Profile
Re: some effects
« Reply #5 on: August 18, 2010, 05:38:47 am »
Quote
i guess i need a plane which always remains vertical and faces camera by only rotating about y axis. is there an easy way of this?

Here's a little trick I discovered that avoids a lot of geometric thinking.

Code: [Select]
//make a temporary camera
Camera backupCam=world.getCamera();
world.newCamera();
Camera newCam=world.getCamera();
//put the temporary camera at the plane's level and facing the plane
newCam.setPosition(backupCam.getPosition().x,yourPlane.getTransformedCenter().y,backupCam.getPosition().z);
newCam.lookAt(yourPlane.getTransmormedCenter());
yourPlane.align(newCam);  //the plane will face the temporary camera

//restore the original camera
world.setCameraTo(backupCam);

I had something like this working a few days ago, but I erased the code. I'm not sure if the above is exactly what I did, but I think it is. It should work. Hope it helps ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #6 on: August 18, 2010, 07:13:50 am »
For changing u/v in AE, you have to use a variant of build to tell the engine that these object's u/v-coordinates are going to be modified: http://www.jpct.net/jpct-ae/download/alpha/doc/com/threed/jpct/Object3D.html#build(boolean).

I understand the need for a mutable TextureInfo...i'll add that.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #7 on: August 18, 2010, 07:52:55 am »
@brian that's a good idea :) but it's also a bit expensive for android i'm afraid. but i believe it can be refined

@egon it didnt helped. i suppose i should call build(false). i've also tried the other way

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #8 on: August 18, 2010, 07:57:07 am »
Have you stripped the object in question? In that case, setting new u/vs doesn't work and simply returns doing nothing at all.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #9 on: August 18, 2010, 07:58:49 am »
nope. same code works at desktop jPCT

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #10 on: August 18, 2010, 08:02:34 am »
Can you post some log output that shows the compilation steps?

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #11 on: August 18, 2010, 08:06:35 am »
sure..

Code: [Select]
I/jPCT-AE ( 4586): [ 1282111476467 ] - WARNING: Object object4 hasn't been build yet. Forcing build()!
I/jPCT-AE ( 4586): Subobject of object 2/object4 compiled to flat fixed point data using 1632 vertices in 16ms!
I/jPCT-AE ( 4586): Subobject of object 2/object4 compiled to flat fixed point data using 48 vertices in 0ms!
I/jPCT-AE ( 4586): Subobject of object 2/object4 compiled to flat fixed point data using 48 vertices in 3ms!
I/jPCT-AE ( 4586): Subobject of object 2/object4 compiled to flat fixed point data using 48 vertices in 0ms!
I/jPCT-AE ( 4586): Object 2/object4 compiled to 4 subobjects in 81ms!
I/jPCT-AE ( 4586): Subobject of object 4/object6 compiled to flat fixed point data using 6 vertices in 0ms!
I/jPCT-AE ( 4586): Object 4/object6 compiled to 1 subobjects in 1ms!
I/jPCT-AE ( 4586): [ 1282111476552 ] - WARNING: Object object8 hasn't been build yet. Forcing build()!
I/jPCT-AE ( 4586): Subobject of object 6/object8 compiled to flat fixed point data using 6 vertices in 1ms!
I/jPCT-AE ( 4586): Object 6/object8 compiled to 1 subobjects in 1ms!
I/jPCT-AE ( 4586): [ 1282111476554 ] - WARNING: Object GeoSphere0_jPCT7 hasn't been build yet. Forcing build()!
I/jPCT-AE ( 4586): Subobject of object 7/GeoSphere0_jPCT7 compiled to flat fixed point data using 240 vertices in 1ms!
I/jPCT-AE ( 4586): Object 7/GeoSphere0_jPCT7 compiled to 1 subobjects in 3ms!
I/jPCT-AE ( 4586): Subobject of object 8/object10 compiled to flat fixed point data using 6 vertices in 0ms!
I/jPCT-AE ( 4586): Object 8/object10 compiled to 1 subobjects in 1ms!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #12 on: August 18, 2010, 08:07:25 am »
Opps...try to add a dummy vertex controller or animation to it before calling build(<boolean>) and see if that helps...

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: some effects
« Reply #13 on: August 18, 2010, 08:13:28 am »
yeap, it helped ;D i had tried setting a dummy vertex controller but it was after build(..). this way it works

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: some effects
« Reply #14 on: August 18, 2010, 08:19:09 am »
Ok, i'll correct this behaviour...i thought that i already had done that...but obviously not... ???