Rendering with SlimDX menu

User Tag List

Results 1 to 12 of 12
  1. #1
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rendering with SlimDX

    I'm trying to render using C# and SlimDX. I've spent most of the day reading up on DirectX/SlimDX to try to figure out what I'm doing wrong, but haven't figured it out yet. I've read all threads I could find on these forums about it, too. Most of my code is based on people's DirectX implementation found among these threads;
    http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/287433-rendering-gameworld.html
    http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/262973-rendering-wows-game-world.html
    http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/308939-directx-rendering-4-0-1-a.html

    I can see the triangle being rendered, but it's not in the correct position and it's doing some weird stuff. I'm trying to render

    Code:
    public static Result Draw()        {
                var vertices = new PositionColored[3];
                vertices[0] = new PositionColored(new Vector3(0.0f, 0.0f, 5.0f), 0xff00ff00);
                vertices[1] = new PositionColored(new Vector3(5.0f, 0.0f, 0.0f), 0xff0000ff);
                vertices[2] = new PositionColored(new Vector3(-5.0f, 0.0f, 0.0f), 0xffff0000);
                            
                Device.VertexShader = null;
                Device.PixelShader = null;
    
    
                CameraInfo cam = Helper.Magic.ReadStruct<CameraInfo>(camPtr);
    
    
                Vector3 eyePt = cam.Pos;  // XYZ location of my camera. Tested working + correct values
                Vector3 lookAtPt = cam.Pos + cam.ViewMat1; // This part I'm pretty certain is wrong. I have my ViewMatrix broken up into 3 Vectors because I don't want to deal with unsafe code using 2d arrays. I think I just copied the method used by Harland in the third link (cam.Pos + new Vector3(Mat[0][0], Mat[0][1], Mat[0][2])
                Vector3 upPt = new Vector3(0, 0, 1); // Up direction. I've seen people using both (0,0,1) and (0,1,0), so I've tried them both but neither have fixed my problem
    
    
                Matrix matWorld = Matrix.Translation(tar.Location.X, tar.Location.Y, tar.Location.Z); // This should be the location where I'm trying to render the object, on top of my target in this case.
                Matrix matView = Matrix.LookAtRH(eyePt, lookAtPt, upPt);
                Matrix matProj = Matrix.PerspectiveFovRH(cam.FieldOfView * 0.6f, (float)(800/600), cam.NearPlane, cam.FarPlane);
    
    
                Device.SetTransform(TransformState.World, matWorld);
                Device.SetTransform(TransformState.View, matView);
                Device.SetTransform(TransformState.Projection, matProj);
    
    
                Result res = Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 1, vertices);
                return res;
    
    public struct CameraInfo
        {
            uint Unk1;
            uint Unk2;
            public Vector3 Pos;
            public Vector3 ViewMat1;
            public Vector3 ViewMat2;
            public Vector3 ViewMat3;
            public float FieldOfView;
            float Unk3;
            int Unk4;
            public float NearPlane;
            public float FarPlane;
        }
    
            }
    EDIT: I now have the projection working - it correctly renders a box over any unit that I specify, I can draw lines to/between units, etc. However, I still have two problems - first, the my rendering is still only shown when I mouse over a unit. I can't for the life of me figure out how to fix this. The rendered boxes also flash on and off when I start writing in the chat box (like when the typing positioner thing blinks on and off as normal, so does my rendered box). I can temporarily fix this in a really dirty way by using a script to show the tooltip (http://www.wowwiki.com/API_GameTooltip_SetUnit), but that's dumb.

    Second, it's not rendering in color. I've tried the methods mentioned on this forum but haven't had any success. When I stop nulling the shaders, it shows color, but it doesn't project properly anymore.
    Last edited by Thongs; 07-02-2011 at 11:42 AM.

    Rendering with SlimDX
  2. #2
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still having this problem - if anyone has any insight on this I'd really appreciate it.

  3. #3
    wag321's Avatar Member
    Reputation
    1
    Join Date
    Jul 2010
    Posts
    17
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, Did you get anywhere with this? I'm currently trying to figure this out.

  4. #4
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, I never really fixed it properly. It works fine as long as I only render lines (and it only renders in black), and I'm using an ugly hack to make it actually display my rendering using Lua;

    if GameTooltip:GetOwner() == nil then GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
    GameTooltip:SetUnit(\"player\")
    GameTooltip:Show()
    end
    I just execute that Lua after rendering. Like I said, it's very ugly (for example, if you're mousing over a gameobject the rendering will either appear faded or completely invisible). The rendering is usually turned off on my bot, though, so it works well enough for me.

  5. #5
    Neffarian's Avatar Member
    Reputation
    -5
    Join Date
    Sep 2006
    Posts
    53
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tryed checking the mouse code
    like

    if(mouseOver){renderbox();}
    else{ renderBox();}

  6. #6
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really know, but I've been reading up on tons of DirectX threads to prepare for making some rendering myself, and from what I gather from others threads is that your Camera structure is wrong. This is what I've been able to get so far:
    Code:
        public struct CameraInfo
        {
            uint unk0;
            uint unk1;
            public Vector3 Position;
            public Matrix3 Matrix;
            public float FieldOfView;
            float unk2;
            int unk3;
            public float NearZ;
            public float FarZ;
            public float Aspect;
        }
    Would be nice if anyone could confirm

  7. #7
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless I've interpreted the Matrix3 class incorrectly (as basically being 3x Vector3s), that structure is mostly the same as mine, aside aspect at the end. As I understand it, the camera struct is only used for 3d->2d projection, which is working correctly in my code. So I believe that your struct is correct, although I couldn't say for Aspect.

  8. #8
    Dysphorie's Avatar Member
    Reputation
    4
    Join Date
    Aug 2011
    Posts
    12
    Thanks G/R
    0/1
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if what you draw is not clean (not/wrong colored, or depends on the last thing wow displayed), it's because some states have been modified by the last object drawn and you don't reset it.

    you should had the following before drawing your vertex

    Code:
    pDevice->SetVertexShader(NULL);
    pDevice->SetPixelShader(NULL);
    pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    pDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
    pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    pDevice->SetRenderState(D3DRS_LIGHTING, 0);
    pDevice->SetTexture(0, NULL);
    pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

  9. #9
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Dysphorie View Post
    if what you draw is not clean (not/wrong colored, or depends on the last thing wow displayed), it's because some states have been modified by the last object drawn and you don't reset it.

    you should had the following before drawing your vertex

    Code:
    pDevice->SetVertexShader(NULL);
    pDevice->SetPixelShader(NULL);
    pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    pDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
    pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    pDevice->SetRenderState(D3DRS_LIGHTING, 0);
    pDevice->SetTexture(0, NULL);
    pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    This worked, thanks! Previously I had actually been playing around with a bunch of the RenderStates but hadn't found the right ones to fix it I guess. Now I can finally get rid of my ugly Lua tooltip hack.

  10. #10
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since this is pretty relevant and you got your stash working:

    c# - SlimDx D3DERR_INVALIDCALL: Invalid call (-2005530516) - Stack Overflow
    Did anyone of you experience this?

  11. #11
    Thongs's Avatar Member
    Reputation
    10
    Join Date
    Oct 2006
    Posts
    51
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't ever run into that problem, but looking over your code (I didn't look over the DrawCircle part as I'd just try to get the line working first), one thing that I noticed is that you're only calling SetTransform for the world matrix. You should also be calling it for the View and Projection matrices. I suspect that this crash is actually a problem with your device, though. I see that you're using cleanCore's implementation, and IIRC it uses a different way of finding the device. Try using this, instead;

    Code:
    public static Device myDevice = Device.FromPointer(Helper.Magic.Read<IntPtr>(Helper.WoWBase + Offsets.D3D9Device, Offsets.D3D9DeviceOffset));
    
    D3D9Device = 0xA7E20C
    D3D9DeviceOffset = 0x27E8

  12. #12
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am setting View and Projection every frame, just directly from the endscene hook

Similar Threads

  1. Drawing image with SlimDX in game world
    By -Ryuk- in forum WoW Memory Editing
    Replies: 8
    Last Post: 08-30-2014, 10:11 AM
  2. [Large Art] Making wallpapers with your renders
    By Larliand in forum Art & Graphic Design
    Replies: 0
    Last Post: 01-04-2011, 06:33 AM
  3. [RATE] My first Sig with a render ;O
    By freakolivier in forum Art & Graphic Design
    Replies: 6
    Last Post: 07-26-2008, 01:39 AM
  4. [Question] Renders with GIMP
    By Reshnaak in forum Art & Graphic Design
    Replies: 6
    Last Post: 03-22-2008, 01:01 PM
  5. Guide to WoW Signatures (with renders! :O)
    By Minimized in forum Art & Graphic Design
    Replies: 24
    Last Post: 09-30-2007, 11:02 AM
All times are GMT -5. The time now is 11:49 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search