func New() *Imp { // x := new(Imp) x.class = None x.colour = col.ScreenF x.vect, x.norm = vect.New(), vect.New() return x }
func vectors(a uint) ([]*vect.Imp, []*vect.Imp) { // v, n := make([]*vect.Imp, a), make([]*vect.Imp, a) for i := uint(0); i < a; i++ { v[i], n[i] = vect.New(), vect.New() } return v, n }
func New() *Imp { // E := new(Imp) E.origin = vect.New() E.originOld = vect.New() E.focus = vect.New() E.temp = vect.New() for d := D0; d < NDirs; d++ { E.vec[d] = vect.New() E.vec[d].Set(Unit[d]) } E.delta = E.origin.Distance(E.focus) E.colour = col.ScreenF E.flaechig = false return E }
func Name(s string) { // file.Name(s + "." + suffix) eye[0].Set3(null, -eins, null) focus[0].Clr() n := file.Num() if n > 0 { vv, nn = make([]*vect.Imp, n), make([]*vect.Imp, n) for i := uint(0); i < n; i++ { vv[i], nn[i] = vect.New(), vect.New() } file.Seek(n - 1) p := pt.New() p = file.Get().(*pt.Imp) if p.ClassOf() == pt.Start { eye[0], focus[0] = p.Read2() } else { eye[0].Set3(null, null, eins) focus[0].Clr() } } }
func Ins1(c pt.Class, a uint, v []*vect.Imp, f col.Colour) { // // if started { ker.Stop (pack, 1) } if c > pt.Polygon { ker.Stop(pack, 2) } // if uint(len (v)) != a { println ("pts.Ins1: len(v) = ", len(v), " != a = ", a) } // ker.Stop (pack, 98) } p := pt.New() n := vect.New() n.Set3(null, null, eins) for i := uint(0); i < a; i++ { p.Set(c, a-1-i, f, v[i], n) file.Ins(p) } }
func init() { // right[0], front[1], top[2] = 1.0, 1.0, 1.0 matrix[3][3] = 1. for l := 0; l < MaxL; l++ { lightSource[l] = vect.New() } w := 2.0 * math.Pi / float64(nLamp) sin[0], cos[0] = C.GLdouble(0.0), C.GLdouble(1.0) sin[nLamp], cos[nLamp] = sin[0], cos[0] for g := 1; g < nLamp; g++ { sin[g] = C.GLdouble(math.Sin(float64(g) * w)) cos[g] = C.GLdouble(math.Cos(float64(g) * w)) } sin[nLamp+1], sin[1] = cos[nLamp+1], cos[1] // C.glDepthFunc (C.GL_LESS) // default C.glEnable(C.GL_DEPTH_TEST) C.glShadeModel(C.GL_SMOOTH) for i := 0; i < 3; i++ { lmAmb[i] = C.GLfloat(0.2) } // default: 0.2 lmAmb[3] = C.GLfloat(1.0) // default: 1.0 C.glLightModelfv(C.GL_LIGHT_MODEL_AMBIENT, &lmAmb[0]) for i := 0; i < 3; i++ { mAmbi[i] = C.GLfloat(0.2) } // default: 0.2 mAmbi[3] = C.GLfloat(1.0) // default: 1.0 // C.glLightModelfv (C.GL_LIGHT_MODEL_TWO_SIDE, 1) C.glMaterialfv(C.GL_FRONT_AND_BACK, C.GL_AMBIENT_AND_DIFFUSE, &mAmbi[0]) for i := 0; i < 3; i++ { mDiff[i] = C.GLfloat(0.8) } // default: 0.8 mDiff[3] = C.GLfloat(1.0) // default: 1.0 w = 1. C.glClearDepth(C.GLclampd(w)) // C.glMaterialfv (C.GL_FRONT_AND_BACK, C.GL_DIFFUSE, mDiff) // C.glColorMaterial (C.GL_FRONT_AND_BACK, C.GL_DIFFUSE) // C.glColorMaterial (C.GL_FRONT, C.GL_AMBIENT) C.glColorMaterial(C.GL_FRONT_AND_BACK, C.GL_AMBIENT_AND_DIFFUSE) C.glEnable(C.GL_COLOR_MATERIAL) C.glEnable(C.GL_LIGHTING) initialize() }
func init() { // file = pseq.New(pt.New()) eye[0], focus[0] = vect.New(), vect.New() gl.Cls(col.LightWhite) }
func Write() { // // TODO: pt der Class Start zuerst p1 := pt.New() fn := file.Num() vv, nn := make([]*vect.Imp, fn), make([]*vect.Imp, fn) for i := uint(0); i < fn; i++ { vv[i], nn[i] = vect.New(), vect.New() } // pts:= make ([]*pt.Imp, fn) i := uint(0) // file.Traverse (func (a Any) { pts[i] = pt.New(); pts[i].Copy (a.(*pt.Imp)) }) file.Seek(0) gl.Write0() // println ("pts.Write: gl.Write0 aufgerufen") // println ("vor for: file.Pos == ", file.Pos (), "/ fn == ", fn) for file.Pos()+1 < fn { // println ("file.Pos == ", file.Pos ()) i = uint(0) var a uint for { p1 = file.Get().(*pt.Imp) k := p1.Number() if i == 0 { if p1.ClassOf() == pt.Light { a = k k = 0 } else { a = k + 1 // ! } } vv[i], nn[i] = p1.Read2() i++ // println ("pts.Write: i == ", i) file.Step(true) if k == 0 { break } } var f gl.Figure switch p1.ClassOf() { case pt.None: f = gl.UNDEF case pt.Start: return case pt.Light: f = gl.LIGHT case pt.Points: f = gl.POINTS case pt.Lines: f = gl.LINES case pt.LineStrip: f = gl.LINE_STRIP case pt.LineLoop: f = gl.LINE_LOOP case pt.Triangles: f = gl.TRIANGLES case pt.TriangleStrip: f = gl.TRIANGLE_STRIP case pt.TriangleFan: f = gl.TRIANGLE_FAN case pt.Quads: println("pts.Write found Quads") f = gl.QUADS case pt.QuadStrip: f = gl.QUAD_STRIP case pt.Polygon: f = gl.POLYGON } // println ("pts.Write: nach switch: f == ", f) gl.Write(f, a, vv, nn, p1.Colour()) } gl.Write1() println("pts.Write: gl.Write aufgerufen") // println ("written") }
// E.vec[Right].Cross (E.vec[Top]) E.vec[Right].Ext(E.vec[Front], E.vec[Top]) E.vec[Right].Norm() } } E.Actualize() } func Report() { // errh.Error2("Bewegungen:", nB, "/ Drehungen:", nD) } var ( stack []([]byte) = make([]([]byte), 100) v *vect.Imp = vect.New() ) // Vielleicht geht das folgende ja noch einfacher ... func zl() uint { // return 4*v.Codelen() + col.Codelen() } func (E *Imp) Push(c col.Colour) { // B := make([]byte, zl()) a := 0 copy(B[a:a+8], E.origin.Encode()) a += 8