a easter present

hoja everyone,
finally i got this thing working. im glad to give you this present, see it as a easter present from me. its not really improved finally, but i had to hurry a friend pass by in about a hour. (so cool drinks are waiting.)

2 mio particles at a framerate > 50 :smiley:

btw. sorry for my reactions in the past!

greetz and nice eastern
rootWOLF

'''
Created on 24.04.2011

@author: dirk hochegger (alias:rudol putz, hieronimus, ditus ...) im sorry for the past
'''
from direct.directbase import DirectStart
from pandac.PandaModules import Geom,GeomNode,GeomVertexFormat,GeomVertexWriter,GeomPoints,GeomVertexData
from pandac.PandaModules import Vec3,NodePath
import random

format=GeomVertexFormat.getV3n3cpt2()
vdata=GeomVertexData('square', format, Geom.UHDynamic)
VERT= GeomVertexWriter(vdata, 'vertex')

base.disableMouse()
base.camera.setPos(20,-20,20)
base.camera.lookAt(0,0,0)

class verts(object):
    '''
    classdocs
    '''
    def __init__(self,count=2000000):
        '''
        Constructor
        '''
        self.time = 0.0
        self.PNT = NodePath()
        self.drawPOINT(count)
        taskMgr.add(self.ml,"ml")
        self.turbulence = {}
        for i in range(10):
            self.turbulenceINFL(i)
        self.setSHADER()
        
    def turbulenceINFL(self,id):

        self.turbulence[id] = loader.loadModel("smiley")
        self.turbulence[id].setPos(random.uniform(-4.0,4.0),
                              random.uniform(-4.0,4.0),
                              random.uniform(-4.0,4.0))
        self.turbulence[id].reparentTo(render)
        self.turbulence[id].hide()
        
    def drawPOINT(self,count):
        
        pnt=GeomPoints(Geom.UHDynamic)
        pnt.closePrimitive()
        color=GeomVertexWriter(vdata, 'color')
        
        for i in range(count):
            pos = Vec3(random.uniform(-4.0,4.0),
                       random.uniform(-4.0,4.0),
                       random.uniform(-4.0,4.0))
            VERT.addData3f(pos)
            pnt.addVertex(i)
            color.addData4f(random.uniform(0.0,1.0),random.uniform(0.0,1.0),random.uniform(0.0,1.0),1.0)
               
        square=Geom(vdata)
        square.addPrimitive(pnt)
                
        snode=GeomNode('square')
        snode.addGeom(square)
                
        self.PNT=render.attachNewNode(snode)
        self.PNT.setTwoSided(True)
        self.PNT.setRenderModeWireframe()
        self.PNT.setRenderModeThickness(4)
       # self.PNT.setColor(random.uniform(0.0,1.0),random.uniform(0.0,1.0),random.uniform(0.0,1.0),1)
        
    def setSHADER(self):
        self.PNT.setShader(loader.loadShader("vertSHADER.sha"))

    def ml(self,task):
        self.time += 0.01
        self.PNT.setShaderInput('time',self.time)
        for i in range(len(self.turbulence)):
            self.PNT.setShaderInput('turbulence',self.turbulence[i])
        return task.cont   
verst=verts()
run()  
vertSHADER.sha 
//Cg 
// Dirk hochegger (alias:rudol putz, hieronimus, ditus ...) im sorry for the past

void vshader(float4 vtx_position : POSITION, 
			float4 vtx_color : COLOR,
			uniform float4x4 mat_modelproj,
			uniform float4 k_time,
			in uniform float4 mspos_turbulence,
			out float4 l_color : COLOR,
            out float4 l_position : POSITION) 
{ 
l_color = vtx_color;

 float time = k_time;
 float4 pos=mul(mat_modelproj, vtx_position); 
 
 float dis = (pos-mspos_turbulence);
 float turbDIS = length(dis);
 
 float posX = pos.x;
 float posY = pos.y;
 float posZ = pos.z;
 float posW = pos.w;
 
 posX += l_color.x*sin(time-turbDIS);
 posY += l_color.y*cos(time-turbDIS);
 posZ += l_color.z*sin(time-turbDIS);
  
 l_position = float4(posX,posY,posZ,posW);
} 
void fshader( 
			in float4 l_color : COLOR,
             out float4 o_color: COLOR0
             )
{ 
	o_color = float4(l_color.x,l_color.y,l_color.z,l_color.w);
} 

improved versionā€¦

Uploaded with ImageShack.us

'''
Created on 24.04.2011

@author: dirk hochegger (alias:rudolf putz, hieronimus, ditus ...) im sorry for the past
'''
from direct.directbase import DirectStart
from pandac.PandaModules import Geom,GeomNode,GeomVertexFormat,GeomVertexWriter,GeomPoints,GeomVertexData
from pandac.PandaModules import Vec3,NodePath,WindowProperties,FrameBufferProperties
from pandac.PandaModules import GraphicsPipe,Texture,GraphicsOutput,Point3
import random, math

format=GeomVertexFormat.getV3n3cpt2()
vdata=GeomVertexData('square', format, Geom.UHDynamic)
VERT= GeomVertexWriter(vdata, 'vertex')

base.disableMouse()
base.camera.setPos(20,-40,20)
base.camera.lookAt(0,0,0)
base.setBackgroundColor(0,0,0,1)
class verts(object):
    '''
    classdocs
    '''
    def __init__(self,count=200000,zSRT = -2,resX = 512,resY = 512):
        '''
        Constructor
        '''
        self.renderTEXTURE = Texture()
        
        winprops = WindowProperties.size(resX, resY)
        props = FrameBufferProperties()
        props.setRgbColor(1)
        props.setAlphaBits(1)
        props.setDepthBits(1)
        props.setStencilBits(1)
        
        self.bufferNEW = base.graphicsEngine.makeOutput(base.pipe, "offscreenBuffer",
                                       zSRT, props, winprops,
                                       GraphicsPipe.BFRefuseWindow,
                                       base.win.getGsg(), base.win)
        
        self.bufferNEW.addRenderTexture(self.renderTEXTURE, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)
        
        self.mycamera = base.makeCamera(self.bufferNEW)

        self.time = 0.0
        self.PNT = NodePath()
        self.drawPOINT(count)
        taskMgr.add(self.ml,"ml")
        self.turbulence = {}
        
        for i in range(3):
            self.turbulenceINFL(i)
        self.setSHADER()
        
    def turbulenceINFL(self,id):

        self.turbulence[id] = loader.loadModel("smiley")
        self.turbulence[id].setPos(random.uniform(-4.0,4.0),
                              random.uniform(-4.0,4.0),
                              random.uniform(-4.0,4.0))
        self.turbulence[id].reparentTo(render)
        
        self.pandaMovement = self.turbulence[0].hprInterval(2,Vec3(180, 90, 0))
       
        self.turbulence[id].hide()
        
    def drawPOINT(self,count):
        
        pnt=GeomPoints(Geom.UHDynamic)
        pnt.closePrimitive()
        color=GeomVertexWriter(vdata, 'color')
        
        for i in range(count):
            pos = Vec3(random.uniform(-6.0,6.0),
                       random.uniform(-6.0,6.0),
                       random.uniform(-6.0,6.0))
            dis = (pos-Vec3(0.0,0.0,0.0)).length()

            VERT.addData3f(pos)
            pnt.addVertex(i)
            color.addData4f(random.uniform(0.0,1.0),random.uniform(0.0,1.0),random.uniform(0.0,1.0),1.0)
            
        square=Geom(vdata)
        square.addPrimitive(pnt)
                
        snode=GeomNode('square')
        snode.addGeom(square)
                
        self.PNT=render.attachNewNode(snode)
        self.PNT.setTwoSided(True)
        self.PNT.setRenderModeWireframe()
        self.PNT.setRenderModeThickness(4)
       # self.PNT.setColor(random.uniform(0.0,1.0),random.uniform(0.0,1.0),random.uniform(0.0,1.0),1)
        
    def setSHADER(self):
        self.PNT.setShader(loader.loadShader("vertSHADER.sha"))

    def ml(self,task):
        self.time += 0.1
        self.PNT.setShaderInput('time',self.time)
        
        self.turbulence[0].setX(self.turbulence[0].getX()+math.sin(self.time)/250)
        self.turbulence[0].setY(self.turbulence[0].getY()+math.cos(self.time)/250)
        self.turbulence[0].setZ(self.turbulence[0].getZ()+math.sin(self.time)/250)
        
        self.turbulence[1].setX(self.turbulence[1].getX()-math.sin(self.time)/250)
        self.turbulence[1].setY(self.turbulence[1].getY()-math.cos(self.time)/250)
        self.turbulence[1].setZ(self.turbulence[1].getZ()-math.sin(self.time)/250)
        
        self.turbulence[2].setX(self.turbulence[2].getX()+math.cos(self.time)/250)
        self.turbulence[2].setY(self.turbulence[2].getY()+math.sin(self.time)/250)
        self.turbulence[2].setZ(self.turbulence[2].getZ()+math.sin(self.time)/250)

        self.PNT.setShaderInput('turbulence',self.turbulence[0])
        self.PNT.setShaderInput('camera',self.mycamera)
        self.PNT.setShaderInput('projection',self.renderTEXTURE)
        
        self.PNT.setShaderInput('cx',base.camera.getX())
        self.PNT.setShaderInput('cy',base.camera.getY())
        self.PNT.setShaderInput('cz',base.camera.getZ())
        
        self.PNT.setShaderInput('x',self.turbulence[0].getX())
        self.PNT.setShaderInput('y',self.turbulence[0].getY())
        self.PNT.setShaderInput('z',self.turbulence[0].getZ())
        
        self.PNT.setShaderInput('x1',self.turbulence[1].getX())
        self.PNT.setShaderInput('y1',self.turbulence[1].getY())
        self.PNT.setShaderInput('z1',self.turbulence[1].getZ())
        
        self.PNT.setShaderInput('x2',self.turbulence[2].getX())
        self.PNT.setShaderInput('y2',self.turbulence[2].getY())
        self.PNT.setShaderInput('z2',self.turbulence[2].getZ())
        
        self.PNT.setH(self.time)
        return task.cont   
verst=verts()
run()  
vertSHADER.sha
//Cg 
// Dirk hochegger (alias:rudolf putz, hieronimus, ditus ...) im sorry for the past

void vshader(float4 vtx_position : POSITION, 
			float4 vtx_color : COLOR,
			uniform float4x4 mat_modelproj,
			uniform float4 k_time,
			
			in uniform float4x4 trans_model_to_clip_of_camera,
			
			uniform float4 k_cx,
			uniform float4 k_cy,
			uniform float4 k_cz,
			
			uniform float4 k_x,
			uniform float4 k_y,
			uniform float4 k_z,
			
			uniform float4 k_x1,
			uniform float4 k_y1,
			uniform float4 k_z1,
			
			uniform float4 k_x2,
			uniform float4 k_y2,
			uniform float4 k_z2,
			out float4 l_color : COLOR0,
			out float4 l_color1 : COLOR1,
			out float4 l_color2 : COLOR2,
			out float l_camDIS,
			out float4 l_vtx,
			out float3 l_texcoord0 : TEXCOORD0,
            out float4 l_position : POSITION) 
{ 
	float4 screenPos = mul(trans_model_to_clip_of_camera, vtx_position);
	screenPos.xy /= screenPos.w;
	screenPos.xy += float2(1,1);
	screenPos.xy /= 2;
	//l_texcoord0 = screenPos.xyz;
	
	float4 camPOS = float4(k_cx.x,k_cy.x,k_cz.x,0.0);
	l_camDIS = length(camPOS-vtx_position);
	

	

 	float time = k_time/4;
 	float4 pos=mul(mat_modelproj, vtx_position); 
 
 	float posX = pos.x;
 	float posY = pos.y;
 	float posZ = pos.z;
 	float posW = pos.w;

/*
posX += vtx_color.x*time;
posY += vtx_color.y*time;
posZ += vtx_color.z*time;
posW += vtx_color.w*time;
*/

float4 posTURB = float4(k_x.x,k_y.x,k_z.x,0.0);
float4 posTURB1 = float4(k_x1.x,k_y1.x,k_z1.x,0.0);
float4 posTURB2 = float4(k_x2.x,k_y2.x,k_z2.x,0.0);

float disTURB0 = length(posTURB -vtx_position);
float disTURB1 = length(posTURB1 -vtx_position);
float disTURB2 = length(posTURB2 -vtx_position);
 
float freqSPD = 2;

posX += sin(time-disTURB0*freqSPD)/(disTURB0/2);
posY += cos(time-disTURB0*freqSPD)/(disTURB0/2);
posZ += sin(time-disTURB0*freqSPD)/(disTURB0/2);

posX += sin(time-disTURB1*freqSPD)/(disTURB0/2);
posY += cos(time-disTURB1*freqSPD)/(disTURB0/2);
posZ += sin(time-disTURB1*freqSPD)/(disTURB0/2);

posX += sin(time-disTURB2*freqSPD)/(disTURB0/2);
posY += cos(time-disTURB2*freqSPD)/(disTURB0/2);
posZ += sin(time-disTURB2*freqSPD)/(disTURB0/2);

float b = vtx_position.x -k_x.x;
float h = vtx_position.y -k_y.x;
float d = vtx_position.z -k_z.x;

float b1 = vtx_position.x -k_x1.x;
float h1 = vtx_position.y -k_y1.x;
float d1 = vtx_position.z -k_z1.x;

float b2 = vtx_position.x -k_x2.x;
float h2 = vtx_position.y -k_y2.x;
float d2 = vtx_position.z -k_z2.x;

posX += b/disTURB0;
posY += h/disTURB0;
posZ += d/disTURB0;

posX += b1/disTURB1;
posY += h1/disTURB1;
posZ += d1/disTURB1;

posX += b2/disTURB2;
posY += h2/disTURB2;
posZ += d2/disTURB2;

 l_vtx = vtx_position;
 
 l_position = float4(posX,posY,posZ,posW*1.33);
 //l_position = float4(posX,posY,posZ,100.0);
 //vtx_color = l_position;
 float4 colD = float4(disTURB0/40,disTURB0/40,disTURB0/30,1.0)+float4(disTURB1/40,disTURB1/40,disTURB1/30,1.0)+float4(disTURB2/40,disTURB2/40,disTURB2/30,1.0)/3;
 colD += float4(sin(time-disTURB0*freqSPD)/(disTURB0/2),
 				cos(time-disTURB0*freqSPD)/(disTURB0/2),
 				sin(time-disTURB0*freqSPD)/(disTURB0/2),1.0);
 colD += float4(sin(time-disTURB1*freqSPD)/(disTURB1/2),
 				cos(time-disTURB1*freqSPD)/(disTURB1/2),
 				sin(time-disTURB1*freqSPD)/(disTURB1/2),1.0);
 colD += float4(sin(time-disTURB2*freqSPD)/(disTURB2/2),
 				cos(time-disTURB2*freqSPD)/(disTURB2/2),
 				sin(time-disTURB2*freqSPD)/(disTURB2/2),1.0);
 l_color = colD;
} 
void fshader( 
			in float l_camDIS,
			in  float3 l_texcoord0 : TEXCOORD0,
			in float4 l_color : COLOR,
			in float4 l_position,
			in sampler2D k_projection,
             out float4 o_color: COLOR0
             )
{ 
	float4 proj = tex2D(k_projection,l_texcoord0);
	o_color = float4(l_position.x/4,l_position.y/4,l_position.z/4,1.0);
	//o_color = float4(l_position.x/4,l_position.y/4,l_position.z/4,1.0);
	o_color = float4(l_camDIS/40,l_camDIS/40,l_camDIS/40,1.0);
	o_color = l_color;
} 

yesterday i started with a voxelizer.

here the first resultsā€¦

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

scanned in a higher resolution. i use maya in the meantime for the scan till i can use a real CT.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Iā€¦ loveā€¦ you

this screen show a test object. i used here a bomb as example. so at this screen you can observe the blow a short moment infront the explosion.

~190.000 voxels

thats quiet cool! :smiley:

Uploaded with ImageShack.us

the environment (just atest)

Uploaded with ImageShack.us

Uploaded with ImageShack.us

yeah, that was a long nite, but finally i got the speculars working on my voxis. :laughing:

so other 2 hard nuts waiting on my todo list for today.

its just about the possiblitiesā€¦
voxis rules!!! :smiley: :smiley: :smiley:

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

so now i caring about the regular texturing. the voxels here (below) are using a prerendert textured.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

YEAHHHHH , now i got the voxel orientation, by using a object space normalmap (which can be manipulate (rotated) in the shader), for more complex models.

btw. i love this kind of retro look. yes, this seems to be a kick ass thing. :smiley:

Uploaded with ImageShack.us

Uploaded with ImageShack.us

so here the first test, by using a realtime lit. :smiley:

of course there lot of things which needs to be improved. but this thing starts rocking!

Could you please post your code for you voxelizer? Iā€™d be really interested to see how you are about to do it.

i cant, from a tactical point of view. but i will, when im that far with my game, that the game status allowes it. 8)

currently im working on a voxel isolation. this will be maybe not really related at all to pxljunks revenge III. so its more module for future projects.

here one of the first results. at this screen you be able to observe, horizontal isolated concave spans. this modul is such flexible, you can easy modify the iso vertex count and it will be mostly produce a very nice looking surface.

Uploaded with ImageShack.us

so here to demonstrate how far it is and how good it work at the moment.

at this screen how the hulls will pulled over:

Uploaded with ImageShack.us

here a example for reducing, at this screen you are able to observe a very reduced edge loop ( at 40 verteces at the edge strip)

Uploaded with ImageShack.us

here in a higher resolution, at the vert count by 100 each strip.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

some fixes and other stuff which will come in:

  • seams fixing (i was to lazy to for,current i fixed the seam just by connecting border lines. i already have thos coordinates but i was to lazy to clamp them between.)
  • mesh
  • dynamical threshold

i think this module can be very helpful by polygon reducing too.

currently i started with the mesh triangulationā€¦

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

here you can observe, how the polygon reducing is working at the moment.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

so now im nearly happy with my mesh.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

so i was a bit motivated and i started with the surface stiching. thats more work than i had imagin before.

but it comes very nicly alongā€¦

Uploaded with ImageShack.us

while i worked on the surface stiching, i was in luck to observe this wonderful moriƩ effect. ->

i was knowing that the computer is the mirror of our intellect, our toy, a toy like every higher developed culture is forming. but this mirror is bigger than i ever imagined!

Uploaded with ImageShack.us

so i improved and changed the isolation algorithmus immensly. now this algorithmus isolates the point cloud in your liked resulotion.

of course now my mesh drawer got corrupt, but im quiet happy with my new algorithmus. now im getting a real concave information back.

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

Uploaded with ImageShack.us

clockwise oriented strip:

of course there is a leak, i had in mind on this way it would be better to display, while leaving a leak in the strip, from where the strip starts and ends. the entry point is flexible to define. at this i used, for example the entry id 370. the idea behind this possiblity is the later coming uv seam.

Uploaded with ImageShack.us

this screenshot displays maybe better the clockwise oriented strip.

Uploaded with ImageShack.us

oopsi, sorry i was looking upside down onto X before :laughing: :smiling_imp:

Uploaded with ImageShack.us

hmmm, maybe the X was a bad example for nice concave shape.

Uploaded with ImageShack.us

isolation demo 0.015

-only to use on windows systems (at the moment)
-it doesnt support the complete functionality of the final version

here the demo download link:
http://eatmore.googlecode.com/files/isolation_01.rar

greetz
dirk

upcoming features:
-3d isolation inkl mesh drawer

Uploaded with ImageShack.us

smoothed:

Uploaded with ImageShack.us

Uploaded with ImageShack.us