HLFX.Ru Forum
Показать все 2 сообщений этой темы на одной странице

HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- Half-Life SDK (https://hlfx.ru/forum/forumdisplay.php?forumid=8)
-- Tri API 3D Sphere problem (https://hlfx.ru/forum/showthread.php?threadid=3590)


Отправлено MisterDeath 20-08-2012 в 17:38:

Unhappy Tri API 3D Sphere problem

I Extracted this code in the forum... but the problem is the texture repeat in each picture...



C++ Source Code:
1
int CSphere :: Draw( float flTime )
2
{
3
  cl_entity_t *player;
4
  vec3_t org;
5
 
6
  // Load it up with some bogus data
7
  player = gEngfuncs.GetLocalPlayer();
8
  if ( player )
9
  {
10
 
11
    org = player->origin;
12
 
13
    //	org.x += 50;
14
    //	org.y += 50;
15
 
16
    if (gHUD.m_hsprCursor == 0)
17
    {
18
      char sz[256];
19
      sprintf( sz, "sprites/blastsphere.spr" );
20
      gHUD.m_hsprCursor = SPR_Load( sz );
21
    }
22
 
23
    gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 );
24
 
25
    // Create a triangle, sigh
26
    gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
27
    gEngfuncs.pTriAPI->CullFace( TRI_NONE );
28
    gEngfuncs.pTriAPI->Brightness( 1 );
29
    gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
30
 
31
    float step = 5;
32
    float grad1 = 0;
33
    float grad2 = -90;
34
    float x, y, z, tmp;
35
    float radius = 40;
36
 
37
    while (grad2 < 90)
38
    {
39
 
40
      //gEngfuncs.Con_Printf( "grad2 = %f, z = %f\n", grad2, cos(M_PI * (grad2 / 180)));
41
 
42
      while (grad1 < 360)
43
      {
44
        gEngfuncs.pTriAPI->Begin( TRI_QUAD_STRIP );
45
 
46
        z = radius * sin(M_PI * (grad2 / 180));
47
        //	 z = radius;
48
        tmp = radius * cos(M_PI * (grad2 / 180));
49
        x = cos(M_PI * (grad1 / 180)) * tmp;
50
        y = sin(M_PI * (grad1 / 180)) * tmp;
51
 
52
        //	 gEngfuncs.Con_Printf( "Rad x1 = %f, y1 = %f, z1 = %f\n", x, y, z);
53
 
54
        gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
55
        gEngfuncs.pTriAPI->Vertex3f( org.x + x, org.y + y, org.z + z );
56
 
57
        grad2 += step;
58
        z = radius * sin(M_PI * (grad2 / 180));
59
        //	 z = radius;
60
        tmp = radius * cos(M_PI * (grad2 / 180));
61
        x = cos(M_PI * (grad1 / 180)) * tmp;
62
        y = sin(M_PI * (grad1 / 180)) * tmp;
63
 
64
        //	 gEngfuncs.Con_Printf( "Rad x2 = %f, y2 = %f, z2 = %f\n", x, y, z);
65
 
66
        gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
67
        gEngfuncs.pTriAPI->Vertex3f( org.x + x, org.y + y, org.z + z );
68
 
69
        grad2 -= step;
70
        grad1 += step;
71
        z = radius * sin(M_PI * (grad2 / 180));
72
        //	 z = radius;
73
        tmp = radius * cos(M_PI * (grad2 / 180));
74
        x = cos(M_PI * (grad1 / 180)) * tmp;
75
        y = sin(M_PI * (grad1 / 180)) * tmp;
76
 
77
        //	 gEngfuncs.Con_Printf( "Rad x3 = %f, y3 = %f, z3 = %f\n", x, y, z);
78
 
79
        gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
80
        gEngfuncs.pTriAPI->Vertex3f( org.x + x, org.y + y, org.z + z );
81
 
82
        grad2 += step;
83
        z = radius * sin(M_PI * (grad2 / 180));
84
        //	 z = radius;
85
        tmp = radius * cos(M_PI * (grad2 / 180));
86
        x = cos(M_PI * (grad1 / 180)) * tmp;
87
        y = sin(M_PI * (grad1 / 180)) * tmp;
88
 
89
        //	 gEngfuncs.Con_Printf( "Rad x4 = %f, y4 = %f, z4 = %f\n", x, y, z);
90
 
91
        gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
92
        gEngfuncs.pTriAPI->Vertex3f( org.x + x, org.y + y, org.z + z );
93
 
94
        grad2 -= step;
95
        gEngfuncs.pTriAPI->End();
96
      }
97
 
98
      grad2 += step;
99
      grad1 = 0;
100
    }
101
  }
102
  return 1;
103
}


Sorry bad english

__________________
hl 4 ever


Отправлено HAWK0044 23-08-2012 в 23:38:

are u sure what u load texture properly?


Временная зона GMT. Текущее время 01:20.
Показать все 2 сообщений этой темы на одной странице

На основе vBulletin версии 2.3.0
Авторское право © Jelsoft Enterprises Limited 2000 - 2002.
Дизайн и программирование: Crystice Softworks © 2005 - 2024