Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (306)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Fasted way of loading underneath data  (Read 1016 times)
0 Members and 1 Guest are viewing this topic.
Offline Gorgorath

Junior Member




Java games rock!


« Posted 2006-01-25 17:33:51 »

-3592.188597 -31119.243622 -31.656954 45 48 55
-4032.520771 -32321.662903 -2988.956690 21 20 25
-4032.530785 -32321.731567 -2974.183321 20 19 24
-3994.546652 -32327.033997 -2988.503218 19 18 23
-4033.147812 -32338.432312 -1982.117653 21 20 25
-4032.834053 -32324.501038 -2929.337263 21 20 26
-4033.452511 -32333.972931 -2537.735462 20 19 25
-4032.876968 -32326.667786 -2749.205112  19 18 23
-4033.049583 -32326.438904 -2869.204998 20 19 25


the first 3 numbers are the coordinates, the second three are the rgb values.
Right now i'm using this code to read them in:
   try
      {
         d = new DataInputStream( new BufferedInputStream(
                            new FileInputStream(ptsFile) ) );
      }
      catch ( FileNotFoundException ie)
      {
         return -1;
      }

      try
      {
         while ((d != null) && (d.available() > 0))
         {
            s = d.readLine();/*StringOperations.nextData(d);*/
            if (s != null)
            {
               tokens = new StringTokenizer(s);
               if (tokens.countTokens() == 6)
               { //Parse tokens as normally

any suggestions, coz i need to read in a million of these points:)
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #1 - Posted 2006-01-25 18:16:03 »

Write a tool to convert from your text format, to a binary format. Read the binary format in one big data buffer (IntBuffer ?) and use it directly from that buffer. Smiley

Kev

Offline Gorgorath

Junior Member




Java games rock!


« Reply #2 - Posted 2006-01-26 15:47:20 »

okay i figured out i need to use Nio;)

but right now i have it like this, first i put a integer in a bytebuffer, this is the total number of points to be read in, after that i put the coordinates array in it. and finally tthe rgb values. 
Then i want  to create directly floatbuffers from it by its given position and limit, but how can i do this:)
Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 463
Projects: 4


Hand over your head.


« Reply #3 - Posted 2006-01-26 16:31:58 »

1  
2  
3  
4  
ByteBuffer bb = ByteBuffer.allocateDirect(...).order(ByteOrder.nativeOrder());
// fill with data
bb.rewind(); // or set any position/limit you want the FloatBuffer to refer to...
FloatBuffer fb = bb.asFloatBuffer();

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline Gorgorath

Junior Member




Java games rock!


« Reply #4 - Posted 2006-01-26 16:54:19 »

1  
2  
3  
4  
ByteBuffer bb = ByteBuffer.allocateDirect(...).order(ByteOrder.nativeOrder());
// fill with data
bb.rewind(); // or set any position/limit you want the FloatBuffer to refer to...
FloatBuffer fb = bb.asFloatBuffer();

what i want( don't know if it's possible is the following ):
at position 4 ( coz of the first integer in the buffer) my vertex positions starts with goes from 4 till (sizeOf(float)*4*numPoints),
and then i want to read in the byte values that are stored after the vertices. I don't want to use getFloat() coz i want to give the buffers directly to opengl
but is it posible, coz i read the the method asFloatBuffer for instance read from 'position' to the end of the buffer
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
BrassApparatus (6 views)
2013-06-19 08:52:37

NegativeZero (10 views)
2013-06-19 03:31:52

NegativeZero (12 views)
2013-06-19 03:24:09

Jesse_Attard (17 views)
2013-06-18 22:03:02

HeroesGraveDev (59 views)
2013-06-15 23:35:23

Vermeer (59 views)
2013-06-14 20:08:06

davedes (58 views)
2013-06-14 16:03:55

alaslipknot (52 views)
2013-06-13 07:56:31

Roquen (73 views)
2013-06-12 04:12:32

alaslipknot (58 views)
2013-06-10 19:30:18
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!