wie rendert man kugeln?
-
Och, das ist eigentlich ganz einfach: durch eine polymerische Triangulisationshyphophenuse mit oszillierender Basismetaphore, deren Startschwingungsfrequenz Du auf den metabolistischen phasenversetzten Abfangverteiler zweiten Grades setzt. Dabei nicht vergessen, dass auch die kleineren Ritutationen eine große Wirkung bei Exogesen mit größeren Werten als 2.7 haben können, durch die bizentralistische Streckungsosmose.
EDIT: Falls Du das wirklich ernst meinst: D3D oder OpenGL? Es gibt nämlich für beides ein paar Vorgabefunktionen...
[ Dieser Beitrag wurde am 19.03.2003 um 20:44 Uhr von TomasRiker editiert. ]
-
hallo TomasRiker
ich habe kein wort verstanden.
Ich programmiere mit DirectX und meine Frage ist ernst gemeint.
-
Dann probier's mal mit D3DXCreateSphere. Infos in der Dokumentation oder auf http://msdn.microsoft.com .
[ Dieser Beitrag wurde am 19.03.2003 um 20:49 Uhr von TomasRiker editiert. ]
-
cool. vielen dank!! über google finde ich bestimmt beispiele dazu.
hätte nicht gedacht das es schon vorgefertigte funktionen für kugeln gibt
-
Gab's früher auch nicht. Erst seitdem es die schöne D3DX-Library gibt
-
Original erstellt von TomasRiker:
**Och, das ist eigentlich ganz einfach: durch eine polymerische Triangulisationshyphophenuse mit oszillierender Basismetaphore, deren Startschwingungsfrequenz Du auf den metabolistischen phasenversetzten Abfangverteiler zweiten Grades setzt. Dabei nicht vergessen, dass auch die kleineren Ritutationen eine große Wirkung bei Exogesen mit größeren Werten als 2.7 haben können, durch die bizentralistische Streckungsosmose.EDIT: Falls Du das wirklich ernst meinst: D3D oder OpenGL? Es gibt nämlich für beides ein paar Vorgabefunktionen...
[ Dieser Beitrag wurde am 19.03.2003 um 20:44 Uhr von [qb]TomasRiker** editiert. ][/QB]
Musst du denn wieder so übertreiben? :D:D:D
-
Ja, es macht mir Spaß, solche Wörter zu erfinden!
-
Solche Kugeln wie hier?
http://www.fh-merseburg.de/~roesch/mirror/download/cmath.zip
-
CSphere.h
#define D3DFVF_SPHEREVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1) //Define a custom vertex for our sphere struct SPHEREVERTEX { FLOAT x, y, z; //Position of vertex in 3D space FLOAT nx, ny, nz; //Lighting Normal FLOAT tu, tv; //Texture coordinates }; class CSphere { private: IDirect3DDevice9 *m_pDevice; IDirect3DIndexBuffer9 *m_pIB; IDirect3DVertexBuffer9 *m_pVB; IDirect3DTexture9 *m_pTexture; int m_nRings; int m_nSegments; DWORD m_dwNumOfVertices; DWORD m_dwNumOfIndices; DWORD m_dwNumOfPolygons; public: void Init( IDirect3DDevice9* ); DWORD Render(D3DPRIMITIVETYPE dwRenderType); void Release(); };
CSphere.cpp
#include "stdafx.h" void CSphere::Init(IDirect3DDevice9*pDevice) { m_pDevice = pDevice; int nRings = 30; int nSegments = 30; m_nSegments = nSegments; m_nRings = nRings; //Setup counts for this object m_dwNumOfVertices = (m_nRings + 1) * (m_nSegments + 1); m_dwNumOfIndices = 2 * m_nRings * (m_nSegments + 1); m_dwNumOfPolygons = m_dwNumOfIndices - 2; /*//Set material default values (R, G, B, A) D3DCOLORVALUE rgbaDiffuse = {1.0, 1.0, 1.0, 0.0,}; D3DCOLORVALUE rgbaAmbient = {1.0, 1.0, 1.0, 0.0,}; D3DCOLORVALUE rgbaSpecular = {0.0, 0.0, 0.0, 0.0,}; D3DCOLORVALUE rgbaEmissive = {0.0, 0.0, 0.0, 0.0,}; */ // create vertexbuffer //Create the vertex buffer from our device. if(FAILED(m_pDevice->CreateVertexBuffer( m_dwNumOfVertices * sizeof(SPHEREVERTEX), 0, D3DFVF_SPHEREVERTEX, D3DPOOL_DEFAULT, &m_pVB, NULL))) { return; } //Create the index buffer from our device if(FAILED(m_pDevice->CreateIndexBuffer(m_dwNumOfIndices * sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pIB, NULL))) { return; } WORD* pIndices; SPHEREVERTEX* pVertex; WORD wVertexIndex = 0; int nCurrentRing; int nCurrentSegment; D3DXVECTOR3 vNormal; //Lock the vertex buffer if(FAILED(m_pVB->Lock(0, 0, (VOID**)&pVertex, 0))) { return; } //Lock the index buffer if(FAILED(m_pIB->Lock(0, m_dwNumOfIndices, (VOID**)&pIndices, 0))) { return; } //Establish constants used in sphere generation FLOAT rDeltaRingAngle = (D3DX_PI / m_nRings); FLOAT rDeltaSegAngle = (2.0f * D3DX_PI / m_nSegments); //Generate the group of rings for the sphere for(nCurrentRing = 0; nCurrentRing < m_nRings + 1; nCurrentRing++) { FLOAT r0 = sinf(nCurrentRing * rDeltaRingAngle); FLOAT y0 = cosf(nCurrentRing * rDeltaRingAngle); //Generate the group of segments for the current ring for(nCurrentSegment = 0; nCurrentSegment < m_nSegments + 1; nCurrentSegment++) { FLOAT x0 = r0 * sinf(nCurrentSegment * rDeltaSegAngle); FLOAT z0 = r0 * cosf(nCurrentSegment * rDeltaSegAngle); vNormal.x = x0; vNormal.y = y0; vNormal.z = z0; D3DXVec3Normalize(&vNormal, &vNormal); //Add one vertex to the strip which makes up the sphere pVertex->x = x0; pVertex->y = y0; pVertex->z = z0; pVertex->nx = vNormal.x; pVertex->ny = vNormal.y; pVertex->nz = vNormal.z; pVertex->tu = 1.0f - ((FLOAT)nCurrentSegment / (FLOAT)m_nSegments); pVertex->tv = (FLOAT)nCurrentRing / (FLOAT)m_nRings; pVertex++; //Add two indices except for the last ring if(nCurrentRing != m_nRings) { *pIndices = wVertexIndex; pIndices++; *pIndices = wVertexIndex + (WORD)(m_nSegments + 1); pIndices++; wVertexIndex++; } } } if(FAILED(m_pIB->Unlock())) { //LogError("<li>CSphere: Unable to unlock index buffer."); return ; } if(FAILED(m_pVB->Unlock())) { //LogError("<li>CSphere: Unable to unlock vertex buffer."); return ; } //D3DXCreateTextureFromFile( m_pDevice, "Sun.bmp", &m_pTexture ); D3DXCreateTextureFromFileEx( m_pDevice, "texture.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE|D3DX_FILTER_MIRROR, D3DX_FILTER_TRIANGLE|D3DX_FILTER_MIRROR, 0x000000, NULL, NULL, &m_pTexture ); } DWORD CSphere::Render( D3DPRIMITIVETYPE dwRenderType ) { m_pDevice->SetStreamSource(0, m_pVB, 0, sizeof(SPHEREVERTEX)); m_pDevice->SetFVF(D3DFVF_SPHEREVERTEX); if(m_pTexture != NULL) { //A texture has been set. We want our texture to be shaded based //on the current light levels, so used D3DTOP_MODULATE. if( dwRenderType != D3DPT_LINESTRIP ) m_pDevice->SetTexture(0, m_pTexture); m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); } else { //No texture has been set m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); } //Select the material to use //m_pDevice->SetMaterial(&m_matMaterial); //Select index buffer m_pDevice->SetIndices(m_pIB ); m_pDevice->DrawIndexedPrimitive( dwRenderType, 0, 0, m_dwNumOfVertices, 0, m_dwNumOfPolygons); // clear m_pDevice->SetTexture(0, 0); m_pDevice->SetIndices(NULL); return m_dwNumOfPolygons; } void CSphere::Release() { if( m_pTexture != NULL ) m_pTexture->Release(); if( m_pIB != NULL ) m_pIB->Release(); if( m_pVB != NULL ) m_pVB->Release(); }
Das kann man benutzten wenn man seine Datei klein halten will. Also nicht die lästigen d3dx includes hinterherschleifen will.
Bye
[ Dieser Beitrag wurde am 20.03.2003 um 14:58 Uhr von Header editiert. ]
-
hi!
kuck ma hier gerner: http://ogre.sourceforge.net
speziell hier: http://ogre.sourceforge.net/modules/Magnish/Gallery_folder/screenshots/Island5.jpg