rendering in gameworld menu

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 15 of 39
  1. #1
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rendering in gameworld

    i'm trying to render a simple vertex in wows gameworld
    that's my code:

    Code:
    		D3DTLVERTEX vertices[] =
    		{
    			{ 0.0f, 0.0f, 0.0f, 1.0f, 0xAA00ff00 },
    			{ 0.0f, 200.0f, 0.0f, 1.0f, 0xff0000ff },
    			{ 200.0f, 0.0f, 0.0f, 1.0f, 0xffff0000 }
    		};
    
    		pDevice->SetVertexShader(NULL);
    		pDevice->SetPixelShader(NULL);
    
    		D3DXMATRIX World;
    		D3DXMatrixIdentity(&World);
    
    		D3DXMatrixTranslation(&World, *Localplayer.X, *Localplayer.Y, *Localplayer.Z);
    
    		pDevice->SetTransform(D3DTS_WORLD, &World);
    
    		pDevice->SetFVF(D3DFVF_TL);
    		pDevice->SetTexture(0, NULL);
    
    		pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 1, &vertices[0], sizeof(vertices[0]));
    but pDevice->SetTransform(D3DTS_WORLD, &World); has no effect on how the vertex is drawn, the result just looks like this:


    i checked the world matrix at the end of my code:
    pDevice->GetTransform(D3DTS_WORLD, &World);
    content of the variable:
    Code:
    1 0 0 0
    0 1 0 0
    0 0 1 0
    -6221.15 329.721 383.208 1
    which is ok

    maybe somebody here can tell me why the vertex position isn't translated

    rendering in gameworld
  2. #2
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to set also view and projection matricies

    (3.3.0 version, mostly "stolen" from other topics here)
    Code:
    Vector3 camera = new Vector3( ( float* )pActiveCamera + 2 );
    float zNearPlane = *( ( float* )pActiveCamera + 14 );
    float zFarPlane = *( ( float* )pActiveCamera + 15 );
    float fieldOfView = *( ( float* )pActiveCamera + 16 );
    float aspect = *( ( float* )pActiveCamera + 17 );
    
    lookAt = lookAt + new Vector3( 0, 0, *( ( float* )pActiveCamera + 74 ) );
    
    Matrix view = Matrix.LookAtRH( camera, lookAt, new Vector3( 0, 0, 1f ) );
    Matrix projection = Matrix.PerspectiveFovRH( fieldOfView * 0.6f, aspect, zNearPlane, zFarPlane );
    
    device.SetTransform( D3DTransformStateType.VIEW, &view );
    device.SetTransform( D3DTransformStateType.PROJECTION, &projection );

  3. #3
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i already tried this, doesn't help anything

    in my understanding the view und projection matrix is only needed for world to screen conversion, though it doesn't matter when drawing an object into world space

  4. #4
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No you still need to set view and projection matrices - I think wow uses shaders for this stuff so you need to set it by yourself (correct me if I'm wrong, I'm not exactly expert in d3d stuff). Also now I noticed you are using D3DFVF_XYZRHW.. thats for 2D IIRC and for world rendering you need to use D3DFVF_XYZ.

    http://dl.dropbox.com/u/1799304/Mmow...510_122100.jpg

  5. #5
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    correct, that's the reason why the vertex was where it was, silly mistake :P

    but now i have the problem that the vertex is just not visible, this should be similar to yours at the gnome starting point:
    Code:
    		struct Vertex
    		{
    			float x, y, z;
    			DWORD color;
    		};
    
    		Vertex vertices[] =
    		{
    			{ 0.0f, 0.0f, 5.0f, 0xff00ff00 },
    			{ 5.0f, 0.0f, 0.0f, 0xff0000ff },
    			{ -5.0f, 0.0f, 0.0f, 0xffff0000 }
    		};
    
    		pDevice->SetVertexShader(NULL);
    		pDevice->SetPixelShader(NULL);
    
    		D3DXMATRIX World, View, Proj;
    		D3DXMatrixIdentity(&World);
    		ViewMatrix(&View);
    		ProjectionMatrix(&Proj);
    
    		D3DXMatrixTranslation(&World, -6225.297f, 332.9926f, 383.205f);
    
    		pDevice->SetTransform(D3DTS_WORLD, &World);
    		pDevice->SetTransform(D3DTS_VIEW, &View);
    		pDevice->SetTransform(D3DTS_PROJECTION, &Proj);
    
    		pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
    		pDevice->SetTexture(0, NULL);
    		
    		pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 1, &vertices[0], sizeof(&vertices[0]));
    i tried setting cullmode to none and disabling the zbuffer, but it's still not visible
    my view und projection matrices are ok, they work fine with world to screen
    and before anybody asks: i checked this from both sides, it's not because the backface isn't rendered
    Last edited by mnbvc; 03-25-2010 at 08:37 AM.

  6. #6
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to see things:
    device.Clear( 0, null, D3DClearFlags.ZBUFFER, Colors.White, 1, 0 );

    to see colored things:
    device.SetRenderState( D3DRenderStateType.AMBIENT, 0xff7f7f7f );
    device.SetRenderState( D3DRenderStateType.LIGHTING, 1 );

  7. #7
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i tried it: pDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1, 0);

    but it's still not visible

    isn't clearing the zbuffer anyway the next step wow does after the endscene hook fcuntion is done and though it's needless that we call it?

  8. #8
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yes, my fail - I had to clear zbuffer because I wanted it to work at least on things I draw. When I didn't clear zbuffer everything I drew appeared behind game world. Anyway I have no idea what is wrong. I tried to do same things as you:

    Code:
    device.SetVertexShader( null );
    device.SetPixelShader( null );
    
    // TODO: create wrapper for camera
    float* pActiveCamera = Pointers.ActiveCamera;
    
    Vector3 camera = new Vector3( pActiveCamera + 2 );
    float zNearPlane = *( pActiveCamera + 14 );
    float zFarPlane = *( pActiveCamera + 15 );
    float fieldOfView = *( pActiveCamera + 16 );
    float aspect = *( pActiveCamera + 17 );
    
    lookAt = lookAt + new Vector3( 0, 0, *( pActiveCamera + 74 ) );
    
    Matrix view = Matrix.LookAtRH( camera, lookAt, new Vector3( 0, 0, 1f ) );
    Matrix projection = Matrix.PerspectiveFovRH( fieldOfView * 0.6f, aspect, zNearPlane, zFarPlane );
    
    device.SetTransform( D3DTransformStateType.VIEW, &view );
    device.SetTransform( D3DTransformStateType.PROJECTION, &projection );
    Code:
    public unsafe void SetTarget( Vector3 vector, float yaw = 0, float pitch = 0, float roll = 0 ) {
        Matrix worldMatrix = Matrix.Translation( vector ) * Matrix.RotationYawPitchRoll( yaw, pitch, roll );
    
        device.SetTransform( ( D3DTransformStateType )256, &worldMatrix );
    }
    
    public unsafe void DrawTriangles( params Triangle[] triangles ) {
        device.SetFVF( D3DFVF.XYZ /*| D3DFVF.NORMAL*/ | D3DFVF.DIFFUSE );
        device.SetTexture( 0, null );
    
        fixed ( Triangle* pBuffer = triangles )
            device.DrawPrimitiveUP( D3DPrimitiveType.TRIANGLESTRIP, ( uint )triangles.Length, pBuffer, ( uint )sizeof( Vertex ) );
    }
    Code:
    [Name( "Triangle test" )]
    class TriangleTest( IScript ):
    	def constructor():
    		self._triangles = (
    				Triangle( Vector3( 0.0f, 0.0f, 5.0f ), Colors.Green, Vector3( 0.0f, 0.0f, 0.0f ), Colors.Blue, Vector3( -5.0f, 0.0f, 0.0f ), Colors.Red ),
    			);
    			
    	private _triangles as (Triangle)
    		
    	def Tick():
    		graphics = Direct3D.Graphics;
    		//graphics.SetTarget( ObjectManager.Player.Target.Position, 0, 0, 0 );
    		graphics.SetTarget( Vector3( -6225.297f, 332.9926f, 383.205f ), 0, 0, 0 );
    		graphics.DrawTriangles( *self._triangles );
    And result: http://dl.dropbox.com/u/1799304/Mmow...510_170241.jpg

    And with lightning
    Code:
    device.SetRenderState( D3DRenderStateType.AMBIENT, 0xff7f7f7f );
    device.SetRenderState( D3DRenderStateType.LIGHTING, 1 );
    http://dl.dropbox.com/u/1799304/Mmow...510_170349.jpg

  9. #9
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, the problem was: zNearPlane and zFarPlane in my projection matrix
    well, i'm now taking the values from the camera struct like you and it's fine
    can it be that your rotation and scale is messed up? because i think mine is ok now

    tada:


    but there is still a problem:


    objects like this tree, or players are rendered behind the triangle, does anybody know how to solve this? :P


    btw, the second value here is really strange:
    pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, (sizeof(vertices)/16)-1, &vertices[0], sizeof(Vertex));

    if i have 3 vertices in my array i can set this to 1 or 2, all 3 will be rendered. if i set this to 3, it is expecting a 4th vertex to render, and so the end of my triangle has a visible error.
    if i have 4 vertices in the array and i set this to 1 or 2 only the first 3 of them are rendered but are looking fine
    for all 4 vertices i have to set this to 3
    (correct number seems to be numberofvertices-1)

  10. #10
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah, I just have different second vertex

    Triangle( Vector3( 0.0f, 0.0f, 5.0f ), Colors.Green, Vector3( 0.0f, 0.0f, 0.0f ), Colors.Blue, Vector3( -5.0f, 0.0f, 0.0f ), Colors.Red )

    And about the size.. I think it should be something like that
    trianglelist -> sizeof( vertices ) / ( sizeof( Vertex ) * 3 )
    trianglestrip and trianglefan -> sizeof( vertices ) / sizeof( Vertex ) - 2

  11. #11
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mnbvc View Post
    objects like this tree, or players are rendered behind the triangle, does anybody know how to solve this? :P
    Did you happen to have any luck solving this pickle? I know I haven't yet


  12. #12
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Harland View Post
    Did you happen to have any luck solving this pickle? I know I haven't yet

    You have to manually take care of the depth buffer.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  13. #13
    Harland's Avatar Member
    Reputation
    8
    Join Date
    Oct 2007
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah okay I'll look into that one. Cheers main.

  14. #14
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what i found out so far is that this has to be set, but i guess it's enabled anyway by wow:
    pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    pDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
    pDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    and the other thing we can do is to clear the zbuffer
    but it didn't change anything for me
    can you give any further info about this?

  15. #15
    Kryso's Avatar Active Member
    Reputation
    40
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /solved

    Code:
    D3DViewport viewport = new D3DViewport();
    viewport.Position = Point.Zero;
    viewport.Size = new Point( 1920, 1200 );
    viewport.MinZ = 0;
    viewport.MaxZ = 0.94f;
    
    device.SetViewport( viewport );
    
    device.SetRenderState( D3DRenderStateType.ZENABLE, 1 );
    device.SetRenderState( D3DRenderStateType.ZWRITEENABLE, 1 );
    device.SetRenderState( D3DRenderStateType.ZFUNC, 4 );
    http://dl.dropbox.com/u/1799304/Mmowned/zbuffer.jpg

    It's still drawing over user interface and effects, but it's start

Page 1 of 3 123 LastLast

Similar Threads

  1. Some rendered WoW art (not for the faint of modem)
    By Pinkhair in forum Art & Graphic Design
    Replies: 33
    Last Post: 09-28-2007, 04:59 AM
  2. Musters guide to: Making WoW renders.(Warning Pictures!)
    By Adrenalin3 in forum Art & Graphic Design
    Replies: 11
    Last Post: 08-28-2007, 02:02 PM
  3. renders
    By Sekspyz in forum Art & Graphic Design
    Replies: 5
    Last Post: 08-16-2007, 06:06 PM
  4. Where to get a render?
    By lohkies in forum Art & Graphic Design
    Replies: 2
    Last Post: 03-06-2007, 04:25 PM
  5. How do I render Vid's in fraps?
    By theillbehaviored in forum World of Warcraft General
    Replies: 0
    Last Post: 09-25-2006, 09:54 AM
All times are GMT -5. The time now is 08:43 AM. 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