Vertex Coordinate Limits
-
- Posts: 23
- Joined: Thu Sep 09, 2010 1:28 pm
- Location: Australia
- Contact:
Vertex Coordinate Limits
I discovered the hard way that the vertices in a scene can't extend past a certain unit, if they do they get capped at it and/or return to 0,0,0 and start again, which is annoying because I am used to being able to make my scenes use whole numbers for a scale system but I have to scale them down to a micro size. For instance, one of the vertices on my player model is at 157, 117, 643 (relative to it's origin which for the excersize was at the world origins) I need to take these down to minute floating point values under 0.0999999 for them to not hit this bounding limit (and make my scene look like a spastic cube)
Move over Mario... and cruise by Crash... Croc Rocks!
It's a serious adventure 3D platformer for all retro gamers to drool over =D
It's a serious adventure 3D platformer for all retro gamers to drool over =D
Re: Vertex Coordinate Limits
such is life. model your objects -8 < x,y,z < 8 and scale them before rendering.
-
- Posts: 23
- Joined: Thu Sep 09, 2010 1:28 pm
- Location: Australia
- Contact:
Re: Vertex Coordinate Limits
No need to tell me such is lifezeromus wrote:such is life. model your objects -8 < x,y,z < 8 and scale them before rendering.
![Wink ;)](./images/smilies/icon_wink.gif)
My only concern is that the bit operations in MAXScript are really finicky and sometimes cause problems in my scripts so I may just have to write a GUI application that can do all that work for me so the data is readily useable on the DS.
Move over Mario... and cruise by Crash... Croc Rocks!
It's a serious adventure 3D platformer for all retro gamers to drool over =D
It's a serious adventure 3D platformer for all retro gamers to drool over =D
-
- Posts: 23
- Joined: Thu Sep 09, 2010 1:28 pm
- Location: Australia
- Contact:
Re: Vertex Coordinate Limits
Didn't think this was going to warrant a new topic, so I'm reviving this old one.
Been fiddling around with normals, now I wrote an exporter for a generalized file format for animations and models for 3dsMax, it works a charm, exports the model and materials and sorts them so they can be easily batched, etc, but normals are being a pain. I copied the floattov10/PACK_NORMAL functions over so the result was the exact same but encountered the obvious sign issue, for instance, -256 is converted to 768 from a packed normal, so I did some bit sniffing and saw that:
-256 (11 0000 0000)
becomes:
768 (00 1111 1111)
Is the 10th bit always reserved as the signage? Bits and signage on a bit level were never my strongpoint so some friendly answers/advice/direction would be appreciated.
When I changed the function to unpack the normal to three 10-bit integers, I changed the bitwise and from 0x3FF to 0x1FF to exclude the 10th bit and 768 became 256 which makes sense, so I should probably just check the 10th bit, if it's set then the integer is negative?
Been fiddling around with normals, now I wrote an exporter for a generalized file format for animations and models for 3dsMax, it works a charm, exports the model and materials and sorts them so they can be easily batched, etc, but normals are being a pain. I copied the floattov10/PACK_NORMAL functions over so the result was the exact same but encountered the obvious sign issue, for instance, -256 is converted to 768 from a packed normal, so I did some bit sniffing and saw that:
-256 (11 0000 0000)
becomes:
768 (00 1111 1111)
Is the 10th bit always reserved as the signage? Bits and signage on a bit level were never my strongpoint so some friendly answers/advice/direction would be appreciated.
When I changed the function to unpack the normal to three 10-bit integers, I changed the bitwise and from 0x3FF to 0x1FF to exclude the 10th bit and 768 became 256 which makes sense, so I should probably just check the 10th bit, if it's set then the integer is negative?
Move over Mario... and cruise by Crash... Croc Rocks!
It's a serious adventure 3D platformer for all retro gamers to drool over =D
It's a serious adventure 3D platformer for all retro gamers to drool over =D
-
- Posts: 30
- Joined: Fri Dec 17, 2010 1:34 pm
- Location: Either side of South Bypass, Madrid, Spain
Re: Vertex Coordinate Limits
I do the following and seems to be working properly:Been fiddling around with normals, now I wrote an exporter for a generalized file format for animations and models for 3dsMax, it works a charm, exports the model and materials and sorts them so they can be easily batched, etc, but normals are being a pain. I copied the floattov10/PACK_NORMAL functions over so the result was the exact same but encountered the obvious sign issue, for instance, -256 is converted to 768 from a packed normal, so I did some bit sniffing and saw that:
-256 (11 0000 0000)
becomes:
768 (00 1111 1111)
Is the 10th bit always reserved as the signage? Bits and signage on a bit level were never my strongpoint so some friendly answers/advice/direction would be appreciated.
When I changed the function to unpack the normal to three 10-bit integers, I changed the bitwise and from 0x3FF to 0x1FF to exclude the 10th bit and 768 became 256 which makes sense, so I should probably just check the 10th bit, if it's set then the integer is negative?
Code: Select all
param = (((int)(normal[0]*511))& 0x3FF) |
(((int)(normal[1]*511))& 0x3FF)<<10 |
(((int)(normal[2]*511))& 0x3FF)<<20;
Code: Select all
glNormal(param);
Code: Select all
unsigned int param;
float normal[3];
--------------------------------
Welcome, my son, to the machine.
Pink Floyd.
Welcome, my son, to the machine.
Pink Floyd.
-
- Posts: 30
- Joined: Fri Dec 17, 2010 1:34 pm
- Location: Either side of South Bypass, Madrid, Spain
Re: Vertex Coordinate Limits
Sorry I did not answer to your question:
Signed integers are stored in what is called two's complement:
most significant bit : 0 for positive, 1 for negative.
With normals it is a little tricky:
So the maximum positive number for normals coordinates in the DS hw is:
0.1 1111 1111b which is a little less than 1 (0.99609375)
An the minimum negative number for normals coordinates is:
1.0 0000 0000b which is a exactly -1
That is why I multiply the float value by 511 instead of 512.
I don't know if I was able to explain it.
Signed integers are stored in what is called two's complement:
- Your reserve half of your precision for negative numbers.
- For obtaining a negative number you invert 0s and 1s and add 1
- Positives from 1 (0000 0001b) to 127 (0111 1111b)
- Negatives from -1 (1111 1111b) to -128(1000 0000b)
- Zero 0 is just 0000 0000b
most significant bit : 0 for positive, 1 for negative.
With normals it is a little tricky:
- We have 10 bits, 1 reserved for integer part and 9 for fractional part
- But you cannot use 1 or -1 because you integer part bit is needed for the sign
- 0000 001.0 0000 0000b for 1 and
- 1111 111.0 0000 0000b for -1
So the maximum positive number for normals coordinates in the DS hw is:
0.1 1111 1111b which is a little less than 1 (0.99609375)
An the minimum negative number for normals coordinates is:
1.0 0000 0000b which is a exactly -1
That is why I multiply the float value by 511 instead of 512.
I don't know if I was able to explain it.
--------------------------------
Welcome, my son, to the machine.
Pink Floyd.
Welcome, my son, to the machine.
Pink Floyd.
Who is online
Users browsing this forum: No registered users and 1 guest