Page 43 of 123
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 8:14 pm
by Privateer
My bad chrrox,
I stated that I need to change a signed int to a float 16
That is not the actual case.
I needed to change 4 bytes to a float 16 (Half Float)
Here's the Python code to do what I needed.
Code: Select all
import struct
def HalfToFloat(h):
s = int((h >> 15) & 0x00000001) # sign
e = int((h >> 10) & 0x0000001f) # exponent
f = int(h & 0x000003ff) # fraction
if e == 0:
if f == 0:
return int(s << 31)
else:
while not (f & 0x00000400):
f <<= 1
e -= 1
e += 1
f &= ~0x00000400
print s,e,f
elif e == 31:
if f == 0:
return int((s << 31) | 0x7f800000)
else:
return int((s << 31) | 0x7f800000 | (f << 13))
e = e + (127 -15)
f = f << 13
return int((s << 31) | (e << 23) | f)
if __name__ == "__main__":
# sample (1.0) - see Wikipedia
FP16='\x00\x3c'
v = struct.unpack('H', FP16)
x = HalfToFloat(v[0])
# hack to coerce int to float
str = struct.pack('I',x)
f=struct.unpack('f', str)
# print the floating point
print f[0]
I also remembered that the texcoords are always inverted in GR2 files so adding the negate to the print f line will do that.
Note that We ONLY do that to the V not the U
So the code needs to account for that.
print - f[0]
This is done so We don't need to flip the texture upside down.
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 9:11 pm
by MrAdults
Noesis has a function to encode a float in 2 bytes as a half-float, yeah. It's noesis.encodeFloat16. (or Math_EncodeFloat16 for native plugins) This encodes the float according to the IEEE 754 binary16 standard.
Noesis breaks everything down to raw triangle lists behind the scenes, regardless of how you feed the data in, or what type of index you feed into it. Satoh, in your case, you should use the immBegin/immEnd functions as mentioned previously. These allow you to loop through any kind of data feeding 1 triangle at a time (or more, if desired) to Noesis, where each triangle can have any given set of components. Noesis will then automatically batch the triangles into mesh buckets behind the scenes when the model is constructed, and you don't have to worry about breaking things up yourself at all.
Oh, and Noesis has support for 2 sets of UV's. The second set is typically used for lightmaps, but you can use it for whatever you want really.
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 9:20 pm
by Satoh
I see, thank you, I'll try that.
Will that impact the performance of noesis at all though?
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 10:13 pm
by Privateer
MrAdults wrote:Noesis has a function to encode a float in 2 bytes as a half-float, yeah. It's noesis.encodeFloat16. (or Math_EncodeFloat16 for native plugins) This encodes the float according to the IEEE 754 binary16 standard.
So your saying I can decode the need info without the code I posted?
I can take x07 x7f and get the half-float?
I know you plan on better documentation ASAP and that's probably what I need.
In any case? Thanks for putting up with questions.
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 10:16 pm
by finale00
Ya, just pass the bytes to encodefloat16 and you should get the same output.
Maybe you can check that that is true.
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 10:21 pm
by Privateer
finale00 wrote:Ya, just pass the bytes to encodefloat16 and you should get the same output.
Maybe you can check that that is true.
Thanks for the responce.
I'll do that and respond.
Re: Señor Casaroja's Noesis
Posted: Fri Dec 23, 2011 10:37 pm
by Rolandonmilk
oh alright how do you get to view it in noesis or switch been finicing through data but nothing

Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 4:17 am
by MrAdults
Satoh: No, performance shouldn't be impacted. The more logic you do in Python the longer your load times are going to be, naturally, but I wouldn't expect your load times should be getting upwards of 1 second unless you're looping through for hundreds of thousands of triangles.
Privateer wrote:So your saying I can decode the need info without the code I posted?
I can take x07 x7f and get the half-float?
I know you plan on better documentation ASAP and that's probably what I need.
In any case? Thanks for putting up with questions.
From what you said before, you wanted to encode a float into a half-float, but now it sounds like you want to decode a half-float from 2 bytes. You can do that as well, the function is noesis.getFloat16(yourint). (it expects an integer in the range of 0-65535)
Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 3:41 pm
by Privateer
Thank You MrAdults,
That's what I was looking for and I admit I didn't understand the definition when I first looked at it.
I feel like an idiot but I learned a few things along the way.

Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 8:50 pm
by UltimateSora
Hi, is there anyway to remove parts from a model before exporting it? When I use Data Viewer, I can highlight the individual sections. But there's no way to remove them, as far as I know.
Thanks.

Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 9:43 pm
by finale00
You can double-click on "skip render" and it should not be rendered.
I don't know whether exporting from preview will also skip those though (I would like to think it does, since there are two ways to export o.O)
Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 9:49 pm
by chrrox
why not just delete what you dont want in the program your loading it in?
Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 10:09 pm
by UltimateSora
finale00 wrote:You can double-click on "skip render" and it should not be rendered.
I don't know whether exporting from preview will also skip those though (I would like to think it does, since there are two ways to export o.O)
Sadly that method doesn't work.
chrrox wrote:why not just delete what you dont want in the program your loading it in?
Because it's time consuming and somewhat challenging.

Re: Señor Casaroja's Noesis
Posted: Sat Dec 24, 2011 10:46 pm
by chrrox
what do you mean?
if they are separate mesh pieces in noesis they will be in your program also.
just click on the mesh and delete it done.
what program are you using?
Re: Señor Casaroja's Noesis
Posted: Sun Dec 25, 2011 1:32 am
by Satoh
chrrox wrote:what do you mean?
if they are separate mesh pieces in noesis they will be in your program also.
just click on the mesh and delete it done.
what program are you using?
I get the feeling, and I apologize if I'm wrong, that he doesn't know how to use a modeling program very well, or that the program he's using doesn't actually do modeling so much as pure animation or something similar.
In any case, @UltimateSora, you could try hiding the meshes you don't need, and exporting from preview. That may or may not export the hidden meshes. I've never tried it.