Author Topic: Not able load md2 file with size 358 KB  (Read 2409 times)

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Not able load md2 file with size 358 KB
« on: September 15, 2010, 02:52:14 pm »
Hi,

          I tried to load a md2 file with size 358 kb but its going out of memory.

Is there any max limit for the jPCT engine for rendering md2 files??

Can anyone provide any reference for loading and rendering a md2 file as i followed the same process of using Loader.loadMD2 but its going out of memory?

Please help

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Not able load md2 file with size 358 KB
« Reply #1 on: September 15, 2010, 03:00:32 pm »
you can try loading your model with desktop jPCT and serialize it.
Code: [Select]
new DeSerializer.serialize(..)
than load it in AE via
Code: [Select]
Loader.loadSerializedObject(..)

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Not able load md2 file with size 358 KB
« Reply #2 on: September 15, 2010, 03:55:52 pm »
HI,

        I serialized the model and it came around 1.9MB . The engine is not showing any memory exception but i am not able to see any rendering and its just a black screen

Following are my rendering logs:


09-15 03:53:21.985: INFO/jPCT-AE(2261): Adding Lightsource: 0
09-15 03:53:22.005: INFO/jPCT-AE(2261): OpenGL vendor:     Android
09-15 03:53:22.005: INFO/jPCT-AE(2261): OpenGL renderer:   Android PixelFlinger 1.0
09-15 03:53:22.005: INFO/jPCT-AE(2261): OpenGL version:    OpenGL ES-CM 1.0
09-15 03:53:22.005: INFO/jPCT-AE(2261): OpenGL renderer initialized (using 2 texture stages)
09-15 03:53:22.885: DEBUG/dalvikvm(2261): GC freed 17789 objects / 776040 bytes in 110ms
09-15 03:53:23.095: INFO/jPCT-AE(2261): Remapping 1618 vertex indices!
09-15 03:53:23.095: INFO/jPCT-AE(2261): Creating vertex cache (38832 bytes)!
09-15 03:53:23.105: INFO/jPCT-AE(2261): Vertex indices will be mapped!
09-15 03:53:23.105: INFO/jPCT-AE(2261): Subobject of object 0/rock compiled to indexed fixed point data using 7218 vertices in 849ms!
09-15 03:53:23.105: INFO/jPCT-AE(2261): Object 0/rock compiled to 1 subobjects in 1094ms!

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Not able load md2 file with size 358 KB
« Reply #3 on: September 15, 2010, 04:02:32 pm »
it can be because of ligthing and/or camera position and direction.
start with turning on ambient lighting to max value
Code: [Select]
World.setAmbientLight(255, 255, 255)and try to place camera at a proper distance where it can see the whole scene. this depends on scaling of your model.

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Not able load md2 file with size 358 KB
« Reply #4 on: September 15, 2010, 04:16:35 pm »
THANX....Its working fine now.

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Not able load md2 file with size 358 KB
« Reply #5 on: September 15, 2010, 04:22:45 pm »
Hi,

     Another thing, As i have five animation in the model. I am not sure how to use animation methods:

1. model.animate(float)
2. model.animate(float, int)

Will they draw the frames or the animation sequences and how to utilize them.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Not able load md2 file with size 358 KB
« Reply #6 on: September 15, 2010, 04:40:40 pm »
when you call animate(..) your object's mesh is updated according to given index. calculation is done via interpolating keyframes. that is every vertex of resulting mesh is an interpolation of corresponding two vertices in two keyframes.
for example if you have 3 keyframes for a sequence, and sequence number is 1:
Code: [Select]
Object3D.animate(0.25f, 1);the resulting mesh will be interpolation of keyframe 0 and 1.
you should calculate index depending on your application and desired animation speed.

Code: [Select]
Object3D.animate(float, int)
this animates the model with given sequence number. (each 5 animation of your model is a separate sequence)

Code: [Select]
Object3D.animate(float)this behaves like all sequences are merged into one

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Not able load md2 file with size 358 KB
« Reply #7 on: September 16, 2010, 02:05:01 pm »
Hi,

        All is going well and the credit goes to you.....I am able to render and use all the animations of the md2 file as guided.I have another request in queue and that is

How to use the collision detection in jPCT?

any reference would lead me in the next step of development



Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: Not able load md2 file with size 358 KB
« Reply #8 on: September 16, 2010, 02:07:28 pm »
very well. you are making quick progress. i guess you are not aware of there is a wiki for jPCT:
http://www.jpct.net/wiki/index.php/Collision_detection