示例#1
0
文件: objects.py 项目: y-vas/game
    def set_structure_extrusion(self, normal = False):
        vertes = self.get_verts_from_face_id(0)
        normalVec = mathutils.geometry.normal(*vertes)

        inverse = -1;
        if normal == True:
            inverse  = 1;

        inverse = inverse * self.STRUC_HEIGHT;

        verts = [];
        face = [];

        for i,e in enumerate(self.verts):
            vect = self.verts[i][0]

            vct = vtr((
                vect[0]+ (normalVec[0] * inverse),
                vect[1]+(normalVec[1]*inverse),
                vect[2]+(normalVec[2]*inverse))
                    )
            idv = self.sid();
            verts.append([vct,idv])
            face.append(idv)

        self.FACES.append([face, self.sid()])

        for i, vec in enumerate(verts):
            if i == len(self.verts)-1:
                face = [self.verts[i][1],verts[i][1],verts[0][1],self.verts[0][1]]
            else:
                face = [self.verts[i][1],verts[i][1],verts[i+1][1],self.verts[i+1][1]]
            self.FACES.append([face, self.sid()])

        self.append_vectors(verts)
示例#2
0
文件: objects.py 项目: y-vas/game
 def get_delimiters_as_areas(self):
     vectors = []; faces = []; edges = []
     verts = 0
     for space in self.delimiters:
         delimiter_vector = space[0]
         radius = space[1]
         face = []; radi = 0;
         while radi < 360:
             radi += 1
             if radi % 24 == 0:
                 vec = vtr((0, radius,0))
                 vec.rotate(Euler((0.0, 0, math.radians(radi)), 'XYZ'))
                 vecF = vtr((vec[0]+delimiter_vector[0], vec[1]+delimiter_vector[1], vec[2]+delimiter_vector[2]))
                 vectors.append(vecF)
                 face.append(verts)
                 verts += 1
         faces.append(face)
     struct = [vectors,edges,faces,self.NAME+"_Delimiters"]
     return struct
示例#3
0
文件: objects.py 项目: y-vas/game
    def rvec(self,x=1,y=1,z=1,xd=True,yd=True,zd=True,delimited=True,persistance=100):
        vec = None
        min = self.size
        for vects in range(persistance):
            vx = rint(-x * 100 * min ,y * 100 * min )/100
            vy = rint(-x * 100 * min ,y * 100 * min )/100
            vz = rint(-z * 100 * min ,z * 100 * min )/100
            vec= vtr(( vx, vy, vz ))

            if not delimited: return vec
            if not self.vdelimited(vec,xd,yd,zd):
                return vec

        return vec
示例#4
0
文件: objects.py 项目: y-vas/game
    def plane(self,strech=None,type=1):
        self.verts = []
        if strech != None: self.delimiters = [ [ vtr((0,0,0)),strech ] ]
        vects, face = [], []

        half = int(self.points / 2)
        v1 = self.rvec(z=0,zd=False,delimited=False);
        vects.append([v1,self.sid()])

        for vect in range( half - 1 ):
            vn = self.rvec( z=0, zd=False, delimited=False )
            vec = vn + vects[-1][0]

            for i,vk in enumerate(vects):
                if i == 0:
                    continue

                if intersect_line_line(vk[0],vects[i-1][0],vects[-1][0],vec):
                    bad = True
                    break

            vn = self.rvec(z=0,zd=False,delimited=False)
            vec = vn + vects[-1][0]


            vects.append([vec,self.sid()])
            pass

            self.verts = vects;
        else:
            for vect in range( self.points ):
                vec = self.rvec(z=0,zd=False);
                vects.append([vec,self.sid()]);

            self.verts = vects;
            self.verts.sort(reverse = True, key = ut.takeSecond)

        for x in self.verts:
            face.append(x[1]);

        self.FACES = [[face,self.sid()]];
示例#5
0
文件: objects.py 项目: y-vas/game
    def get_stored(self):
        structure = ut.sql_query("SELECT id FROM structures WHERE name = '"+self.NAME+"' ;")
        if structure == None :
            print("This object does not exist in your database!!");
            return None;

        stored_verts = [];
        stored_faces = [];

        faces = ut.sql_query("SELECT verts FROM faces WHERE id_structure = '"+str(structure[0][0])+"' ")

        for face in faces:
            stored_face = []
            for vert in face[0].split(","):
                if vert == "":
                    continue;

                v = ut.sql_query("SELECT x,y,z FROM vertices WHERE id = "+vert)[0]

                vert_pos = len(stored_verts);
                v = vtr( (v[0],v[1],v[2]) );

                if v in stored_verts:
                    vert_pos = stored_verts.index(v)
                    stored_face.append(vert_pos);
                    continue;

                stored_verts.append(v);
                stored_face.append(vert_pos);
                pass

            if len(stored_face) < 3:
                print("A stored face doesn't have all the needet vertices!!");
                continue;

            stored_faces.append(stored_face);

        dict = { "faces" : stored_faces, "verts" : stored_verts }

        return dict