XMDS Posted August 13, 2021 Share Posted August 13, 2021 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 More sharing options...
XMDS Posted August 13, 2021 Author Share Posted August 13, 2021 I am still confused about the RwFrame structure, what are they? Link to comment Share on other sites More sharing options...
Wesser Posted August 13, 2021 Share Posted August 13, 2021 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 More sharing options...
XMDS Posted August 13, 2021 Author Share Posted August 13, 2021 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 More sharing options...
XMDS Posted August 15, 2021 Author Share Posted August 15, 2021 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 More sharing options...
XMDS Posted August 17, 2021 Author Share Posted August 17, 2021 [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 More sharing options...
Wesser Posted August 17, 2021 Share Posted August 17, 2021 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 More sharing options...
XMDS Posted August 21, 2021 Author Share Posted August 21, 2021 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now