Search Results

Search found 1267 results on 51 pages for 'rotate'.

Page 25/51 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • ExtJS 4 Chart Axis Display Issue in Chrome

    - by SerEnder
    I've run into an issue while using ExtJS 4.0.7. I'm trying to display a chart with two series on a Numeric/Category Chart. The chart displays correctly in Firefox, but while using Chrome (18.0.1025.142) the x axis labels are either all stacked upon each or else (when using rotate) rendered behind the chart in the specified angle. Any ideas would be appreciated. Screen shot in Firefox: Screen Shot in Chrome: And the code that's used to generate both: Ext.require(['Ext.chart.*']); Ext.onReady(function() { var iChartWidth = 800; // Defines chart width var iChartHeight = 550; // Defines chart height Ext.define('RulesCreatedModel',{ extend:'Ext.data.Model', fields:[ {name:'sHourName', type:'string'}, {name:'User_2', type:'number'}, {name:'User_1', type:'number'}, ] }); var RulesCreatedStore = Ext.create('Ext.data.Store',{ id:'RulesCreatedStore', model:'RulesCreateModel', fields: [ 'sHourName','dayNum','hour','User_2','User_1'], data:[{ 'sHourName':'3pm', 'User_1':82, 'User_2':56 },{ 'sHourName':'4pm', 'User_1':39, 'User_2':44 },{ 'sHourName':'5pm', 'User_1':80, 'User_2':14 },{ 'sHourName':'6pm', 'User_1':55, 'User_2':0, },{ 'sHourName':'7pm', 'User_1':36, 'User_2':0, },{ 'sHourName':'8pm', 'User_1':66, 'User_2':0 },{ 'sHourName':'9pm', 'User_1':39, 'User_2':0, },{ 'sHourName':'10pm', 'User_1':0, 'User_2':0 },{ 'sHourName':'11pm', 'User_1':0, 'User_2':0 },{ 'sHourName':'12am', 'User_1':0, 'User_2':0 },{ 'sHourName':'1am', 'User_1':0, 'User_2':0 },{ 'sHourName':'2am', 'User_1':0, 'User_2':0 },{ 'sHourName':'3am', 'User_1':0, 'User_2':0 },{ 'sHourName':'4am', 'User_1':0, 'User_2':0 },{ 'sHourName':'5am', 'User_1':0, 'User_2':0 },{ 'sHourName':'6am', 'User_1':0, 'User_2':0 },{ 'sHourName':'7am', 'User_1':0, 'User_2':1 },{ 'sHourName':'8am', 'User_1':0, 'User_2':99 },{ 'sHourName':'9am', 'User_1':0, 'User_2':28 },{ 'sHourName':'10am', 'User_1':0, 'User_2':28 },{ 'sHourName':'11am', 'User_1':0, 'User_2':153 },{ 'sHourName':'12pm', 'User_1':0, 'User_2':58 },{ 'sHourName':'1pm', 'User_1':0, 'User_2':42 },{ 'sHourName':'2pm', 'User_1':20, 'User_2':10 }] }); Ext.create('Ext.chart.Chart',{ id: 'RulesWrittenChart', renderTo: 'StatCharts_Display', width: iChartWidth, height: iChartHeight, animate: true, store: RulesCreatedStore, axes: [{ type: 'Numeric', position: 'left', fields: ['User_2','User_1'], title: 'Rules Written', grid: true },{ type: 'Category', position: 'bottom', fields: ['sHourName'], title: 'Hour', grid: false, label: { rotate: { degrees: 315 } } }], series: [{ type: 'line', axis: 'left', xField: 'sHourName', yField: 'User_2', highlight: { size: 3, radius: 3 } },{ type: 'line', axis: 'left', xField: 'sHourName', yField: 'User_1', highlight: { size: 3, radius: 3 } }] }); });

    Read the article

  • error in a pygame code

    - by mekasperasky
    # INTIALISATION import pygame, math, sys from pygame.locals import * screen = pygame.display.set_mode((1024, 768)) car = pygame.image.load('car.png') clock = pygame.time.Clock() k_up = k_down = k_left = k_right = 0 speed = direction = 0 position = (100, 100) TURN_SPEED = 5 ACCELERATION = 2 MAX_FORWARD_SPEED = 10 MAX_REVERSE_SPEED = ­5 BLACK = (0,0,0) while 1: # USER INPUT clock.tick(30) for event in pygame.event.get(): if not hasattr(event, 'key'): continue down = event.type == KEYDOWN # key down or up? if event.key == K_RIGHT: k_right = down * ­5 elif event.key == K_LEFT: k_left = down * 5 elif event.key == K_UP: k_up = down * 2 elif event.key == K_DOWN: k_down = down * ­2 elif event.key == K_ESCAPE: sys.exit(0) # quit the game screen.fill(BLACK) # SIMULATION # .. new speed and direction based on acceleration and turn speed += (k_up + k_down) if speed > MAX_FORWARD_SPEED: speed = MAX_FORWARD_SPEED if speed < MAX_REVERSE_SPEED: speed = MAX_REVERSE_SPEED direction += (k_right + k_left) # .. new position based on current position, speed and direction x, y = position rad = direction * math.pi / 180 x += ­speed*math.sin(rad) y += ­speed*math.cos(rad) position = (x, y) # RENDERING # .. rotate the car image for direction rotated = pygame.transform.rotate(car, direction) # .. position the car on screen rect = rotated.get_rect() rect.center = position # .. render the car to screen screen.blit(rotated, rect) pygame.display.flip() enter code here the error i get is this Non-ASCII character '\xc2' in file race1.py on line 13, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Not able to understand what the error is and how to get rid of it?

    Read the article

  • Auto-rotating freshly created interface

    - by zoul
    Hello! I have trouble with auto-rotating interfaces in my iPad app. I have a class called Switcher that observes the interface rotation notifications and when it receives one, it switches the view in window, a bit like this: - (void) orientationChanged: (NSNotification*) notice { UIDeviceOrientation newIO = [[UIDevice currentDevice] orientation]; UIViewController *newCtrl = /* something based on newIO */; [currentController.view removeFromSuperview]; // remove the old view [window addSubview newCtrl.view]; [self setCurrentController:newCtrl]; } The problem is that the new view does not auto-rotate. My auto-rotation callback in the controller class looks like this: - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) io { NSString *modes[] = {@"unknown", @"portrait", @"portrait down", @"landscape left", @"landscape right"}; NSLog(@"shouldAutorotateToInterfaceOrientation: %i (%@)", io, modes[io]); return YES; } But no matter how I rotate the device, I find the following in the log: shouldAutorotateToInterfaceOrientation: 1 (portrait) shouldAutorotateToInterfaceOrientation: 1 (portrait) …and the willRotateToInterfaceOrientation:duration: does not get called at all. Now what? The orientation changing is becoming my least favourite part of the iPhone SDK… (I can’t check the code on the device yet, could it be a bug in the simulator?) PS. The subscription code looks like this: [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];

    Read the article

  • How to remove an object from the canvas?

    - by Marius Jonsson
    Hello there, I am making this script that will rotate a needle on a tachometer using canvas. I am a newbie to this canvas. This is my code: function startup() { var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var meter = new Image(); meter.src = 'background.png'; var pin = new Image(); pin.src = 'needle.png'; context.drawImage(meter,0,0); context.translate(275,297); for (var frm = 0; frm < 6000; frm++){ var r=frm/1000; //handle here var i=r*36-27; //angle of rotation from value of r and span var angleInRadians = 3.14159265 * i/180; //converting degree to radian context.rotate(angleInRadians); //rotating by angle context.drawImage(pin,-250,-3); //adjusting pin center at meter center } } Here is the script in action: http://www.kingoslo.com/instruments/ The problem is, as you can see, that the red needle is not removed beetween each for-loop. What I need to do is to clear the canvas for the pin object between each cycle of the loop. How do I do this? Thanks. Kind regards, Marius

    Read the article

  • gluLookAt vectors and FPS-style camera

    - by Kevin Pamplona
    I am attempting to implemented an FPS-style camera by updating three vectors: EYE, DIR, UP. These vectors are the same that are used by gluLookAt (since gluLookAt is specified by the position of the camera, the direction it is looking at, and an up vector). I have already implemented the left-right and up-down strafing movements, but I'm having a lot of trouble understanding the math behind making the camera look-around while remaining stationary. In this case, the EYE vector remains the same, while I must update DIR and UP. Below is the code I tried, but it doesn't seem to work properly. Any suggestions? Thanks. void Transform::left(float degrees, vec3& dir, vec3& up) { vec3 axis; axis = glm::normalize(up); mat3 R = rotate(-degrees, axis); dir = R*dir; dir = R*up; }; void Transform::up(float degrees, vec3& dir, vec3& up) { vec3 axis; axis=glm::normalize(glm::cross(dir,up)); mat3 R = rotate(-degrees, axis); dir = R*dir-; up = R*up; };

    Read the article

  • 3D Animation Rotating and Translating simultaneously in WPF

    - by sklitzz
    Hi, I have ModelVisual3D of a cube. I want to translate and rotate it at the same time. I wish the center of rotation to be in the middle of the cube(the cube rotates around its own axis). But when I try to do this applying both transformations the effect is not what you would expect. Since the object is translating the center of rotation is different thus making it move and rotate in a strange way. How do I get the desired effect? Transform3DGroup transGroup = new Transform3DGroup(); DoubleAnimation cardAnimation = new DoubleAnimation(); cardAnimation.From = 0; cardAnimation.To = 3; cardAnimation.Duration = new Duration(TimeSpan.FromSeconds(2)); Transform3D transform = new TranslateTransform3D(0,0,0); transGroup.Children.Add(transform); RotateTransform3D rotateTransform = new RotateTransform3D(); AxisAngleRotation3D rotateAxis = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180); Rotation3DAnimation rotateAnimation = new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2)); rotateAnimation.DecelerationRatio = 0.8; transGroup.Children.Add(rotateTransform); Model.Transform = transGroup; transform.BeginAnimation(TranslateTransform3D.OffsetXProperty, cardAnimation); rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, rotateAnimation);

    Read the article

  • How to calculate the normal of points on a 3D cubic Bézier curve given normals for its start and end points?

    - by Robert
    I'm trying to render a "3D ribbon" using a single 3D cubic Bézier curve to describe it (the width of the ribbon is some constant). The first and last control points have a normal vector associated with them (which are always perpendicular to the tangents at those points, and describe the surface normal of the ribbon at those points), and I'm trying to smoothly interpolate the normal vector over the course of the curve. For example, given a curve which forms the letter 'C', with the first and last control points both having surface normals pointing upwards, the ribbon should start flat, parallel to the ground, slowly turn, and then end flat again, facing the same way as the first control point. To do this "smoothly", it would have to face outwards half-way through the curve. At the moment (for this case), I've only been able to get all the surfaces facing upwards (and not outwards in the middle), which creates an ugly transition in the middle. It's quite hard to explain, I've attached some images below of this example with what it currently looks like (all surfaces facing upwards, sharp flip in the middle) and what it should look like (smooth transition, surfaces slowly rotate round). Silver faces represent the front, black faces the back. Incorrect, what it currently looks like: Correct, what it should look like: All I really need is to be able to calculate this "hybrid normal vector" for any point on the 3D cubic bézier curve, and I can generate the polygons no problem, but I can't work out how to get them to smoothly rotate round as depicted. Completely stuck as to how to proceed!

    Read the article

  • UIButton stops responding after going into landscape mode - iPhone

    - by casey
    I've been trying different things the last few days and I've run out of ideas so I'm looking for help. The situation is that I'm displaying my in-app purchasing store view after the user clicks a button. Button pressed, view is displayed. The store shows fine. Inside this view, I have a few labels with descriptions of the product, and then below them I have the price and a Buy button which triggers the in-app purchase. Problem is when I rotate the phone to landscape, that Buy button no longer responds, weird. Works fine in portrait. The behavior in landscape when the I touch the button is nothing. It doesn't appear to press down and be selected or anything, just not responding to my touches. But then when I rotate back to portrait or even upside down portrait, it works fine. Here is the rough structure of my view in IB, all the rotating and layout is setup in IB. I set the autoresizing in IB so that everything looks ok in landscape and the Buy button expands horizontally a little bit. The only layout manipulation I do in my code is after loading, I set the content size of the scroll view. File Owner with view set to the scrollView / scrollView ----/ view --------/ label --------/ label --------/ label --------/ label --------/ label --------/ label --------/ label --------/ label --------/ uibutton (Buy) After orientation changes I printed out the userInteractionEnabled property of the scrollView and the button, and they were both TRUE at all orientations. Ideas? Or maybe some other way of displaying a buy button that won't be nonfunctional? I've already begun a branch that plays with a toolbar and placing the buy button there, but I can't seem to get the bar to stay in place while scrolling.

    Read the article

  • determining if value is in range with 0=360 degree problem.

    - by Raven
    Hi, I am making a piece of code for DirectX app. It's meaning is to not show faces that are not visible. Normaly it would be just using Z-buffer, but I'm making many moves and rotations of mesh, so I would like to not do them and save computing power. I will describe this on cube. You are looking from the front so you see just one face and you don't need to rotate the 5 that left. If you would have one side of cube from 100*100 meshes, it would be great to not have to turn around 50k meshes that you really don't need. So I have stored X,Y,Z rotation of camera(the Z rotation I'm not using), and also X,Y,Z rotation of faces. In this cube simplified I would see faces that makes this statement true: cRot //camera rotation in degrees oRot //face rotation in degrees if(oRot.x > cRot.x-90 && oRot.x < cRot.x+90 && oRot.y > cRot.y-90 && oRot.y < cRot.y+90) But there comes a problem. If I will rotate arround, the camera can get to value 330 for exapmple. In this state, I would see front and right side of cube. Right side have rotation 270 so that's allright in IF statement. Problem is with 0 rotation of front face, which is also 360 degrees. So my question is how to make this statement to work, because when I use modulo, it will be failing for that right side and in this way it won't work for 0=360.

    Read the article

  • OpenGL circle rotation

    - by user350632
    I'm using following code to draw my circles: double theta = 2 * 3.1415926 / num_segments; double c = Math.Cos(theta);//precalculate the sine and cosine double s = Math.Sin(theta); double t; double x = r;//we start at angle = 0 double y = 0; GL.glBegin(GL.GL_LINE_LOOP); for(int ii = 0; ii < num_segments; ii++) { float first = (float)(x * scaleX + cx) / xyFactor; float second = (float)(y * scaleY + cy) / xyFactor; GL.glVertex2f(first, second); // output Vertex //apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL.glEnd(); The problem is that when scaleX is different from scaleY then circles are transformed in the right way except for the rotation. In my code sequence looks like this: circle.Scale(tmp_p.scaleX, tmp_p.scaleY); circle.Rotate(tmp_p.rotateAngle); My question is what other calculations should i perform for circle to rotate properly when scaleX and scaleY are not equal?

    Read the article

  • .next is undefined, jquery plugin problem

    - by ndelangen
    I'm trying to create my own plugin. But I'm having trouble getting things right. It appears when I'm trying to traverse inside .each things go wrong. I'm trying to go to the next item every 6 seconds by fading. jQuery(function($){ $.fn.rotator = function(options){ this.each(function() { var container = $(this); var images = container.children(); //Set the opacity of all images to 0 images.css({opacity: 0.0}); //Get the first image and display it (gets set to full opacity) $('div:first',this).css({opacity: 1.0}).addClass('show'); //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds var obj = $(this); setInterval(nextimage(obj),6000); }); }; // rotate function function nextimage(obj) { var container = $(obj); var images = container.children(); //Get the current image var current = (images.hasClass('show')? images.hasClass('show') : images.first()); //Get next image, when it reaches the end, rotate it back to the first image var next = ((current.next().length) ? ((current.next().hasClass('show')) ? images.first() :current.next()) : images.first()); //Set the fade in effect for the next image, the show class has higher z-index next.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, 1000); //Hide the current image current.animate({opacity: 0.0}, 1000) .removeClass('show'); }; }); $(document).ready(function(){ $("#bg").rotator({ }) }); The error I get is: current.next is not a function Line 35 Line 35 = var next = ((current.next().length) ? ((current.next().hasClass('show')) ? images.first() :current.next()) : images.first()); Can someone tell me what I'm doing wrong?

    Read the article

  • Maintaining Mouse Control in Embedded swfs (i.e. parent / child ) Flash cs4 AS3

    - by garydev
    Hello to all, I have an issue that is driving me nuts. I have an AS3 application that performs a calculation based upon user's input to determine a result. The purpose is to predict the results of a horse's coat color based on the genetics. The results are given in a 3d model swfs that are loaded into the "shell's" UILoader Component and they rotate. I have an example of this here: http://www.provideoshow.com/coatcalculator/coat_calculator.html As you can see this works fine with an "auto-rotate" feature. The problem is that my client wants the 3d models to be rotated by the user's mouse. I have the 3d models rotating with the mouse but they only work when they are stand alone swfs. They break when they are loaded into the shell. Some research informs me that the issue is in the stage properties and the parent not receiving them from the child. I've gotten some advice that I need to pass a reference to the shell's stage and preferably in the init function. This is the code I have in the child which is loaded as a class public function Main_master_withmouse() { if(stage) { _stage = stage; init(stage); } } protected function init(rootStage:Stage):void { if(rootStage) { _stage = rootStage; } else { _stage = this.stage; } sceneWidth = _stage.stageWidth createChildren(); startRendering(); } I can't figure out what to put in the parent to pass the reference to its stage. Any help is greatly appreciated. Thank you in advance

    Read the article

  • Hard Drive POV clock

    - by SkinnyMAN
    I am building a hard drive POV clock. (google it, they are pretty cool) I am working on the code for it, right now all i want to do is get the hang of making it do simple patterns with the RGB leds. I am wondering if anyone has any ideas on how to do something simple like make a red line rotate around the platter. right now what i have is an interrupt that triggers a function. int gLED = 8; // pins for RGB led strip int rLED = 9; int bLED = 10; attachInterrupt(0, ledPattern, FALLING); void ledPattern(){ digitalWrite(gLED, HIGH); // This will make a stable image of slice of the delayMicroseconds(500); // platter, but it does not move. digitalWrite(gLED, LOW); } That is the main part of the code (obviously I cut some stuff out that arduino requires) What I am trying to figure out is how can make that slice rotate around the platter. Eventually I will make the pattern more interesting by adding in other colors. Any Ideas?

    Read the article

  • Drawing straight lines in JavaScript

    - by Shawn31313
    I'm just trying to draw a line with JavaScript. I would like it to be like this: http://deepliquid.com/projects/blog/arrows2.html My version: http://jsfiddle.net/shawn31313/qsWML/5/show Doesn't work too well and I don't know how to get it too work. It must be an issue in my JavaScript. This my code: $(document).ready(function() { var dragStatus = 2, getPos, giveRandomID; $(document).mousedown(function(event) { dragStatus = 0; getPos = { top: event.clientY, left: event.clientX }; giveRandomID = Math.floor(Math.random() * 99999); }); $(document).mousemove(function() { var line = $('#line' + giveRandomID); if (dragStatus == 0) { $('body').append("<div id='line" + giveRandomID + "' style='position:absolute;top:" + getPos.top + "px;left:" + getPos.left + "px;background:black;width:2px;height:5px'></div>"); dragStatus = 1; } if (dragStatus == 1) { if (event.clientX > getPos.left) { line.css({ left: getPos.left, width: event.clientX - getPos.left }); } else { line.css({ left: event.clientX, width: getPos.left - event.clientX }); } if (event.clientY > getPos.top) { line.css({ top: getPos.top - Math.abs((event.clientY - getPos.top) * 2), '-webkit-transform': 'rotate(' + (event.clientY - getPos.top) + 'deg)' }); } else { line.css({ top: getPos.top + Math.abs((getPos.top - event.clientY) * 2), '-webkit-transform': 'rotate(' + (getPos.top - event.clientY) + 'deg)' }); } //for DEG "-" Top-Math.abs(DEG*2) for Deg "+" Top+(DEG*2) } }); $(document).mouseup(function() { dragStatus = 2; }); });? Thanks for any help fixing this. Mainly an issue with the math, just don't know how I can fix this.

    Read the article

  • How to maintain encapsulation with composition in C++?

    - by iFreilicht
    I am designing a class Master that is composed from multiple other classes, A, Base, C and D. These four classes have absolutely no use outside of Master and are meant to split up its functionality into manageable and logically divided packages. They also provide extensible functionality as in the case of Base, which can be inherited from by clients. But, how do I maintain encapsulation of Master with this design? So far, I've got two approaches, which are both far from perfect: 1. Replicate all accessors: Just write accessor-methods for all accessor-methods of all classes that Master is composed of. This leads to perfect encapsulation, because no implementation detail of Master is visible, but is extremely tedious and makes the class definition monstrous, which is exactly what the composition should prevent. Also, adding functionality to one of the composees (is that even a word?) would require to re-write all those methods in Master. An additional problem is that inheritors of Base could only alter, but not add functionality. 2. Use non-assignable, non-copyable member-accessors: Having a class accessor<T> that can not be copied, moved or assigned to, but overrides the operator-> to access an underlying shared_ptr, so that calls like Master->A()->niceFunction(); are made possible. My problem with this is that it kind of breaks encapsulation as I would now be unable to change my implementation of Master to use a different class for the functionality of niceFunction(). Still, it is the closest I've gotten without using the ugly first approach. It also fixes the inheritance issue quite nicely. A small side question would be if such a class already existed in std or boost. EDIT: Wall of code I will now post the code of the header files of the classes discussed. It may be a bit hard to understand, but I'll give my best in explaining all of it. 1. GameTree.h The foundation of it all. This basically is a doubly-linked tree, holding GameObject-instances, which we'll later get to. It also has it's own custom iterator GTIterator, but I left that out for brevity. WResult is an enum with the values SUCCESS and FAILED, but it's not really important. class GameTree { public: //Static methods for the root. Only one root is allowed to exist at a time! static void ConstructRoot(seed_type seed, unsigned int depth); inline static bool rootExists(){ return static_cast<bool>(rootObject_); } inline static weak_ptr<GameTree> root(){ return rootObject_; } //delta is in ms, this is used for velocity, collision and such void tick(unsigned int delta); //Interaction with the tree inline weak_ptr<GameTree> parent() const { return parent_; } inline unsigned int numChildren() const{ return static_cast<unsigned int>(children_.size()); } weak_ptr<GameTree> getChild(unsigned int index) const; template<typename GOType> weak_ptr<GameTree> addChild(seed_type seed, unsigned int depth = 9001){ GOType object{ new GOType(seed) }; return addChildObject(unique_ptr<GameTree>(new GameTree(std::move(object), depth))); } WResult moveTo(weak_ptr<GameTree> newParent); WResult erase(); //Iterators for for( : ) loop GTIterator& begin(){ return *(beginIter_ = std::move(make_unique<GTIterator>(children_.begin()))); } GTIterator& end(){ return *(endIter_ = std::move(make_unique<GTIterator>(children_.end()))); } //unloading should be used when objects are far away WResult unloadChildren(unsigned int newDepth = 0); WResult loadChildren(unsigned int newDepth = 1); inline const RenderObject& renderObject() const{ return gameObject_->renderObject(); } //Getter for the underlying GameObject (I have not tested the template version) weak_ptr<GameObject> gameObject(){ return gameObject_; } template<typename GOType> weak_ptr<GOType> gameObject(){ return dynamic_cast<weak_ptr<GOType>>(gameObject_); } weak_ptr<PhysicsObject> physicsObject() { return gameObject_->physicsObject(); } private: GameTree(const GameTree&); //copying is only allowed internally GameTree(shared_ptr<GameObject> object, unsigned int depth = 9001); //pointer to root static shared_ptr<GameTree> rootObject_; //internal management of a child weak_ptr<GameTree> addChildObject(shared_ptr<GameTree>); WResult removeChild(unsigned int index); //private members shared_ptr<GameObject> gameObject_; shared_ptr<GTIterator> beginIter_; shared_ptr<GTIterator> endIter_; //tree stuff vector<shared_ptr<GameTree>> children_; weak_ptr<GameTree> parent_; unsigned int selfIndex_; //used for deletion, this isn't necessary void initChildren(unsigned int depth); //constructs children }; 2. GameObject.h This is a bit hard to grasp, but GameObject basically works like this: When constructing a GameObject, you construct its basic attributes and a CResult-instance, which contains a vector<unique_ptr<Construction>>. The Construction-struct contains all information that is needed to construct a GameObject, which is a seed and a function-object that is applied at construction by a factory. This enables dynamic loading and unloading of GameObjects as done by GameTree. It also means that you have to define that factory if you inherit GameObject. This inheritance is also the reason why GameTree has a template-function gameObject<GOType>. GameObject can contain a RenderObject and a PhysicsObject, which we'll later get to. Anyway, here's the code. class GameObject; typedef unsigned long seed_type; //this declaration magic means that all GameObjectFactorys inherit from GameObjectFactory<GameObject> template<typename GOType> struct GameObjectFactory; template<> struct GameObjectFactory<GameObject>{ virtual unique_ptr<GameObject> construct(seed_type seed) const = 0; }; template<typename GOType> struct GameObjectFactory : GameObjectFactory<GameObject>{ GameObjectFactory() : GameObjectFactory<GameObject>(){} unique_ptr<GameObject> construct(seed_type seed) const{ return unique_ptr<GOType>(new GOType(seed)); } }; //same as with the factories. this is important for storing them in vectors template<typename GOType> struct Construction; template<> struct Construction<GameObject>{ virtual unique_ptr<GameObject> construct() const = 0; }; template<typename GOType> struct Construction : Construction<GameObject>{ Construction(seed_type seed, function<void(GOType*)> func = [](GOType* null){}) : Construction<GameObject>(), seed_(seed), func_(func) {} unique_ptr<GameObject> construct() const{ unique_ptr<GameObject> gameObject{ GOType::factory.construct(seed_) }; func_(dynamic_cast<GOType*>(gameObject.get())); return std::move(gameObject); } seed_type seed_; function<void(GOType*)> func_; }; typedef struct CResult { CResult() : constructions{} {} CResult(CResult && o) : constructions(std::move(o.constructions)) {} CResult& operator= (CResult& other){ if (this != &other){ for (unique_ptr<Construction<GameObject>>& child : other.constructions){ constructions.push_back(std::move(child)); } } return *this; } template<typename GOType> void push_back(seed_type seed, function<void(GOType*)> func = [](GOType* null){}){ constructions.push_back(make_unique<Construction<GOType>>(seed, func)); } vector<unique_ptr<Construction<GameObject>>> constructions; } CResult; //finally, the GameObject class GameObject { public: GameObject(seed_type seed); GameObject(const GameObject&); virtual void tick(unsigned int delta); inline Matrix4f trafoMatrix(){ return physicsObject_->transformationMatrix(); } //getter inline seed_type seed() const{ return seed_; } inline CResult& properties(){ return properties_; } inline const RenderObject& renderObject() const{ return *renderObject_; } inline weak_ptr<PhysicsObject> physicsObject() { return physicsObject_; } protected: virtual CResult construct_(seed_type seed) = 0; CResult properties_; shared_ptr<RenderObject> renderObject_; shared_ptr<PhysicsObject> physicsObject_; seed_type seed_; }; 3. PhysicsObject That's a bit easier. It is responsible for position, velocity and acceleration. It will also handle collisions in the future. It contains three Transformation objects, two of which are optional. I'm not going to include the accessors on the PhysicsObject class because I tried my first approach on it and it's just pure madness (way over 30 functions). Also missing: the named constructors that construct PhysicsObjects with different behaviour. class Transformation{ Vector3f translation_; Vector3f rotation_; Vector3f scaling_; public: Transformation() : translation_{ 0, 0, 0 }, rotation_{ 0, 0, 0 }, scaling_{ 1, 1, 1 } {}; Transformation(Vector3f translation, Vector3f rotation, Vector3f scaling); inline Vector3f translation(){ return translation_; } inline void translation(float x, float y, float z){ translation(Vector3f(x, y, z)); } inline void translation(Vector3f newTranslation){ translation_ = newTranslation; } inline void translate(float x, float y, float z){ translate(Vector3f(x, y, z)); } inline void translate(Vector3f summand){ translation_ += summand; } inline Vector3f rotation(){ return rotation_; } inline void rotation(float pitch, float yaw, float roll){ rotation(Vector3f(pitch, yaw, roll)); } inline void rotation(Vector3f newRotation){ rotation_ = newRotation; } inline void rotate(float pitch, float yaw, float roll){ rotate(Vector3f(pitch, yaw, roll)); } inline void rotate(Vector3f summand){ rotation_ += summand; } inline Vector3f scaling(){ return scaling_; } inline void scaling(float x, float y, float z){ scaling(Vector3f(x, y, z)); } inline void scaling(Vector3f newScaling){ scaling_ = newScaling; } inline void scale(float x, float y, float z){ scale(Vector3f(x, y, z)); } void scale(Vector3f factor){ scaling_(0) *= factor(0); scaling_(1) *= factor(1); scaling_(2) *= factor(2); } Matrix4f matrix(){ return WMatrix::Translation(translation_) * WMatrix::Rotation(rotation_) * WMatrix::Scale(scaling_); } }; class PhysicsObject; typedef void tickFunction(PhysicsObject& self, unsigned int delta); class PhysicsObject{ PhysicsObject(const Transformation& trafo) : transformation_(trafo), transformationVelocity_(nullptr), transformationAcceleration_(nullptr), tick_(nullptr) {} PhysicsObject(PhysicsObject&& other) : transformation_(other.transformation_), transformationVelocity_(std::move(other.transformationVelocity_)), transformationAcceleration_(std::move(other.transformationAcceleration_)), tick_(other.tick_) {} Transformation transformation_; unique_ptr<Transformation> transformationVelocity_; unique_ptr<Transformation> transformationAcceleration_; tickFunction* tick_; public: void tick(unsigned int delta){ tick_ ? tick_(*this, delta) : 0; } inline Matrix4f transformationMatrix(){ return transformation_.matrix(); } } 4. RenderObject RenderObject is a base class for different types of things that could be rendered, i.e. Meshes, Light Sources or Sprites. DISCLAIMER: I did not write this code, I'm working on this project with someone else. class RenderObject { public: RenderObject(float renderDistance); virtual ~RenderObject(); float renderDistance() const { return renderDistance_; } void setRenderDistance(float rD) { renderDistance_ = rD; } protected: float renderDistance_; }; struct NullRenderObject : public RenderObject{ NullRenderObject() : RenderObject(0.f){}; }; class Light : public RenderObject{ public: Light() : RenderObject(30.f){}; }; class Mesh : public RenderObject{ public: Mesh(unsigned int seed) : RenderObject(20.f) { meshID_ = 0; textureID_ = 0; if (seed == 1) meshID_ = Model::getMeshID("EM-208_heavy"); else meshID_ = Model::getMeshID("cube"); }; unsigned int getMeshID() const { return meshID_; } unsigned int getTextureID() const { return textureID_; } private: unsigned int meshID_; unsigned int textureID_; }; I guess this shows my issue quite nicely: You see a few accessors in GameObject which return weak_ptrs to access members of members, but that is not really what I want. Also please keep in mind that this is NOT, by any means, finished or production code! It is merely a prototype and there may be inconsistencies, unnecessary public parts of classes and such.

    Read the article

  • Apache rotatelogs gives error

    - by newbie.my
    Recently I have implement apache 2.4.1 in my web server.The problem is the rotate logs seems to be not functioning.Here is the output in the error_log: [core:error] [pid 13060:tid 47015847145408] (2)No such file or directory The command line that i have put in the httpd.conf are such as below: CustomLog "|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400" combined Is there anything wrong here with my setup?For your information I've already tested it in apache 2.2.22 and everythings is perfectly working. Thanks.

    Read the article

  • Ubuntu 10.04 LTS - Dual monitor works only sometimes (ATI multi-desktop)

    - by Beres Botond
    I've been using my laptop with an external LCD monitor attached to it at work (Philips 201E). And at home with a different external monitor (Samsung 2032BW). I have an ATI graphics card (HD3450), with Ati Catalyst drivers enabled and I'm using the Single display desktop (Multi-Desktop) seeting. At work I have the external monitor on the left and laptop on the right, while at home the other way around. So when I switch between the two setups, I just needed to go to Ati Catalyst Control Center, change the order of the displays, change the resolution (Home - 1680x1050, Work - 1440x900), reboot and it was all fine. But since a while it doesn't work properly anymore: At home it still works fine. At work it doesn't work. Sometimes it works for some reason, after a few resolution/setting changes in ACCC and reboots... it's very strange and annoying. With the home monitor I can see the whole bootup process on both monitors (laptop + LCD) and it always just works fine. With the work monitor on the external LCD monitor I just see "No video input" until I get to the login screen, then it shows up there as well. But after login it will either: Flicker a few times, but then work OK. Or (more often) Flicker once and then go back to "No video input" again. I usually end up rebooting a few times until it works. Does anyone have any idea for fixing it? This is my xorg.conf currently: Section "ServerLayout" Identifier "amdcccle Layout" Screen 0 "amdcccle-Screen[6]-0" 0 0 Screen "amdcccle-Screen[6]-1" 1280 0 EndSection Section "Files" EndSection Section "Module" Load "glx" EndSection Section "ServerFlags" Option "Xinerama" "off" EndSection Section "Monitor" Identifier "0-LVDS" Option "VendorName" "ATI Proprietary Driver" Option "ModelName" "Generic Autodetecting Monitor" Option "DPMS" "true" Option "PreferredMode" "1280x768" Option "TargetRefresh" "60" Option "Position" "0 0" Option "Rotate" "normal" Option "Disable" "false" EndSection Section "Monitor" Identifier "0-CRT1" Option "VendorName" "ATI Proprietary Driver" Option "ModelName" "Generic Autodetecting Monitor" Option "DPMS" "true" Option "TargetRefresh" "60" Option "Position" "0 0" Option "Rotate" "normal" Option "Disable" "false" Option "PreferredMode" "1440x900" EndSection Section "Device" Identifier "Default Device" Driver "fglrx" EndSection Section "Device" Identifier "amdcccle-Device[6]-0" Driver "fglrx" Option "Monitor-LVDS" "0-LVDS" BusID "PCI:6:0:0" EndSection Section "Device" Identifier "amdcccle-Device[6]-1" Driver "fglrx" Option "Monitor-CRT1" "0-CRT1" BusID "PCI:6:0:0" Screen 1 EndSection Section "Screen" Identifier "Default Screen" DefaultDepth 24 SubSection "Display" Virtual 2560 1024 EndSubSection EndSection Section "Screen" Identifier "amdcccle-Screen[6]-0" Device "amdcccle-Device[6]-0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection Section "Screen" Identifier "amdcccle-Screen[6]-1" Device "amdcccle-Device[6]-1" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection

    Read the article

  • Simple, free Mac OSX paint program with transparency

    - by Julie
    What FREE software (included with Mac OSX, or public domain) would be a good, simple way to take some existing PNG clipart files do some simple editing? I really only need to do 3 things: Rotate the image. Clip the image. Set a "transparent" color. I don't need anything that takes weeks to learn... or is super-powerful... or super expensive. Thanks.

    Read the article

  • Mac OS X bug: Desktop & Screen Saver: image alignment preference is ignored.

    - by Aaron F.
    I have my desktop background set to rotate through a folder of images. Even though I have the alignment drop-down list set to "Center", the images still render as "Fill to Screen". When I change the list value to something else, then back to "Center", OR I manually click on a different image to display, well, that image is rendered as "Center". But all images that follow (via the "Change picture every x minutes" checkbox) are rendered as Fill to Screen. Any fix to this bug?

    Read the article

  • Simple, free Mac OS X paint program with transparency

    - by Margret
    What FREE software (included with Mac OS X, or public domain) would be a good, simple way to take some existing PNG clipart files and do some simple editing? I really only need to do 3 things: Rotate the image. Clip the image. Set a "transparent" color. I don't need anything that takes weeks to learn or is super-powerful or super expensive.

    Read the article

  • Squid Log Rotation and Sarg

    - by beakersoft
    We have just setup squid as our proxy, and i was going to use Sarg to analyze the log files. I had initially set the Squid logs to rotate everyday so they dont get huge. The problem is i cant see an option in the squid config to read a folder full of squid log files (say *.log). Is there an easy way to do this or am i going to have to write a bash script or something to process them all into one before i get squid to read it? Cheers Luke

    Read the article

  • Free-space driven log rotation on linux?

    - by kdt
    Someone just asked me 'how long should we keep logs for our application', and my answer was 'until the disk is full' as there's no reason to throw them away other than running out of space. However, standard logrotate wants us to specify a specific period + number of rotations. Is there something similar that would let us say "rotate daily, and keep as much history as you like until there is only 5% space free"? The platform is Redhat Linux.

    Read the article

  • assign user and group to site log files

    - by Francis
    When in a site apache conf file, is there a way to set the user and group for the CustomLog and ErrorLog? Right now, these 2 records create the error and access log with root:root permissions, but I would like them to be flewis:admin CustomLog /var/log/httpd/domain.com-access.log combined ErrorLog /var/log/httpd/domain.com-error.log If I change the user:group of the files, when the logs rotate, the new logs are root:root

    Read the article

  • Tomcat, change webapp to log to its own file.

    - by nos
    I've a webapp that apparently uses the standard java.util.Logging (no log4j or other stuff). Everything is logged under "com.bzsearchj.". I'm assuming I can configure Tomcat 6, via $CATALINA_HOME/conf/logging.properties to have it log everything under com.bzsearcj. to its own file, bonus if I can make it rotate daily - right now everything gets logged to the catalina-xxx.log What do I put in the conf/logging.properties to do this ?

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >