Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

CLEO Render Object


XMDS
 Share

Recommended Posts

const
 CModelInfo_ms_modelInfoPtrs = 0x0092D4C8
 CBaseModelInfo_AddRef = 0x0053F1B0
 RwFrameCreate = 0x00644AA0
 RpAtomicClone = 0x00640FD0
 RpAtomicSetFrame = 0x006423C0
 RwFrameUpateObjects = 0x00644D00
end // const

int ModelInfo
int RpAtomic
int RwFrame
int NewRpAtomic
int pos
float x
float y
float z
float px
float py
float pz
int object
int str

:1
wait 0
if
 pad.IsKeyPressed(77)
jf @1
player.GetCoordinates(0, px, py, pz)
world.GetRandomObjectInSphereNoSaveRecursive(object, px, py, pz, 2.0, 0)
if
 Object.DoesExist(object)
jf @1
0A98: str = object struct
1@ = str + 0x4C 
memory.Read(RpAtomic, 1@, 4, 0) 
if
 RpAtomic <> 0
jf @1
//0AA6: call_method CBaseModelInfo_AddRef struct ModelInfo num_params 0 pop 0
0AA7: call_function_return RwFrameCreate num_params 0 pop 0 RwFrame
0AA7: call_function_return RpAtomicClone num_params 1 pop 1 RpAtomic NewRpAtomic
0AA5: call_function RpAtomicSetFrame num_params 2 pop 2 RwFrame NewRpAtomic

char.GetOffsetInWorldCoords(x, y ,z, $player_actor, 0.0, 2.0, 0.0) 
pos = RwFrame + 0x40
memory.Write(pos, 4, x, 0)
pos += 4
memory.Write(pos, 4, y, 0)
pos += 4
memory.Write(pos, 4, z, 0)
0AA5: call_function RwFrameUpateObjects num_params 1 pop 1 RwFrame
end_thread

@WesserI get the obj model in the game, clone their atmoic, and set the frame. I want it to be rendered in front of the player, but the game has no effect after the button is pressed.

Link to comment
Share on other sites

You are not rendering the atomic at all. You should either set it to an object with null model (never tried) or manually rendering it at the right moment to retain the depth-sorting.

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

1 hour ago, Wesser said:

You are not rendering the atomic at all. You should either set it to an object with null model (never tried) or manually rendering it at the right moment to retain the depth-sorting.

I don't want to create the rendered obj as a model (not occupying CObject), but want to render them directly. How should I render them correctly?

 

I found some functions and structures for rendering Atomic. Should I use them like this?

RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic)

RpAtomic+0x48-renderCallBack

 

Link to comment
Share on other sites

0000:
const
 CModelInfo_ms_modelInfoPtrs = 0x0092D4C8
 CBaseModelInfo_AddRef = 0x0053F1B0
 RwFrameCreate = 0x00644AA0
 RpAtomicClone = 0x00640FD0
 RpAtomicSetFrame = 0x006423C0
 RwFrameUpateObjects = 0x00644D00
 ModelID = 336
end // const

int ModelInfo
int vtable
int GetRwObject
int RpAtomic
int RwFrame
int NewRpAtomic
int pos
float x
float y
float z
int RpAtomicCallBackRender

:1
wait 0
if
 Streaming.IsModelAvailable(ModelID) 
jf @1
0@ = ModelID * 4
0@ += CModelInfo_ms_modelInfoPtrs 
memory.Read(ModelInfo, 0@, 4, 0)
if
 ModelInfo <> 0
jf @1 
memory.Read(vtable, ModelInfo, 4, 0)
2@ = vtable + 0x14
memory.Read(GetRwObject, 2@, 4, 0)
0AA8: call_method_return GetRwObject struct ModelInfo num_params 0 pop 0 RpAtomic 
if
 RpAtomic <> 0
jf @1
0AA6: call_method CBaseModelInfo_AddRef struct ModelInfo num_params 0 pop 0
0AA7: call_function_return RwFrameCreate num_params 0 pop 0 RwFrame
0AA7: call_function_return RpAtomicClone num_params 1 pop 1 RpAtomic NewRpAtomic
0AA5: call_function RpAtomicSetFrame num_params 2 pop 2 RwFrame NewRpAtomic

:2
wait 0
if
 pad.IsKeyPressed(77)
jf @2
char.GetOffsetInWorldCoords(x, y ,z, $player_actor, 0.0, 2.0, 0.0) 
pos = RwFrame + 0x40
memory.Write(pos, 4, x, 0)
pos += 4
memory.Write(pos, 4, y, 0)
pos += 4
memory.Write(pos, 4, z, 0)
0AA5: call_function RwFrameUpateObjects num_params 1 pop 1 RwFrame
15@ = NewRpAtomic + 0x48
memory.Read(RpAtomicCallBackRender, 15@, 4, 0)
0AA5: call_function RpAtomicCallBackRender num_params 1 pop 1 NewRpAtomic
end_thread

My game is GTAVC, I used "RpAtomic+0x48//renderCallBack", but the game crashes, how should I render correctly?

Link to comment
Share on other sites

[GTASA]I want to render textures and 2d vertices on the screen, in fact I should use the Newopcodes.cleo plugin:

0D41: set_vertices [email protected] vertex 1 xyz 0.0 0.0 0.0 rhw 3.33 RGBA 255 255 255 255 uv 0.0 0.0 screenX false screenY true
0D40: draw_2d_shape_type PRIMTYPETRIFAN texture [email protected] numVerts 4 pVerts [email protected] vertexAlpha 0 srcBlend 2 dstBlend 2 priority 0 // IF and SET 

But these commands have bugs that will cause the game to crash (test scripts written by dk will still crash).

So I have the following code:

{$CLEO .cs}
{$USE newopcodes}
0000:
const
 RwIm2DRenderPrimitive = 0x00734E90
end

const
//RwRenderState
 rwRENDERSTATETEXTURERASTER = 1
 rwRENDERSTATESRCBLEND = 10
 rwRENDERSTATEDESTBLEND = 11
 rwRENDERSTATEVERTEXALPHAENABLE = 12
 
//RwBlendFunction 
 rwBLENDSRCALPHA = 5
 rwBLENDINVSRCALPHA = 6
 
//RwPrimitiveType
 rwPRIMTYPETRIFAN = 5
end

int RwTexture
int raster
int RwRenderStateSet
int RwEngineInstance

:1
wait 0
0D64: RwTexture = load_texture_png_from "xmds.png" // IF and SET
if
 RwTexture <> 0
jf @1

:2
wait 0
0A8D: raster = read_memory RwTexture size 4 virtual_protect 0
0A8D: RwEngineInstance = read_memory 0x00C97B24 size 4 virtual_protect 0
2@ = RwEngineInstance + 0x20
0A8D: RwRenderStateSet = read_memory 2@ size 4 virtual_protect 0
0AA5: call_function RwRenderStateSet num_params 2 pop 2 raster rwRENDERSTATETEXTURERASTER
0AA5: call_function RwRenderStateSet num_params 2 pop 2 rwBLENDSRCALPHA rwRENDERSTATESRCBLEND
0AA5: call_function RwRenderStateSet num_params 2 pop 2 rwBLENDINVSRCALPHA rwRENDERSTATEDESTBLEND
0AA5: call_function RwRenderStateSet num_params 2 pop 2 1 rwRENDERSTATEVERTEXALPHAENABLE
int id = 0
float x1 = 187.0
float y1 = 161.0
float x2 = 600.0
float y2 = 400.0
float z = 0.0
float rhw = 3.33
int r = 255
int g = 255
int b = 255
int a = 100
float u = 0.0
float v = 0.0
0AB1: cleo_call @RwIm2DRender 11 id x1 y1 z rhw r g b a u v
id = 1
u = 1.0 
0AB1: cleo_call @RwIm2DRender 11 id x2 y1 z rhw r g b a u v
id = 2
v = 1.0 
0AB1: cleo_call @RwIm2DRender 11 id x2 y2 z rhw r g b a u v
id = 3
u = 0.0
0AB1: cleo_call @RwIm2DRender 11 id x1 y2 z rhw r g b a u v
jump @2

:RwIm2DRender
0AC7: 30@ = var 0@ pointer
0AA5: call_function RwIm2DRenderPrimitive num_params 3 pop 3 4 30@ rwPRIMTYPETRIFAN
//RwBool RwIm2DRenderPrimitive(RwPrimitiveType primType, RwIm2DVertex* vertices, RwInt32 numVertices)
0AB2: cleo_return 0

But the game has no effect, what am I doing wrong?

 

@Wesser Sorry to disturb you again, if you have time to answer. I don’t want to create a new topic

Link to comment
Share on other sites

The scripting engine is simply not updated at every frame for optimisation purposes, thus drawing stuff via script won't work without relying on the power of assembly language.

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

On 8/17/2021 at 9:30 PM, Wesser said:

The scripting engine is simply not updated at every frame for optimisation purposes, thus drawing stuff via script won't work without relying on the power of assembly language.

Thank you for your reply.  If you have time, can you help write a 2D vertex sample code for reference?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.