Jump to content

Ruki

Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by Ruki

  1. I created a pretty complicated armour system which loads/unloads models and parents them to the entity on the fly. I experienced some crashing errors and I managed to condense my crash into a few simple steps. I spent a whole day targeting this error although it may be me at fault but just wanted to make you aware of the issue just incase. The steps are as follows:

     

    // Step #1, load sword to *swordModel, setparent to hand
       // Step #2, load dress to *dressModel, setparent to entity
    
       // Step #3, unload sword from *swordModel
       // Step #4, load sword to *swordModel, setparent to hand
    
       // Step #5, unload dress from *dressModel
       // Step #6, load dress to *dressModel, setparent to entity
    
       // Step #7, unload sword from *swordModel
       // Step #8, load sword to *swordModel, setparent to hand
    

     

    So basically I'm loading a sword and attaching it to hand, loading a dress and attaching it to entity, unloading and loading sword again, unloading dress and loading dress again, and finally unloading and loading sword again. ~80% of the time it CRASHED on step 7 (which I later found out that *swordModel was being deleted by "the bug" and corrupted the pointer. This is the C++ code for those steps:

     

    Entity *body = Model::Load( "Models/entity_Cat/body.mdl" ); // Succeeds, model exists
    // Step #1, load sword to *swordModel, setparent to hand
    Model *swordModel = Model::Load( "Models/DinnerGame/Equipment/Weapons/sword.mdl" );
           swordModel->SetParent( body->FindChild( "Hand_L" ) );
       // Step #2, load dress to *dressModel, setparent to entity
    Model *dressModel = Model::Load( "Models/DinnerGame/Equipment/Torso/dress-standard.mdl" );
           dressModel->SetParent( body->FindChild( "Torso" ) );
    
       // Step #3, unload sword from *swordModel
    swordModel->Free();
       swordModel = NULL;
       // Step #4, load sword to *swordModel, setparent to hand
    swordModel = Model::Load( "Models/DinnerGame/Equipment/Weapons/sword.mdl" );
           swordModel->SetParent( body->FindChild( "Hand_L" ) );
    
       // Step #5, unload dress from *dressModel
    dressModel->Free();
       dressModel = NULL;
       // Step #6, load dress to *dressModel, setparent to entity
    dressModel = Model::Load( "Models/DinnerGame/Equipment/Torso/dress-standard.mdl" );
           dressModel->SetParent( body->FindChild( "Torso" ) );
    
       // Step #7, unload sword from *swordModel
    swordModel->Free();
       swordModel = NULL;
       // Step #8, load sword to *swordModel, setparent to hand
    swordModel = Model::Load( "Models/DinnerGame/Equipment/Weapons/sword.mdl" );
           swordModel->SetParent( body->FindChild( "Hand_L" ) );
    

     

    When I set up a breakpoint on #Step7, I found out that during step#5, dressMode->Free() WAS ALSO DELETING MY SWORD MODEL! Shown in the following output:

    post-6300-0-46783800-1441241598_thumb.jpg

     

    As you can see, the dressModel->Free(); command in step#5 causes swordModel to also be deleted, making my current *swordModel pointer now corrupt. Step#6 executes fine cause it just loads the dressModel back in, but come to Step#7 where I try to unload the swordModel, and it crashes because that pointer is now corrupt.

     

    I removed all the parenting commands and it NEVER crashes, it all works fine and as expected. I also tried it on an existing model in Leadwerks and could not replicate the error (one of the FPSarm models, and attaching the same models to its hand bones).

     

    My solution:

    If i put a swordModel->SetParent( NULL ); just before Step#5, this prevents it from being deleted along with dressModel in step#5 and the code works fine. However, I feel like this is a bit of a 'hackish' solution to a bit of a vagueish bug? I'm really sorry if this not a bug, please feel free to close the topic if you think so. Thanks for your time

  2. What kind of object is this, a brush or model?

     

    A "Model". I did a test snippet and I'm 90% sure it's bugged, unless I'm doing something wrong. I tested it using the default Barrel Model, which definitely does have a material in the LW editor.

     

    Model *testModel = Model::Load( "Models/Barrel/barrel.mdl" );
    if ( testModel->GetMaterial() )
    	myMain->flag( "Barrel has material!" );
    else
    	myMain->flag( "Barrel has NO material.." );
    

     

    Output says that the barrel has no material, but it shows up ingame as having the blue/yellow material on it

  3. I *might* not be using this correctly, but if you call GetMaterial() on an entity/model loaded in C++ which has a material assigned to it in the LWEditor, it returns NULL, even though you can see ingame that the model has a material being rendered on it.

     

    If you call SetMaterial() and load a material into it, GetMaterial() will return the correct Material.

     

     

    Just to clarify, this only fails if you set the material in the LWeditor. Is this the intended use?

     

    Windows 7, Visual studio community 2013

  4. I would just apply a different material to that part of the model.

     

    How do you do that? I see a .SetMaterial() command which is fine, but assuming my character is made up of 1 model, how do I select just the head? I just tried splitting the head from the body in Blender and exporting that to Leadwerks, but it appears now as 2 separate models, how would I consolidate that into 1 model? Thank you!

  5. I'm working on a low-poly game and I was wondering how to go about making facial expressions/speaking animations on my models by swapping the texture and not by animating the 3d model.

     

    The affect can be seen in the first bit of this animal crossing video:

     

    How do I do this? In the most memory efficient way possible? Do I create a separate 3D model and attach it as a 'mask' on my body model and then change the texture it uses or something? I'm a bit confused! Thank you :)

  6. Thanks Macklebee, for some reason I'm still not achieving it. I followed your Lua script exactly but in C++:

     

           // Create entity data
       workingEntityPointer->LWEntity = Model::Load( myMain->pathManager->getPath_Model( "catmodel" ) );
       workingEntityPointer->LWEntity->SetMass( 1 );
       workingEntityPointer->LWEntity->SetPhysicsMode( Entity::CharacterPhysics );
    
       // Set Collision
       workingEntityPointer->LWEntity->SetCollisionType( Collision::Character );
    
       // Attach sword
       Entity *handEntity = workingEntityPointer->LWEntity->FindChild( "Hand_L" );
       Model *weaponModel = Model::Load( myMain->pathManager->getPath_Model( "sword" ) );
       weaponModel->SetPosition(handEntity->GetPosition(true),true);
       weaponModel->SetRotation(180,0,0,true);
       weaponModel->SetParent(handEntity,true);
    

     

    And then the animation update code:

    LWEntity->SetAnimationFrame(Time::GetCurrent()/100.0,1,0);
    

     

    But I still get the following result when the cat swings it's arm forward

    https://dl.dropboxusercontent.com/u/15579799/LWE/cat2.jpg

     

    Are you able to send the .mdl's you exported incase it's somehow to do with the way I'm exporting them? I'm using blender's Leadwerks exporter

     

     

    *EDIT* This is now fixed, for some reason when I exported my original file in blender using Leadwerks exporter it caused my issue. But I made a new scene and imported the .FBX file I made from it, THEN exported using the Leadwerks exporter somehow fixed something and now it's working fine!

  7. Hi, I've created and rigged a simple model of a cat and I'm trying to attach a simple sword onto its hand in C++ using SetParent(). Whilst this does put the sword into the cat's hand, when the cat animates the sword seems to animate twice as much (or something), so it appears to rotate too much and swing right out of its hand (See video demo below)

     

    Video:

    https://dl.dropboxusercontent.com/u/15579799/LWE/catmodel.avi

     

     

    After the entity is created, I create a sword model and then Parent it to the left hand bone of the cat entity.

     

    // Attach sword
    Model *weaponModel = Model::Load( myMain->pathManager->getPath_Model( "sword" ) );
    Entity *handEntity = catEntity->FindChild( "Hand_L" );
    // Set Parent
    weaponModel->SetParent( handEntity );
    // Set Position
    //weaponModel->SetPosition( handEntity->GetPosition() );
    //weaponModel->SetRotation( handEntity->GetRotation() );
    weaponModel->SetPosition( 0, 0, 0 );
    weaponModel->SetRotation( 0, 0, 0 );
    

     

    I have tried it with both SetPosition/Rotation( handEntity->GetPosition/Rotation() ) and weaponModel->SetPosition/Rotation( 0, 0, 0 ); but they seem to yield the exact same results. I have also tried to attach the Sword to the LowerArm incase my handbone was somehow moving out of whack but it seems to do the same kind of desynced animation. I have also tried to use "SetEntityMatrix" instead of SetPosition/SetRotation and it made the sword distort into a horrible.. horrible thing.

     

    weaponModel->SetMatrix( handEntity->GetMatrix() );
    

     

    Which looks like the attached picture:

    https://dl.dropboxusercontent.com/u/15579799/LWE/cat.jpg

     

     

    Please help me! I've searched for hours and I can't figure it out sad.png I have tried with the weapon having a bone aswell but it didn't seem to change anything

     

    Here are the FBX files of the cat and the sword if it helps:

    https://dl.dropboxusercontent.com/u/15579799/LWE/catmodel.fbx

    https://dl.dropboxusercontent.com/u/15579799/LWE/sword.fbx

  8. Hi, I recently upgrading from LE2 to LE3. I'd like to draw a section of a texture directly onto the screen for my GUI. My GUI texture contains lots of elements that I need to draw individually. I achieved this in LE2 using an OpenGL extension where I could set vertices and their texture coordinates, but I can't access OpenGL with LE3 can I? I'm using Context->DrawImage(...) but it has no parameters for texture UV.. So how do I do this? With a shader? I've never used shaders before so I'm completely baffled by them :| Please help! Thank you

  9. If that works, you might want to make a function that will cast it for you, such as

     

    iConsole* get_iConsole( BaseClass baseclassIn )
    {
    // Check for type
    if ( baseClassIn->type == TYPE_iCONSOLE )
    // return
    Return (iConsole *)baseClassIn;
    else
    // Return
    return NULL;
    }
    

     

    which will simplify the casting for you and check the inherited item is the right type before trying to call ->LoginVar on it?

     

    I wrote a whole gui system based on inheritance and it turned out to be more hassle than it's worth because of all this casting stuff, good luck!

  10. OK I think I *might* have fixed it. I changed quite a lot but I think I narrowed it down to when I was rendering text. I used

     

    SetBlend(BLEND_ALPHA);

     

    somewhere between

     

    // Render

    RenderFramework();

     

    and

     

    // Send to screen

    Flip(0) ;

     

     

     

    I need to tidy up my code and do a few more tests to confirm this was the error, but looks like the fix is to reset back to

     

    SetBlend(BLEND_NONE);

     

    right before flipping. Probably says that in the docs somewhere and I missed it, idk!

  11. Hi, I've been loading the tunnels.sbx scene following the thread here:

    http://www.leadwerks...age__hl__vs2008

     

     

    The scene loads fine, but if I activate HDR I get horrendous artifacts and glitches. I'm not sure where to even start looking. The scene renders fine without HDR activated. The gamelog has no errors

     

    //// DISABLE SetHDR(1);

    http://welkstore.com/images/hdr0.jpg

     

    SetHDR(1);

    http://welkstore.com/images/hdr1.jpg

     

    graphics card: ATI Radeon 7950

  12. I'm currently porting over my existing game structure into Leadwerks engine and I'm having trouble on how to draw a flat 2D texture with specific UV coordinates. That is, rendering a specific part of a texture onto the screen. This is for my GUI elements.

     

    I can only find DrawImage, which seems to work, but will only draw the entire texture, and not specifically a portion of the texture. Should I be using some other function? Thank you

    DrawImage(texture, 50, 50, 200, 400);

     

    Do I have to use some OpenGL commands? I've previously achieved this in DX9 by drawing a trianglestrip and passing in the UV coordinates

     

    Sorry if this is a dumb question. Thank you

  13. Hi, I just signed up, and maybe I'm an idiot but- how do I view the 'programming' section of the forum?

     

    I'm currently porting over my existing game structure into Leadwerks engine and I'm having trouble on how to draw a flat 2D texture with specific UV coordinates. That is, rendering a specific part of a texture onto the screen. This is for my GUI elements.

     

    I can only find DrawImage, which seems to work, but will only draw the entire texture, and not specifically a portion of the texture. Should I be using some other function? Thank you

    DrawImage(texture, 50, 50, 200, 400);

×
×
  • Create New...