2 registered members (AndrewAMD, Ayumi),
853
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Dynamic Mesh Creation
[Re: PriNova]
#410139
10/29/12 13:59
10/29/12 13:59
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
If you only want to create a function graph you could simply create a model like this one: Then, in the vertex shader, you take the InPos.x value as the argument of your function (you may have to scale or shift the value, f.i. with vecSkill41, so it fits your argument) and simply apply it to the formula you have. There is no need for VS 3.0 or higher and no need for mesh generation then.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Dynamic Mesh Creation
[Re: Superku]
#410187
10/30/12 09:17
10/30/12 09:17
|
Joined: Sep 2012
Posts: 74 Niedersachsen, Germany
PriNova
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
|
Thanks @Superku, sounds good, but didn't hit my goal.
Another example:
I try to model procedural meshes (a rock or whatever) with Perlin Noise for example. Then i want to have a gradual LOD:
1. Create Proc-Mesh at LOD-Level 1 with 1 Octave. 2. If User zoom-in, then select all Vertices visibily in frustrum and if a certain threshhold (no fixed thresh, rather dynamic) is reached, tesselate the selected Vertices with higher Octave. 3. If more zoom in then select this new vertices and tesselate them again and detesselate all vertices which are not in frustrum view.
What i try to reach is, that i have a dynamic LOD, depentend initial on procedural creation of meshes. The same is with a terrain. if you stand on the terrain every patch which is farer away should have the lowest LOD, but with a gradual LOD smoothing if the pathes are nearer at the camera. The most examples i see and knew from Model-LOD are 3-5 Stages.
My idea comes from a Voxel Engine and the 1st chapter of GPU Gems 3. i'd like to realize this within 3DGS, but without geometry shader.
I hope you could follow my thoghts.
Last edited by PriNova; 10/30/12 09:18.
|
|
|
Re: Dynamic Mesh Creation
[Re: PriNova]
#410194
10/30/12 10:47
10/30/12 10:47
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Hello Community,
i'm searching for a solution to create meshes dynamicly at runtime. My idea is:
1. create a dummy mesh with ent_create(NULL, VECTOR*, NULL) 2. Allocate a vertexlist, triangellist, normals etc at runtime. ..., Thanks in advance Here is my simple example, maybe it helps.
#include <default.c>
#include <ackphysx.h>
#include <d3d9.h>
#define PRAGMA_PATH "%EXE_DIR%\samples"
#define NVB 9 // Number of Vertices
#define NIB 42 // Number of Indexes
#define NAB 14 // Number of Attributes
LPD3DXMESH pMesh;
D3DVERTEX pvb[NVB];
short pib[NIB];
long pab[NAB];
ENTITY* ent;
function create_house(ENTITY *entity) {
//printf("Total number of mesh vertices = %d", (long)ent_status(entity, 1));
int num_triangles = NAB;
int num_vertices = NVB;
// Vertices
pvb[0].x = -8;pvb[0].y = 8;pvb[0].z = -8;
pvb[1].x = 8;pvb[1].y = 8;pvb[1].z = -8;
pvb[2].x = 8;pvb[2].y = 8;pvb[2].z = 8;
pvb[3].x = -8;pvb[3].y = 8;pvb[3].z = 8;
pvb[4].x = -8;pvb[4].y = -8;pvb[4].z = -8;
pvb[5].x = 8;pvb[5].y = -8;pvb[5].z = -8;
pvb[6].x = 8;pvb[6].y = -8;pvb[6].z = 8;
pvb[7].x = -8;pvb[7].y = -8;pvb[7].z = 8;
pvb[8].x = 0;pvb[8].y = 32;pvb[8].z = 0;
// Triangles / Attributes
pib[ 0] = 6;pib[ 1] = 2;pib[ 2] = 7; pab[ 0] = 0;
pib[ 3] = 3;pib[ 4] = 7;pib[ 5] = 2; pab[ 1] = 1;
pib[ 6] = 7;pib[ 7] = 3;pib[ 8] = 4; pab[ 2] = 2;
pib[ 9] = 0;pib[10] = 4;pib[11] = 3; pab[ 3] = 3;
pib[12] = 4;pib[13] = 0;pib[14] = 5; pab[ 4] = 4;
pib[15] = 1;pib[16] = 5;pib[17] = 0; pab[ 5] = 5;
pib[18] = 5;pib[19] = 1;pib[20] = 6; pab[ 6] = 6;
pib[21] = 2;pib[22] = 6;pib[23] = 1; pab[ 7] = 7;
pib[24] = 7;pib[25] = 4;pib[26] = 6; pab[ 8] = 8;
pib[27] = 5;pib[28] = 6;pib[29] = 4; pab[ 9] = 9;
pib[30] = 3;pib[31] = 8;pib[32] = 0; pab[10] = 10;
pib[33] = 2;pib[34] = 8;pib[35] = 3; pab[11] = 11;
pib[36] = 1;pib[37] = 8;pib[38] = 2; pab[12] = 12;
pib[39] = 0;pib[40] = 8;pib[41] = 1; pab[13] = 13;
D3DXCreateMesh(num_triangles, num_vertices, D3DXMESH_MANAGED , pvertexdecl, pd3ddev, &pMesh);
D3DVERTEX *pnewvb; pMesh->LockVertexBuffer(0, (void**)&pnewvb);
short *pnewib; pMesh->LockIndexBuffer(0, (void**)&pnewib);
long *pnewab; pMesh->LockAttributeBuffer(0, &pnewab);
memcpy(pnewvb, pvb, num_vertices*ent_status(entity,22));
memcpy(pnewib, pib, num_triangles*3*sizeof(short));
memcpy(pnewab, pab, num_triangles*sizeof(long));
pMesh->UnlockVertexBuffer();
pMesh->UnlockIndexBuffer();
pMesh->UnlockAttributeBuffer();
D3DXComputeNormals(pMesh,0);
//int entBuffer = ent_buffers(entity,0,0,&pnewvb,&pnewib,&pnewab);
//printf("Number of triangles of the mesh = %i", entBuffer);
ent_setmesh(entity, pMesh, 0, 0); //printf("ent_setmesh(entity, pMesh, 0, 0);");
//int entBuffer = ent_buffers(entity,0,0,&pnewvb,&pnewib,&pnewab);
//printf("Number of triangles of the mesh = %i", entBuffer);
//printf("Total number of mesh vertices = %d", (long)ent_status(entity, 1));
}
function init_mesh() {
ent = ent_create(CUBE_MDL, vector(-100, 0, 0), NULL);
ent_clone(ent); set(ent, SHADOW|CAST);
create_house(ent);
wait_for(create_house);
c_setminmax(ent);
pXent_settype(ent,PH_RIGID,PH_CONVEX);
wait(1);
}
function spot1() {
set(me, SPOTLIGHT|CAST|LIGHT);
my.lightrange = 500;
vec_set(my.blue,vector(255,100,100));
while(1) {
my.pan += 3*time_step;
my.tilt = -60;
wait(1);
}
}
function spot2() {
set(me, SPOTLIGHT|CAST|LIGHT);
my.lightrange = 500;
vec_set(my.blue,vector(255,50,100));
while(1) {
my.pan -= 3*time_step;
my.tilt = -60;
wait(1);
}
}
function main() {
random_seed(0);
vec_set(sky_color,vector(76,51,25));
video_set(1024, 768, 32, 2);
fps_max = 60; sun_light = 0;
shadow_stencil = 1;
physX_open();
level_load("small.hmp");
vec_set(ambient_color,vector(40,40,40));
vec_set(camera.x,vector(-211,-77,50));
vec_set(camera.pan,vector(35,-19,0));
pXent_settype(level_ent,PH_STATIC,PH_POLY);
init_mesh(); wait_for(init_mesh);
int i; for(i=1;i<NAB+1;i++)
ent_setskin(ent, bmap_fill(bmap_createblack(32,32,24),vector(50+integer(random(255)),100+integer(random(255)),100+integer(random(255))),100),i);
ent.ambient = 50;
//printf("Total number of model skins = %d", (long)ent_status(ent, 8));
you = ent_create(CUBE_MDL,vector(0,0,200),spot1);
you = ent_create(CUBE_MDL,vector(100,0,200),spot2);
def_move();
while(1) {
pX_pick(); // pick and move the mesh with the cursor
wait(1);
}
}
function on_esc_event() {
pMesh = ent_getmesh(ent,0,0);
pMesh->Release();
ent_setmesh(ent,0,0,0);
sys_exit("");
}
|
|
|
Re: Dynamic Mesh Creation
[Re: rojart]
#410206
10/30/12 11:48
10/30/12 11:48
|
Joined: Sep 2012
Posts: 74 Niedersachsen, Germany
PriNova
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
|
Holly cow,
thats exactly what i'm searching for. +reps for you @rojart.
i think adding and subtracting vertices at runtime will be simple too.
i have to study now your code, how everthings work.
*applause*
i should also study more directx programming
Last edited by PriNova; 10/30/12 11:57.
|
|
|
|