Problems hacking properties

Blitz3D Forums/Blitz3D Programming/Problems hacking properties

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This may help - not sure if the offsets are still valid though..
;Texture

;Function GetTextureFlags(texture)
;  Return RtlPeekInt(texture + 32)
;End Function 

Function GetTextureBlend(texture)
  Return RtlPeekInt(texture + 48)
End Function 

Function GetTextureCoords(texture)
  Return RtlPeekInt(texture + 52)
End Function 

Function GetTextureScaleU#(texture)
  Return 1.0 / RtlPeekFloat(texture + 60)
End Function 

Function GetTextureScaleV#(texture)
  Return 1.0 / RtlPeekFloat(texture + 64)
End Function 

Function GetTexturePositionU#(texture)
  Return -RtlPeekFloat(texture + 68)
End Function 

Function GetTexturePositionV#(texture)
  Return -RtlPeekFloat(texture + 72)
End Function 

Function GetTextureRotation#(texture)
  Return (-360.0 * RtlPeekFloat(texture + 76)) / (2.0 / Pi)
End Function 

;Use this funcs if you retrieve texture with GetBrushTexture

;Function GetBrushTextureFlags(texture)  
;  Return 1;RtlPeekInt(RtlPeekInt(texture) + 8)
;End Function 

Function GetBrushTextureBlend(texture)
  Return RtlPeekInt(RtlPeekInt(texture) + 24)
End Function 

Function GetBrushTextureCoords(texture)
  Return RtlPeekInt(RtlPeekInt(texture) + 28)
End Function 

Function GetBrushTextureScaleU#(texture)
  Return 1.0 / RtlPeekFloat(RtlPeekInt(texture) + 36)
End Function 

Function GetBrushTextureScaleV#(texture)
  Return 1.0 / RtlPeekFloat(RtlPeekInt(texture) + 40)
End Function 

Function GetBrushTexturePositionU#(texture)
  Return - RtlPeekFloat(RtlPeekInt(texture) + 44)
End Function 

Function GetBrushTexturePositionV#(texture)
  Return - RtlPeekFloat(RtlPeekInt(texture) + 48)
End Function 

Function GetBrushTextureRotation#(texture)
  Return (-360.0 * RtlPeekFloat(RtlPeekInt(texture) + 52)) / (2.0 / Pi)
End Function 

;Brush

Function GetBrushBlend(brush)
  Return RtlPeekInt(RtlPeekInt(brush) + 4)
End Function 

Function GetBrushColorRGB(brush)
  Return (GetBrushColorR(brush) Shl 16) Or (GetBrushColorG(brush) Shl 8) Or GetBrushColorB(brush)
End Function 

Function GetBrushColorR(brush)  
  Return RtlPeekFloat(RtlPeekInt(brush) + 16)*255  
End Function 

Function GetBrushColorG(brush)
  Return RtlPeekFloat(RtlPeekInt(brush) + 20)*255  
End Function 

Function GetBrushColorB(brush)
  Return RtlPeekFloat(RtlPeekInt(brush) + 24)*255  
End Function 

Function GetBrushFX(brush)
 Return RtlPeekInt(RtlPeekInt(brush) + 40)
End Function 

Function GetBrushShininess#(brush)
 Return RtlPeekFloat(RtlPeekInt(brush) + 28)
End Function 

Function GetBrushAlpha#(brush)
 Return RtlPeekFloat(RtlPeekInt(brush) + 32)
End Function 


;Entity

;Quaternions (local only)

Function EntityQuatW#(entity)
  Return RtlPeekFloat(entity + 48)
End Function 

Function EntityQuatX#(entity)
  Return RtlPeekFloat(entity + 52)
End Function 

Function EntityQuatY#(entity)
  Return RtlPeekFloat(entity + 56)
End Function 

Function EntityQuatZ#(entity)
  Return RtlPeekFloat(entity + 60)
End Function 

Function SetEntityQuat(entity, w#, x#, y#, z#)
  RtlPokeFloat(entity + 48, w#)
  RtlPokeFloat(entity + 52, x#)
  RtlPokeFloat(entity + 56, y#)
  RtlPokeFloat(entity + 60, z#)
  TurnEntity entity,0,0,0
End Function 

;EntityScale funcs based on original code of Mikkel Fredborg

Function EntityScaleX#(Entity, glob=False)

ScaleX# = RtlPeekFloat(Entity + 76)

If glob

Vx# = GetMatElement(Entity, 0, 0)

Vy# = GetMatElement(Entity, 0, 1)

Vz# = GetMatElement(Entity, 0, 2)

ScaleX# = Sgn(ScaleX) * Sqr(Vx#*Vx# + Vy#*Vy# + Vz#*Vz#)

EndIf


Return ScaleX


End Function

Function EntityScaleY#(Entity, glob=False)

ScaleY# = RtlPeekFloat(Entity + 80)

If glob 

Vx# = GetMatElement(Entity, 1, 0)

Vy# = GetMatElement(Entity, 1, 1)

Vz# = GetMatElement(Entity, 1, 2)

ScaleY# = Sgn(ScaleY) * Sqr(Vx#*Vx# + Vy#*Vy# + Vz#*Vz#)

End If


Return ScaleY


End Function

Function EntityScaleZ#(Entity, glob=False)

ScaleZ# = RtlPeekFloat(Entity + 84)

If glob

Vx# = GetMatElement(Entity, 2, 0)

Vy# = GetMatElement(Entity, 2, 1)

Vz# = GetMatElement(Entity, 2, 2)

ScaleZ# = Sgn(ScaleZ) * Sqr(Vx#*Vx# + Vy#*Vy# + Vz#*Vz#)

End If


Return ScaleZ


End Function


;Internal
Function RtlPeekInt%(addr)
  Bank = CreateBank(4) 
  Kernel32_RtlMoveMemory2(Bank,addr,4) 
  Value = PeekInt(Bank, 0)
  FreeBank(Bank)
  Return Value
End Function 

Function RtlPokeInt(addr, value)
  Bank = CreateBank(4) 
  PokeInt Bank, 0, value
  Kernel32_RtlMoveMemory(addr,Bank,4)   
  FreeBank(Bank)  
End Function

Function RtlPeekFloat#(addr)
  Bank = CreateBank(4) 
  Kernel32_RtlMoveMemory2(Bank,addr,4) 
  Value# = PeekFloat(Bank, 0)
  FreeBank(Bank)
  Return Value
End Function

Function RtlPokeFloat(addr, value#)
  Bank = CreateBank(4) 
  PokeFloat Bank, 0, value
  Kernel32_RtlMoveMemory(addr,Bank,4)   
  FreeBank(Bank)  
End Function


.decls

.lib "kernel32.dll"
Kernel32_RtlMoveMemory%(Destination,Source*,Length) : "RtlMoveMemory" 
Kernel32_RtlMoveMemory2%(Destination*,Source,Length) : "RtlMoveMemory"