Quantcast

Jump to content

» «
Photo

Create copy of model as atomic and add to veh clump?

7 replies to this topic
Junior_Djjr
  • Junior_Djjr

    Living in modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#1

Posted 18 December 2013 - 11:14 AM

the idea started here in my other topic

http://gtaforums.com...r-engine-audio/

now i'm creating this topic to ask about this :p

 

i'm creating 2 mods (with same function): attach objects

gta-sa70.jpg

 

the first, car audio shop and speakers vibrating, the other, i will use one function of the first, the function to you add ANY model of game in car

then DK give me idea to "create a copy of model as atomic and add to vehicle clump", but, how to make this? this will be possible to move the "object" in car after attach him? (i think no, but no problem if not ok)

 

how this work? how to make? i hope of this is very useful in my mods, cause at this time i'm only attaching the object in car and creating a thread to control the object, to destroy etc (others objects like dvd player and speaker moving)

 

DK or any other, help me

 


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#2

Posted 18 December 2013 - 04:31 PM Edited by Wesser, 19 December 2013 - 03:03 PM.

Considering you are able to understand the operation of complex scripts, take this code as an example which has been built on the basis of this one:
{$CLEO}

0000: NOP

const
    PAD1                 = 0
end
const
    LEFTSHOULDER1        = 4
end
const
    MODELTYPE_BOAT       = 5
    MODELTYPE_BIKE       = 9
    MODELTYPE_BMX        = 10
end
const
    ATOMIC_MODEL         = 1224 // #WOODENBOX
end
const
    HIERARCHY_CHASSIS    = 1
end
const
    FRAME_POSITION_X     = 0.0
    FRAME_POSITION_Y     = -3.347
    FRAME_POSITION_Z     = 1.1
    FRAME_ROTATION_X     = 0.0
    FRAME_ROTATION_Y     = 0.0
    FRAME_ROTATION_Z     = 0.0
end
const
    _getModelPtr           = 0x00403DA0
    _rwFrameCreate         = 31@
    //_rwFrameClone          = 30@
    _rwFrameAddChild       = 29@
    _rwFrameDestroy        = 28@
    _rwFrameTranslate      = 27@
    _rwFrameRotate         = 26@
    //_rwFrameFindNodeByName = 0x004C5400
    //_rwFrameGetNodeName    = 0x0072FB30
    _rpClumpAddAtomic      = 25@
    _rpClumpRemoveAtomic   = 24@
    _rpClumpFindFrameById  = 0x004C53C0
    _rpAtomicClone         = 23@
    _rpAtomicSetFrame      = 22@
    _rpAtomicDestroy       = 21@
    //_rpAtomicSetCarMatFX   = 0x004C9410
end
const
    _pstAxisX              = 0x008D2E00
    _pstAxisY              = 0x008D2E0C
    _pstAxisZ              = 0x008D2E18
end

0A8E: 0@ = 0x004C44F5 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameCreate = 1@ + 2@
{0A8E: 0@ = 0x00537338 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameClone = 1@ + 2@}
0A8E: 0@ = 0x004C9269 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameAddChild = 1@ + 2@
0A8E: 0@ = 0x004C4473 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameDestroy = 1@ + 2@
0A8E: 0@ = 0x0053394F + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameTranslate = 1@ + 2@
0A8E: 0@ = 0x00533903 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rwFrameRotate = 1@ + 2@
0A8E: 0@ = 0x004C6CC1 + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpClumpAddAtomic = 1@ + 2@
0A8E: 0@ = 0x004C6CBA + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpClumpRemoveAtomic = 1@ + 2@
0A8E: 0@ = 0x004C44EE + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicClone = 1@ + 2@
0A8E: 0@ = 0x004C450A + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicSetFrame = 1@ + 2@
0A8E: 0@ = 0x004C446D + 0x01
0A8E: 1@ = 0@ + 0x04
0A8D: 2@ = read_memory 0@ size 4 virtual_protect 1
0A8E: _rpAtomicDestroy = 1@ + 2@

0A9F: 20@ = current_thread_pointer
0A8E: 12@ = 20@ + 0x74 // CScriptThread.m_aiLocalVars[14]
0A8E: 13@ = 20@ + 0x80 // CScriptThread.m_aiLocalVars[17]
14@ = FRAME_POSITION_X
15@ = FRAME_POSITION_Y
16@ = FRAME_POSITION_Z
17@ = FRAME_ROTATION_X
18@ = FRAME_ROTATION_Y
19@ = FRAME_ROTATION_Z

20@ = false

while true
    wait 0
    if
    00DD:  actor $PLAYER_ACTOR driving_car_with_model #WALTON
    then
        if
        00E1:  player PAD1 pressed_key LEFTSHOULDER1 // Secondary Fire
        then
            if
                20@ == false
            then
                0247: load_model ATOMIC_MODEL
                while 8248:  not model ATOMIC_MODEL available
                    wait 0
                end 
                03C0: 0@ = actor $PLAYER_ACTOR car
                // Get the vehicle model pointer.
                0441: 1@ = car 0@ model
                0AA7: call_function _getModelPtr num_params 1 pop 1 iId 1@ pclInfo 2@
                // Get the vehicle type by model.
                0A8E: 3@ = 2@ + 0x3C // CModelCars.m_eType
                0A8D: 3@ = read_memory 3@ size 4 virtual_protect 0
                // Get the type-indipendent chassis RwFrame.
                0A97: 4@ = car 0@ struct
                0A8E: 5@ = 4@ + 0x18 // CVehicle.m_clPhysical.m_clEntity.m_pstRwObject
                0A8D: 5@ = read_memory 5@ size 4 virtual_protect 0
                if and
                    3@ >= MODELTYPE_BOAT
                    3@ <> MODELTYPE_BIKE
                    3@ <> MODELTYPE_BMX
                then
                    0A8E: 6@ = 5@ + 0x04 // SRpClump.m_stObject.m_pstParent
                    0A8D: 6@ = read_memory 6@ size 4 virtual_protect 0
                else
                    0AA7: call_function _rpClumpFindFrameById num_params 2 pop 2 iHierarchyId HIERARCHY_CHASSIS pstRpClump 5@ pstRwFrame 6@
                    if
                        6@ == 0x00000000
                    then
                        0A8E: 6@ = 5@ + 0x04 // SRpClump.m_stObject.m_pstParent
                        0A8D: 6@ = read_memory 6@ size 4 virtual_protect 0
                    end
                end
                // Get the model RwObject of the attaching object (it is clump free, so we get the first atomic).
                0AA7: call_function _getModelPtr num_params 1 pop 1 iId ATOMIC_MODEL pclInfo 7@
                0A8E: 8@ = 7@ + 0x1C // CModelCars.m_clModelHier.m_clBaseModelInfo.m_pstRwObject
                0A8D: 8@ = read_memory 8@ size 4 virtual_protect 0
                // Get the atomic RwFrame needed to be cloned in order to save the original name.
                {0A8E: 9@ = 8@ + 0x04 // SRpAtomic.m_stObject.m_stObject.m_pstParent
                0A8D: 9@ = read_memory 9@ size 4 virtual_protect 0}
                // Clone and link both the model atomic and frame to the vehicle clump. Plus, move the frame at our predefined offsets.
                0AA7: call_function _rpAtomicClone num_params 1 pop 1 pstRpAtomic 8@ pstRpAtomic 10@
                //0AA7: call_function _rwFrameClone num_params 1 pop 1 pstRwFrame 9@ pstRwFrame 11@
                0AA7: call_function _rwFrameCreate num_params 0 pop 0 pstRwFrame 11@
                0AA5: call _rwFrameTranslate num_params 3 pop 3 iCombine 0 pstOffset 12@ pstRwFrame 11@
                0AA5: call _rwFrameRotate num_params 4 pop 4 iCombine 1 fAngle 17@ pstAxis _pstAxisX pstRwFrame 11@
                0AA5: call _rwFrameRotate num_params 4 pop 4 iCombine 1 fAngle 18@ pstAxis _pstAxisY pstRwFrame 11@
                0AA5: call _rwFrameRotate num_params 4 pop 4 iCombine 1 fAngle 19@ pstAxis _pstAxisZ pstRwFrame 11@
                0AA5: call _rpAtomicSetFrame num_params 2 pop 2 pstRwFrame 11@ pstRpAtomic 10@
                0AA5: call _rpClumpAddAtomic num_params 2 pop 2 pstRpAtomic 10@ pstRpClump 5@
                0AA5: call _rwFrameAddChild num_params 2 pop 2 pstRwChild 11@ pstRwFrame 6@
                //0AA5: call _rpAtomicSetCarMatFX num_params 2 pop 2 iMaterialId 0 pstRpAtomic 10@
                0249: release_model ATOMIC_MODEL
                20@ = true
            else
                0AA5: call _rpClumpRemoveAtomic num_params 2 pop 2 pstRpAtomic 10@ pstRpClump 5@
                0AA5: call _rpAtomicDestroy num_params 1 pop 1 pstRpAtomic 10@
                0AA5: call _rwFrameDestroy num_params 1 pop 1 pstRwFrame 11@
                20@ = false
            end
        end
        while 00E1:  player PAD1 pressed_key LEFTSHOULDER1 // Secondary Fire
            wait 0
        end
    end
end
Press "Secondary Fire" inside the Walthon vehicle and the wooden box will appear magically in the back. You could discard the code of the third comment by calling _rpClumpFindFrameById and passing your desired component ID (I do not have a list unfortunately). The only drawback is the absent collision of the attached atomic (we may imitate the helicopter rotors though).
  • Junior_Djjr likes this

Junior_Djjr
  • Junior_Djjr

    Living in modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#3

Posted 19 December 2013 - 07:25 AM Edited by Junior_Djjr, 19 December 2013 - 07:26 AM.

this is very incredible man

congratulations and thanks

 

is possible to move the "object" after attach it? (i think don't is recomended make this attaching in each frame)

ah, and the rotate?

 

and other question: i think is impossible to add an bone in a vehicle and use ifp to move (correct?) any way, is possible to attach a object in a vehicle with specular light and all reflexes etc of this vehicle?

(at 2:50)

when i created this car i needed to make the roof flat/mat 'cause when attached object continues with specular lighthing etc of a simple map object


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#4

Posted 19 December 2013 - 03:48 PM

Check out the updated script. _rwFrameTranslate sets the position of the static modelling matrix, whereas _rwFrameRotate rotates it given an axis and an angle (you have to repeat this step for the XYZ axes).

The attached atomic will have the same specular light and reflection of the parent vehicle (as it becomes part of the model), as long as you apply the same material of other components.

Junior_Djjr
  • Junior_Djjr

    Living in modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#5

Posted 20 December 2013 - 05:56 AM Edited by Junior_Djjr, 20 December 2013 - 02:35 PM.

i loved!

gta-sa72.jpg

i will use this in some mods :B

 

other question;

add bones in object and then add in car, and add a ifp to this "object" can be possible to work? (or this remove all functions of a object?) anyway... have other way to do this? make a object to use a light/reflexes of a specific car, no converting to atomic, only make it uses the lighting etc .-.

 

i have a good idea how to make an new "system" of damage of a car, a thing to do the parts damages more realistics and no "ok" and "damaged", but... i need to use bones in the parts, yes... my idea is possible to make only using a simple object, but... is ugly cause don't use lighting and reflexes of car

 

 

edit: ah, converting to atomic, the object can use vehiclelightson128? :p (i'm waiting for my modeler friend to make tests with this)


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]

#6

Posted 20 December 2013 - 03:00 PM Edited by _DK, 20 December 2013 - 03:07 PM.

The best idea I had for making better damages on cars was interpolating vertices between 'normal' and 'damaged' model. Too bad, Morphing Rw plugin wasn't included into SA.

add bones in object and then add in car, and add a ifp to this "object" can be possible to work? (or this remove all functions of a object?) anyway... have other way to do this? make a object to use a light/reflexes of a specific car, no converting to atomic, only make it uses the lighting etc .-.

1) Nope, animations won't work. Notice you even don't create any objects here - you just use model. But you can create something like 'procedural' animation - remember how minigun and jetpack parts are rotated.
2) As Wesser said, you need to set material properties (spec/envmap intensity, envmap texture etc.) to see changes. This also mean you need to create specific models for each vehicle model, because material data is not cloned for each atomic. Or change material properties dynamicly (save material props - render vehicle - reset material props).

Junior_Djjr
  • Junior_Djjr

    Living in modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#7

Posted 21 December 2013 - 03:00 AM

The best idea I had for making better damages on cars was interpolating vertices between 'normal' and 'damaged' model. Too bad, Morphing Rw plugin wasn't included into SA.

yes, i thought of it days ago when i while i was idealizing a way, but i'm don't know complex things, and the unique thing of i can do is creating a map object controlled with ifp, and then i control the progress of animation to create a interpolation

i even thought, there awesome gta programmers around the world, why no one has made ​​an interpolation of a form to another? must achieve

 

2) As Wesser said, you need to set material properties (spec/envmap intensity, envmap texture etc.) to see changes. This also mean you need to create specific models for each vehicle model, because material data is not cloned for each atomic. Or change material properties dynamicly (save material props - render vehicle - reset material props).

yes, i know, but don't have other way to use specular lighting in object not converting to atomic and add to car?
some things like the folding roof of Peugeot 307cc BMS Edition, uses one object attaching to other... i make this to make easy the movement, this way all of i want make is rotate one object, and the other object who attached in the "edge" of one rotates too, then one object will "push" the other, then the other will lift without need to move, but only rotations :p

i think is can be possible to make with dummys, no? like imvehft works
then in the hierarchy of car i make 2 dummys, one dummy inside of other, then o rotate one, and rotate other, will make same effect

 

 

i'm on this subject cause me and Tasso3D will make an Ferrari California BMS Edition with roof and others parts like 307cc... things of ImVehFt can't be possible, but is a sh*t make all of this using simples objects, we want to use dummys in this new car, but i don't know how to gets a dummy by name and control the modelling matrix (i don't like newopcodes.cleo cause make crashes)
 


madleg
  • madleg

    Player Hater

  • Members
  • Joined: 01 Jan 2014
  • Russia

#8

Posted 23 July 2014 - 08:23 PM

sorry for bump, but how about collision? is it possible to copy collision data from object to object?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users