Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Drawing phasers!

  1. #21

    Re: Drawing phasers!

    Quote Originally Posted by ize
    Hi there. Well don't i feel like the prize idiot - i ran off at 1000 mph ... in completely the wrong direction I came online last night to upload the 2nd version and saw your post that it wasn't right. So went back to the drawing board and studied the video for about 10mins frame by frame to see exactly what it did.

    After much head scratching/headaches/nosebleeds i think i have what you're looking for!

    Sorry, no source at the mo because it's in such a mess after being ripped to shreds! All the materials are embedded in the app, but they can easily be loaded at runtime, etc. There's also no need to have the variations like i've done - you can have one "template" material, assign it to the phase and then make changes to the phase material leaving the original untouched.
    The only thing i couldn't get right was the highlighting of the phaser. I think the best "cheat" would just be to put it in the texture. I'm no artist so i didn't try it.

    I can give you an outline of how i achived it though. It's probably wrong as i'm not a maths genius. It involved a LOT of trial and even more errors

    • I calculated the direction from the camera to the first node in the phase and did a cross product of that with the phaser direction to give me the final vector (eye vector).
    • After that i calculated the angle of the phase direction and eye vector using the phase up vector as a reference. This angle returns -1 .. 1 which i changed to 0 .. 2 and made it signed so i know which side it was on -=left +=right
    • Finally i used this number to modify the uv tex coords to "slide" the texture around the phaser


    Here ya go:
    video: http://izeinfinity.comoj.com/flash/test2.html
    Download app

    Let me know if this is at least in the right direction

    laters
    This is awesome, it is perfect! you did a most awesome thing, exactly what i need to finish my phasers i can finally move the project forward now with weapons fully charged can't wait for the src i remember i mentioned paypal on first page, i'll be gladly donating something if you wish

    The only thing i couldnt figure out is how to load a custom texture in the app.

    User137: thanks for helping, i realise that ize came up with a working solution now, but i still appreciate your help, unfortunately i'm not that good with math to understand half of it, i usually go around trial and error with such complex things, in this phasers case.. it didn't quite work..
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #22

    Re: Drawing phasers!

    Glad i could help. As for the payment, thankyou very much for the offer but don't worry about it. It was a really fun thing to try and figure out

    All the textures are fixed in the app. What i meant was that you could load textures to the Material Library at runtime in your game. I just figured it would be easier that way as i didn't have to worry about changing the properties of materials once loaded.

    i'll make a start on cleaning up and fully commenting the src and will post here soon
    Windows Vista x64 Ultimate<br />AMD Athlon x64 4000+<br />Codegear Delphi 2009, Delphi 2007, Borland Delphi 7

  3. #23

    Re: Drawing phasers!

    Hey there.
    I wasn't sure how you were going to include it in your game so i have moved all the relevant code, placed it in its own unit and have made it a class. This way you have the option of adding it, or ripping the code out of it.

    I also made a couple of mods to it:
    • Phaser can now have a parent object. if it's assigned, the origin becomes relative to parent, otherwise it's absolute. Eg:
      Start(NullVector, GLsphere1.AbsolutePosition) will set the origin to (0,0,0) if no parent is assigned and the object's center if it is. The target is always absolute
    • Texture can now face any direction(it still rotates around the phaser). Just supply the eye origin to the Update method


    If you are going to use the class then just a couple of things to note:
    • You must have a TGLDirectOpenGL component in your GLscene and never move the position of it from (0,0,0) or this will offset the phaser
    • Only call the Update method from the TGLDirectOpenGL onRender event (all other methods can be called from anywhere)
    • Materials must have their Texture wrapping set to tmBoth or the effect won't work (the repeat and especially the facing)
    • For all methods that expect coordinates, it's best to use an absolute position (except in the case of Start method


    All compiled with Delphi 2009 but hopefully it will work in other versions. Zip contains:
    • testbed app from previous post (src tidied up but not commented)
    • phaser unit (src commented + <unzipped folder>\help\index.html)


    Let me know of any bugs i may have missed
    Download Src
    Windows Vista x64 Ultimate<br />AMD Athlon x64 4000+<br />Codegear Delphi 2009, Delphi 2007, Borland Delphi 7

  4. #24

    Re: Drawing phasers!

    This is cool, i will probably make a custom component to hold many phasers, also this gldirect is annoying to use, when glscene always does frustum culling on it and you can't turn it off.. i kinda made my own workaround for this to always move the gldirect into camera view and reverse the matrix so it renders in global space

    Also i had to hack the demo a bit.. since it wouldnt compiler properly with D7 until i removed the akward compiler directives, inlines and some other fixes :\

    I'll definetly keep you posted to see the final results.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #25

    Re: Drawing phasers!



    This is how it looks now, it's pretty good looking, i still need to add colors and proper texture "flowing" animation into the target direction and stretching of the texture but it looks very promising.

    You definetly deserved a beer for this one!
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #26

    Re: Drawing phasers!

    Sorry for the delayed reply - have been having internet problems @ home That's looking amazing Glad i could help, but sorry for all the hacks/fixes you had to do. i might see if i can get my hands on an earlier version of Delphi so i can test compatability of my apps. I realise what with unicode in D2009 and operator overloading from D2006 onwards the best bet would be to get D7 and then work forwards rather than backwards.

    You've probably got it sorted already, but the flowing should be easy if you're using the update method from the class. Pass the deltatime(dt) to the drawphase method and then you can offset the x texture coord over time. pm me if my code is giving you trouble,

    Browsing this site and now working on this has definitely given me an appetite to start on my own little project
    Windows Vista x64 Ultimate<br />AMD Athlon x64 4000+<br />Codegear Delphi 2009, Delphi 2007, Borland Delphi 7

  7. #27

    Re: Drawing phasers!

    There's a slight problem with uv mapping if you can help me fix this:



    There's only a part of whole texture shown, this works very bad because it cuts out the phaser speckles in texture, i tries multiplying the V texture mapping by 3, and got a semi-useable fix, but then it the texture shifts wrong when seen from specific angles, could you look into this so the whole texture height is mapped to the exact half of visible surface?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  8. #28

    Re: Drawing phasers!

    Whoops! Sorry about that. I assumed the texture would wrap the whole phaser not just the visible side - mainly because of the black borders on the texture. Also, it looks like i didn't take the v repeats into account on the offset

    Here's a fix:

    Replace code in method DrawPhase:
    [pascal]
    glTexCoord2f((i+1)/(fncount-1)*xrep, (yrep*1.5)-((fyrep*o)/fsides)-fofs*yrep);
    glVertex3fv(@fverts[trenderItem(p),a]);
    glTexCoord2f(i/(fncount-1)*xrep, (yrep*1.5)-((fyrep*o)/fsides)-fofs*yrep);
    glVertex3fv(@fverts[trenderItem(p),b]);
    [/pascal]

    with this:
    [pascal]
    var
    u,v: single; // add to method

    // this line tries to keep visible textures centered around offset
    if Odd(fyrep) then v:=0.5 else v:=0;

    u:=(2*fyrep+v)-((2*fyrep*o)/fsides)-(fofs*2*fyrep);
    glTexCoord2f((i+1)/(fncount-1)*xrep, u);
    glVertex3fv(@fverts[trenderItem(p),a]);
    glTexCoord2f(i/(fncount-1)*xrep, u);
    glVertex3fv(@fverts[trenderItem(p),b]);
    [/pascal]

    haven't tested yet, but it looks like it'll work probably best to still leave a border on the textures just to make sure
    Windows Vista x64 Ultimate<br />AMD Athlon x64 4000+<br />Codegear Delphi 2009, Delphi 2007, Borland Delphi 7

  9. #29

    Re: Drawing phasers!



    Perfect, thanks
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  10. #30

    Re: Drawing phasers!

    No problem
    Windows Vista x64 Ultimate<br />AMD Athlon x64 4000+<br />Codegear Delphi 2009, Delphi 2007, Borland Delphi 7

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •